Historical / pre-build. The working plan feature has shipped. Use 0021-working-plan.md for current behaviour and ops. This file keeps the original BetterShift evaluation and in-house build plan for context only.
This document describes a plan to implement a working plan (shift schedule / rota) for kitchen, bar, and waiters: who is scheduled to work on which days and time slots.
BetterShift is an open-source, self-hosted shift management app (Next.js 16, React 19, SQLite, Drizzle, Better Auth). We evaluated it for integration.
| Aspect | BetterShift | POS2 need |
|---|---|---|
| Data model | Shifts belong to calendars; a shift is a time slot (title, start/end, color) on a calendar. There is no user_id on a shift - it’s “this calendar has these blocks” and sharing is at calendar level. |
We need assignments: “user X works on date Y from 09:00-14:00”. I.e. shifts must reference our User (kitchen/bartender/waiter) and be scoped by tenant. |
| Multi-tenancy | No tenant/organization; model is global users + calendars + shares. | Everything in POS2 is tenant-scoped (restaurant); users and data are per-tenant. |
| User / auth | Own user table and Better Auth (OAuth, OIDC, etc.). | We use JWT + tenant-scoped users with roles (owner, admin, kitchen, bartender, waiter). Our users already exist in PostgreSQL. |
| Stack | Next.js, React, SQLite, Drizzle. Full standalone app. | Angular frontend, FastAPI backend, PostgreSQL. We need a page inside our app, not a second app. |
| Integration | Not a library; no “embed in existing app” story. Options: run as separate service (two logins, two UIs, sync users/shifts) or fork and port (replace DB, auth, add tenant_id everywhere). | Single app, single login, one DB; working plan is one feature area. |
- Light integration (e.g. iframe + link): possible but gives two UIs, two auth systems, and no shared notion of “our waiters/kitchen/bar” or tenant. Not a good fit.
- Deep integration (fork, add tenant_id, add user_id to shifts, swap auth/DB): effectively a full port and long-term maintenance of their codebase.
- Building our own MVP (one
shifttable, CRUD API, one Angular page) is aligned with our stack, tenant and user model, and the scope in §1-2. We can deliver a minimal working plan quickly and extend later (reports, “on shift” filters, export).
Recommendation: develop the working plan in-house as described in this document. Use BetterShift only as UI/UX inspiration (e.g. week view, presets) if desired.
- Define who works when - Assign staff (by role: kitchen, bartender, waiter) to date-based slots (e.g. morning, evening, or custom time ranges).
- Single source of truth - One place for managers to maintain the weekly/daily rota; visible to staff and usable for reports and optional automation.
- Reuse existing roles - Build on
UserRole(kitchen, bartender, waiter) and tenant-scopedUser; no new “staff type” beyond role. - Keep scope bounded - No payroll, no clock-in/out, no automatic assignment of orders to “on-shift” staff in the first version. Optional later: filter floor/table waiter lists by “on shift today”.
- Data model: Shifts (or “schedule entries”) per tenant: date, time range (start/end), user_id, optional label (e.g. “Morning”, “Evening”).
- Backend: CRUD API for schedule entries; list by date range; list users by role for pickers.
- Frontend: A Working plan (or Schedule / Rota) page where owner/admin can:
- View a week (or chosen date range) in a simple grid: days × slots or days × list of assignments.
- Add shift: pick user (filtered by role: kitchen, bartender, waiter), date, start/end time, optional label.
- Edit/delete a shift.
- Access: Owner and admin only (permission: e.g.
SCHEDULE_READ,SCHEDULE_WRITE). - i18n: Translation keys for the new screen and labels (e.g. “Working plan”, “Kitchen”, “Bar”, “Waiters”, “Morning”, “Evening”).
- Automatic assignment of tables/floors to “on shift” waiters only.
- Clock-in/clock-out and actual hours tracking.
- Payroll or wage calculation.
- Notifications/reminders (“your shift tomorrow”).
- Public view of “who’s working today”.
- Shift (tenant-scoped):
id,tenant_iduser_id(FK → User; user must belong to tenant and have role in kitchen | bartender | waiter)date(date)start_time(time)end_time(time)label(optional string, e.g. "Morning", "Evening")created_at,updated_at
- Indexes:
(tenant_id, date),(user_id, date). - Role is derived from
User.role; no need to store role on the shift (consistent with existing user management).
- We could define named slots per tenant (e.g. “Morning”, “Evening”) from opening hours and then assign users to (date, slot_name). That adds a layer of configuration (slot definitions) and may be overkill for MVP. Recommendation: Option A with optional
labelfor display only; time range is explicit.
start_time<end_time.- User must be in same tenant and have role in
{kitchen, bartender, waiter}. - No duplicate (user_id, date, start_time) or overlapping ranges for same user on same day (optional business rule; can be relaxed in v1).
- Add
SCHEDULE_READandSCHEDULE_WRITEtoPermissionenum. - Grant both to
ownerandadmininROLE_PERMISSIONS(seeback/app/permissions.py).
| Method | Path | Description | Permission |
|---|---|---|---|
| GET | /schedule or /working-plan |
List shifts; query: from_date, to_date (inclusive), optional user_id, optional role (filter users by role) |
SCHEDULE_READ |
| GET | /schedule/{id} |
Get one shift | SCHEDULE_READ |
| POST | /schedule |
Create shift (user_id, date, start_time, end_time, label?) | SCHEDULE_WRITE |
| PUT | /schedule/{id} |
Update shift | SCHEDULE_WRITE |
| DELETE | /schedule/{id} |
Delete shift | SCHEDULE_WRITE |
- List users for picker: Reuse existing
GET /users(tenant-scoped); frontend filters byrolein [kitchen, bartender, waiter]. If needed, add optional query?role=waiterto reduce payload. - Date params: ISO date strings
YYYY-MM-DD; backend parse and filterShiftbydate >= from_dateanddate <= to_date.
- Create:
POST /schedulebody:{ "user_id": 3, "date": "2025-03-20", "start_time": "09:00", "end_time": "14:00", "label": "Morning" }. - List:
GET /schedule?from_date=2025-03-17&to_date=2025-03-23→ array of shifts withid,user_id,user_name(or email),role,date,start_time,end_time,label.
- Route: e.g.
/working-planor/schedule(configurable; “Working plan” in nav). - Guard:
authGuard+ permission guard (SCHEDULE_READ minimum to see the page; SCHEDULE_WRITE to add/edit/delete).
- Toolbar: Date range selector (e.g. week picker: “Week of 17 Mar 2025” with prev/next); optional “Today”.
- Main area:
- Option 1 - Table: Rows = days in range, columns = roles (Kitchen, Bar, Waiters) or “Morning”/“Evening”; cells show assigned staff names (and time if needed). Click cell to add/edit.
- Option 2 - List: List of shifts grouped by day; each line: date, time range, label, user name, role. Buttons: Add shift, Edit, Delete.
- Add/Edit shift modal: Dropdown for User (filter by role: kitchen, bartender, waiter), date picker, start time, end time, optional label. Validate start < end.
- Empty state: “No shifts in this period. Add a shift to build your working plan.”
- Dashboard: add link “Working plan” (owner/admin only).
- Sidebar: same link under Settings or a “Planning” group if you introduce one.
- New keys under e.g.
WORKING_PLAN.*: title, description, add_shift, edit_shift, delete_shift, date_range, morning, evening, kitchen, bar, waiters, no_shifts, user_placeholder, etc. Reuse existingROLES.KITCHEN,ROLES.BARTENDER,ROLES.WAITERwhere applicable. AddNAV.WORKING_PLANorNAV.SCHEDULE.
- Create table
shift(orschedule_entry) with columns above. - Foreign keys:
tenant_id→tenant.id,user_id→user.id. - Indexes:
(tenant_id, date),(user_id, date).
- Migration: create
shifttable. - SQLModel:
Shiftmodel; Pydantic schemas:ShiftCreate,ShiftUpdate,ShiftResponse(include user name, role for list). - Permissions: add
SCHEDULE_READ,SCHEDULE_WRITE; assign to owner and admin. - Endpoints: GET list (with date range), GET one, POST, PUT, DELETE. Ensure all filter by
tenant_idand that selected user belongs to tenant and has role kitchen/bartender/waiter.
- Route and guard:
/working-plan, show only for users with SCHEDULE_READ. - Working plan page: date range selector, list or table of shifts, “Add shift” button.
- Add/Edit modal: user picker (filter by role), date, start/end time, label; call API.
- Delete: confirm and call DELETE.
- Dashboard and nav: link to Working plan for owner/admin.
- i18n: all new keys in
en(and optionally other locales).
- Reports: filter “by waiter” / “by role” already exist; optional “only on-shift staff” filter using schedule.
- Tables/Floors: when assigning default waiter or table waiter, optionally restrict dropdown to users on shift today (requires “who is on shift today” API or client-side filter).
- Export: export week as PDF or CSV for printing rota.
- Migration:
shifttable with tenant_id, user_id, date, start_time, end_time, label. - Models and schemas: Shift, ShiftCreate, ShiftUpdate, ShiftResponse.
- Permissions: SCHEDULE_READ, SCHEDULE_WRITE for owner and admin.
- API: GET /schedule (date range), GET /schedule/{id}, POST, PUT, DELETE.
- Frontend: /working-plan page with date range, list/table of shifts, add/edit/delete.
- Nav and dashboard: Working plan link (owner/admin).
- i18n: WORKING_PLAN.* and NAV.WORKING_PLAN.
- Smoke test: create shift, list by week, edit, delete (manual or Puppeteer).
- Existing roles:
back/app/models.py-UserRole(kitchen, bartender, waiter). - Permissions:
back/app/permissions.py- add new permissions and role mapping. - Similar feature: Reservations (date/time, tenant-scoped) -
docs/0010-table-reservation-implementation-plan.md. - Opening hours: Settings “split shifts” (morning/evening) are for business hours, not staff shifts; reuse labels only if desired (e.g. “Morning”/“Evening” in dropdown).