LLOU Ecosystem — Audit, Architecture & Development Plan
Revision 3.1 — Revision 3 plus the Account Access, Invitations and Authorization Policy (Section 18). Status: planning only. Nothing implemented. Date: 30 October 2026
What changed in Revision 3
| # | Final adjustment requested | Where addressed | | --- | --- | --- | | 1 | Employees submit and update their own bank / payment details, with no full account number ever exposed | Section 4.9, Section 9.8 | | 2 | Explicit self-service permissions listed for every personal capability | Section 6.2 | | 3 | Self-service can never reach operations, customers, orders, food prices, recipes or business finance | Section 6.3, Section 12 | | 4 | Chef, manager and internal admin permissions fully configurable and independently assignable by the owner | Section 6.5 | | 5 | Marketplace modifications to Driver and DeliveryBatch deferred to the marketplace phase | Section 4.2, Section 4.10 | | 6 | Every existing DELICES, DROP DRIVER and Admin feature preserved — no deletion, replacement, redesign or regression | Section 8.2 | | 7 | Real Base44 mobile publishing capabilities and limitations stated | Section 15 | | 8 | One owner-controlled administration interface for all users, employees, positions, permissions, promotions, departments and org settings | Section 6.6, Section 9.9 |
Added in Revision 3.1 — Account Access, Invitations and Authorization Policy
| Policy section | Adopted as | Where | | --- | --- | --- | | 1 Owner authority over all internal accounts | Owner capabilities table, every action backend-enforced and audited | 18.1 | | 2 Delegated account administration with hard limits | DelegationGrant record plus a delegation check inside the access gate | 18.2 | | 3 Invitation links, individual QR codes, general registration QR codes | AccessInvitation entity; a general QR code never activates an account | 18.3 | | 4 Account lifecycle and prompt revocation | AccountStatusEvent; access denied on the next request; records retained | 18.4 | | 5 Platforms covered, names finalised later | Platform register, policy independent of branding | 18.5 | | 6 Customer accounts excepted | Customer registration unchanged and never invitation-gated | 18.7 | | 7 Backend enforcement and audit | Gate order, audit events, retention rules | 18.8 |
1. Existing System Audit (unchanged)
One Base44 app hosts four interfaces on one database: the LLOU DELICES public site, the /admin console, the /driver portal (DROP DRIVER) and /staff (crew onboarding).
| Platform | State | What exists | | --- | --- | --- | | LLOU DELICES site | Working (business data thin) | 24 pages: home, menu (pickup/delivery split), dish detail, collection and filters, cart, guest checkout, order tracking, account, pickup scheduling, policies, ingredients, contact, help and tickets, reviews, newsletter | | Admin console (/admin) | Working | 26 sections: dashboard, orders, pickups, menu, catalog, add-ons, service schedule, delivery, dispatch, zones and pay, batch pricing, drivers, driver dashboard, invitations, availability, compensation, reports, audit, employees, team and access, security, inbox, driver support, customer support, settings | | DROP DRIVER (/driver) | Working | 20 pages incl. map home with Dash Now, marketplace, offers, active batch with photo/OTP/signature proof, earnings, withdrawals, analytics, support, profile, city | | Driver onboarding | Working | 10-step application, private document storage, invitations and QR, identity vs approval separation, suspend/revoke lifecycle | | Crew / employees | Partial | Application, approval, employee record, custom roles on a 24-key permission catalogue, directory. No scheduling, no time clock, no leave, no payroll, no documents, no positions, no promotion flow, no self-service | | Security | Working | Private /admin-access, TOTP second factor, recovery codes, sessions, devices, policy modes, lockout, step-up, audit log | | Support desk | Working | One SupportTicket entity, separate customer/driver/admin interfaces | | Marketplace / merchant | Missing | No merchant, store, product or marketplace-order structure |
Live counts: 43 entities, 6 staff roles, 0 employees, 2 drivers, 3 menu items, 0 orders, 1 delivery batch, 35 audit entries, payment provider none. There are no workflows yet.
2. Current Architecture
Customer --> DELICES site --+
Driver --> /driver -------+--> ONE Base44 app --> 43 entities (RLS) --> 32 functions --> 11 shared modules
Staff --> /admin, /staff + Core only: LLM, email, private files
No payments - No connectors - No workflows
3. Proposed Architecture
One shared backend app. Two staff populations separated at the door, not hidden in the UI.
+================ SHARED BASE44 BACKEND ================+
| Identity - RLS - functions - audit - delivery engine |
| private files - notification dispatch |
+==+==========+===========+===========+=========+========+
| | | | |
/ (site) | /crew | /driver | /merchant | /drop |
DELICES | Admin & | DROP | portal | market |
unchanged | Crew | DRIVER | (future) | (future)|
| (now) | unchanged | | |
+----------+-----------+-----------+---------+
/crew splits internally into two shells that never overlap:
/crew/admin/* Internal administrative users -> operations, orders, menu,
(owner, admin user, manager, prices, recipes, sales, staff
chef, finance, support) administration, payroll
/crew/me/* Restaurant employees -> MY profile, MY photo, MY
(cashier, server, dishwasher, schedule, MY clock, MY pay,
cleaner) MY bank details, MY leave,
MY documents, team messages
| Platform | Namespace | Phase | Rule | | --- | --- | --- | --- | | DELICES | / | live | Untouched, independent brand | | Admin and Crew | /crew with the two shells above | now | One login, dashboard decided by staff class and permission | | DROP DRIVER | /driver | live | Untouched | | Merchant portal | /merchant | future | Schema prepared, not built | | LLOU DROP | /drop | future | Opt-in marketplace, DELICES never auto-listed |
Why one app: Base44 gives each app its own database. A shared backend is only real inside one app, separated by namespace and permission. A future separate brand app would have to call this app's API and would lose transactional integrity across orders, batches and pay.
4. Final Database Schema
4.1 Reused unchanged — 43 existing entities
User, StaffRole, AuditLog, SiteSettings, Order, OrderItem, MenuItem, AddOn, MenuAddOnGroup, ServiceDate, ServiceSchedule, PickupRequest, PaymentRecord, DeliveryZone, DeliveryBatch, DeliveryStop, DeliveryOffer, BatchRequest, BatchPricing, PricingRules, Compensation, Withdrawal, Driver, DriverAvailability, DriverLocation, DriverNotification, DriverBadge, DriverRating, DriverInvitation, DriverCityRequest, SupportTicket, CustomerAddress, FavoriteDish, Review, NewsletterSubscriber, ContactMessage, LateOrderInquiry, NotificationLog, AdminSecurity, AdminSecurityPolicy, AdminSession, AdminDevice, Employee (extended only).
4.2 Extended, not replaced — and explicitly not touched now
| Table | Change | Timing | | --- | --- | --- | | Employee | Additive fields only — Section 5 | Phase 2 | | StaffRole | Add staff_class and position_scope; permissions stay a flat array; no rename | Phase 2 | | SiteSettings | Add crew_timezone, crew_week_start, overtime_weekly_hours, daily_overtime_hours, overtime_multiplier, seventh_day_rule, rounding_minutes, geofence_radius_meters, geofence_required_default, geofence_mode, auto_clockout_hours, document_expiry_alert_days, leave_year_start, bank_changes_require_review, payroll_provider | Phase 2 | | User | No schema change — already carries role, is_owner, staff_status | — | | Driver | No change in this programme. merchant_id is deferred | Phase 12 only | | DeliveryBatch | No change in this programme. merchant_id and source are deferred | Phase 12 only | | DeliveryStop, Compensation, BatchPricing, PricingRules, DeliveryOffer, BatchRequest, Withdrawal | No change | — | | AccessInvitation, AccountStatusEvent, DelegationGrant | New access-governance tables required by Section 18 | Phase 2 | | Existing DriverInvitation, AdminSession, AdminDevice, AuditLog | Kept as they are; AccessInvitation covers internal, driver and merchant invitations, while DriverInvitation keeps serving today's driver QR flows until migrated | — |
Deferral rule: no field is added to Driver or DeliveryBatch while building the crew system. When the marketplace phase opens, the two fields are added additively and defaulted, then backfilled; until then every delivery and driver query is identical to today.
4.3 Scheduling and attendance
| Table | Purpose | Key fields | Relations | | --- | --- | --- | --- | | Department | Org units | name, key, description, active | 1 to n JobPosition, Employee | | JobPosition | Job titles and their default access | title, department_id, level, staff_class, responsibilities[], default_permissions[], pay_type, base_rate, overtime_eligible, standard_weekly_hours, active | n to 1 Department | | EmployeeAvailability | Recurring availability plus exceptions | employee_id, weekday, windows[], effective_from, exception_date, kind (available/unavailable/preferred), note | n to 1 Employee | | Shift | A scheduled block of work | employee_id, position_id, location_id, date, start_time, end_time, break_minutes, status (draft/published/swap_requested/covered/cancelled/completed/no_show), published_at, published_by, note | n to 1 Employee, JobPosition | | ShiftSwapRequest | Cover a shift, give one away | shift_id, from_employee_id, to_employee_id, type (swap/cover/drop), reason, status (requested/accepted_by_peer/approved/declined/withdrawn), decided_by, decided_at | n to 1 Shift | | TimeClockEntry | A punched shift | employee_id, shift_id, date, clock_in_at, clock_out_at, clock_in_lat, clock_in_lng, clock_in_accuracy, clock_in_distance_m, geofence_result (inside/outside/unknown), clock_out_lat, clock_out_lng, breaks[] (start, end, minutes, paid), break_minutes_total, minutes_worked, source (web/kiosk/manager), device_label, auto_closed, auto_close_reason, status (open/submitted/approved/flagged/corrected), approved_by, approved_at, correction_note | n to 1 Employee, Shift | | TimesheetPeriod | Weekly approval container | employee_id, period_start, period_end, regular_minutes, overtime_minutes, break_minutes, paid_leave_minutes, status (open/submitted/approved/locked), submitted_at, approved_by, approved_at, note | 1 to n TimeClockEntry |
Note: there is no continuous location tracking in this design. Location is captured only at the moment of a punch, in the foreground, because that is what the platform supports (Section 15).
4.4 Leave — configurable PTO and sick leave
| Table | Purpose | Key fields | Relations | | --- | --- | --- | --- | | LeavePolicy | One row per policy the owner defines | name, key, type (pto/sick/personal/unpaid/bereavement/other), paid, accrual_method (annual_grant/per_hour_worked/per_pay_period/none), accrual_amount, accrual_hours_basis, max_balance_hours, carryover_max_hours, carryover_expires_months, waiting_days, min_notice_days, max_consecutive_days, requires_approval, allow_partial_day, requires_document_after_days, blackout_dates[], eligible_employment_types[], active | — | | EmployeeLeaveEnrollment | Which policies an employee holds | employee_id, policy_id, enrolled_at, accrual_start_date, override_accrual_amount, note | n to 1 Employee, LeavePolicy | | LeaveBalance | Running balance per policy per year | employee_id, policy_id, year, accrued_hours, used_hours, pending_hours, adjusted_hours, available_hours, expires_at, updated_at | n to 1 Employee, LeavePolicy | | LeaveAdjustment | Manual grant or correction | employee_id, policy_id, hours, reason, decided_by, decided_at | n to 1 LeaveBalance | | TimeOffRequest | A request and its decision | employee_id, policy_id, start_date, end_date, partial_day, hours, reason, attachment_uri (private), status (draft/submitted/pending/approved/declined/cancelled), decided_by, decided_at, decision_note, balance_deducted | n to 1 Employee, LeavePolicy |
4.5 Pay structures — hourly and salaried
| Table | Purpose | Key fields | Relations | | --- | --- | --- | --- | | PayRate | Effective-dated compensation | employee_id, pay_type (hourly/salary), hourly_rate, annual_salary, standard_weekly_hours, overtime_eligible, exempt_status (exempt/non_exempt), overtime_multiplier, effective_from, effective_to, reason, approved_by, approved_at | n to 1 Employee | | PayrollRun | A pay period | period_start, period_end, pay_date, status (draft/open/review/locked/exported/paid), employee_count, regular_hours, overtime_hours, gross_total, deduction_total, net_total, computed_by, computed_at, locked_by, locked_at | 1 to n Payslip | | Payslip | One employee's result | payroll_run_id, employee_id, pay_type, regular_hours, overtime_hours, hourly_rate_used, annual_salary_used, regular_pay, overtime_pay, paid_leave_pay, bonus, deductions[] (label, amount, kind), gross, net, status (draft/approved/paid/void), document_uri (private), paid_at, note | n to 1 PayrollRun, Employee |
Hourly: approved timesheet minutes at the rate in force on that date, plus overtime above the configured threshold at the policy multiplier. Salaried: gross = annual_salary divided by periods per year, prorated for mid-period starts, departures and unpaid leave; overtime only when the position is marked non-exempt. A derived hourly equivalent is shown on the employee record so labour cost stays comparable.
4.6 Employee documents
| Table | Purpose | Key fields | Relations | | --- | --- | --- | --- | | EmployeeDocument | Uploaded file plus its validity | employee_id, kind (contract/id/certification/food_handler/tax_form/bank_letter/other), title, file_uri (private), file_name, uploaded_by (employee/owner), uploaded_at, status (pending/verified/rejected/expired), expires_at, expiry_alert_days, reviewed_by, reviewed_at, review_note, replaces_document_id | n to 1 Employee | | EmployeeDocumentRequest | Owner asks for a document | employee_id, kind, title, instruction, due_at, status (requested/uploaded/waived/overdue), fulfilled_document_id, requested_by, requested_at | n to 1 Employee | | EmployeeHandbookAck | Proof of policy acknowledgement | employee_id, document_id, version, accepted_at | n to 1 Employee |
4.7 Internal communication
| Table | Purpose | Key fields | Relations | | --- | --- | --- | --- | | Conversation | A channel, group or direct thread | title, kind (announcement_channel/team/direct/operations), department_id, member_ids[], created_by, archived_at, last_message_at | 1 to n Message | | Message | One message with optional files | conversation_id, author_id, author_name, author_class, body, attachments[] (file_uri private, file_name, type), reply_to_id, pinned, edited_at | n to 1 Conversation | | Announcement | Operational broadcast | title, body, audience (all/internal_admin/department/position/employees), department_id, position_id, employee_ids[], severity, attachment_uris[], publish_at, expires_at, created_by, requires_acknowledgement | 1 to n AnnouncementRead | | AnnouncementRead | Who has seen or acknowledged | announcement_id, employee_id, read_at, acknowledged_at | n to 1 Announcement | | StaffNotification | Internal notification feed | employee_id, kind (shift/swap/timeclock/leave/payroll/document/bank/message/announcement/timesheet/account), title, body, link, priority, dedupe_key, read_at, created_by | n to 1 Employee |
4.8 Promotion and job history
| Table | Purpose | Key fields | Relations | | --- | --- | --- | --- | | PromotionRequest | The review-first promotion workflow | employee_id, requested_by, current_position_id, current_role_key, current_permissions[], current_pay_type, current_rate, proposed_position_id, proposed_role_key, proposed_title, proposed_permissions[], proposed_self_service[], permissions_added[], permissions_removed[], proposed_pay_type, proposed_rate, effective_date, responsibilities[], reason, status (draft/pending_review/approved/rejected/cancelled/applied), reviewed_by, reviewed_at, review_note, applied_at, history_id | n to 1 Employee | | EmploymentHistory | Immutable record of every job change | employee_id, event (hired/promoted/pay_change/role_change/permissions_changed/suspended/reactivated/leave_started/leave_returned/terminated), from_position_id, to_position_id, from_rate, to_rate, from_role_key, to_role_key, effective_date, reason, promotion_request_id, decided_by, decided_at | n to 1 Employee |
4.9 Employee payout details — full account numbers are never stored (final adjustment 1)
| Table | Purpose | Key fields | Relations | | --- | --- | --- | --- | | EmployeeBankProfile | Where the employee is paid. Masked by construction | employee_id, account_holder, institution, account_type (checking/savings), country, currency, last4 only, routing_last4 only, provider, provider_token, masked_label (e.g. ending 4021), status (pending_verification/verified/rejected/superseded), submitted_by (employee/owner), previous_profile_id, change_reason, verified_at, verified_by, rejected_reason, note | n to 1 Employee; chain via previous_profile_id |
Rules that make exposure impossible rather than merely restricted:
- The full account number is never written to any table. The form captures it, sends it once to the payout provider's tokenisation endpoint, and only the provider token plus the last four digits come back. What is stored is what cannot be misused.
- Until a payout provider is connected (today: none), the app does not accept full numbers at all. The employee submits a payout preference — holder name, institution, account type, last four — marked pending_verification, and the owner completes verification with the provider directly. A full number typed into a form that cannot tokenise it would be a liability, so no such field exists in that mode.
- Every change is a new record, never an edit. Submitting new details creates a row with status pending_verification and previous_profile_id set; the previous row stays active and is superseded only after verification. Payroll always reads the verified active row. The chain is the bank-change audit trail, which is the classic payroll fraud vector.
- Change alerts are mandatory. Submitting a bank change notifies the owner and every payroll holder immediately, whatever notification preferences are set.
- Re-authentication before a change. The employee must re-enter their credentials (and, where configured, a second factor) in the same session before the change form opens.
- Display is always masked. The employee, the owner and payroll all read the same masked label. No endpoint returns a full number, because none exists to return.
- Writes go through one function only. No browser write to the table: create, update and read are backend-only, and the record is returned to the employee masked and to the owner masked.
4.10 Access configuration
| Table | Purpose | Key fields | Relations | | --- | --- | --- | --- | | EmployeeAccessGrant | The owner's per-employee customisation, recorded | employee_id, operational_permissions[], self_service_permissions[], source (role/position/owner), granted_by, granted_at, reason, effective_from, expires_at | n to 1 Employee | | Department, JobPosition | As in Section 4.3 | — | — |
Effective access is computed on the server, never stored as a convenience field the client can read: effective = (role permissions plus position default permissions, minus removed keys) then the owner's overrides, with every write recorded in EmployeeAccessGrant and AuditLog.
4.11 Marketplace — design only, created in Phase 12
Merchant, MerchantApplication, MerchantDocument, Store, StoreCategory, Product, ProductVariant, InventoryLevel, MarketplaceCart, MarketplaceCartItem, MarketplaceOrder, MarketplaceOrderItem, MerchantPayout, MerchantStaff. Every row carries merchant_id; RLS isolates merchants from each other and from DELICES internal data. Driver and DeliveryBatch gain merchant_id only at that point.
5. The Employee Entity — exact identification and extension
The existing table is Employee, schema file base44/entities/Employee.jsonc, entity name Employee, 40 properties, required full_name and personal_email, RLS read/create/update/delete all backend_only. It is never read from the browser.
Used today by: base44/shared/staffIdentity.ts (identity resolution and publicEmployee), base44/functions/employeeApply, employeeAdmin, staffWorkspace, and the pages and components under src/pages/staff and src/components/admin/employees.
Extension plan — additive only. No field renamed, retyped or removed.
| New field | Type | Why | | --- | --- | --- | | staff_class | enum: internal_admin, restaurant_employee | The single switch between operational and employment-only access | | department_id | string | Org placement | | position_id | string | Links to JobPosition | | manager_employee_id | string | Who approves time and leave | | crew_number | string | Human-readable employee number | | preferred_name | string | Shown in the crew workspace | | hire_date | date | Payroll and leave accrual start | | probation_end_date | date | Optional milestone | | pay_type | enum: hourly, salary | Pay structure | | exempt_status | enum: exempt, non_exempt | Overtime eligibility | | overtime_eligible | boolean | Explicit, never inferred | | standard_weekly_hours | number | Salary proration and overtime threshold | | location_id | string | Site the employee works at | | leave_policy_keys | array of string | Policies enrolled at hire | | geofence_required | boolean | Per-employee override | | kiosk_enabled | boolean | Shared-device clock-in | | kiosk_pin_hash | string | Hashed PIN, never returned | | bank_profile_id | string | Active masked payout profile | | bank_changes_count | number | Fraud signal shown to the owner | | access_updated_at | string | Last permission change | | access_updated_by | string | Who changed it | | self_service_locked | boolean | Owner switch: self-service suspended while access is under review | | schedule_notifications | boolean | Shift reminder preference | | emergency_contact_name / emergency_contact_phone | string | Standard employee record | | last_timesheet_approved_at | string | Payroll readiness | | promoted_from_position | string | Quick read of the last promotion | | promoted_at | string | Quick read of the last promotion | | last_promotion_request_id | string | Links to the review record |
Existing fields that stay exactly as they are: application_status, employment_status, account_status, role_key, role_name, permissions, work_email, work_email_status, identity_provider, sso_subject, owner_notes, and every lifecycle timestamp.
Separation of duty, unchanged: application_status, employment_status and account_status never write to each other.
6. Role and Permission Model
6.1 Two classes of staff
| | Internal administrative user | Restaurant employee | | --- | --- | --- | | staff_class | internal_admin | restaurant_employee | | Examples | owner, admin user, general manager, shift manager, chef, finance, customer support | cashier, server, dishwasher, cleaner, prep hand | | Lands on | /crew/admin | /crew/me | | Operational permission keys | Yes, granted per role, and owner-editable | None, ever | | Self-service keys | All, by default | All, by default | | Sees orders, customers, prices, recipes, sales | Only as granted | Never | | Own pay, hours, leave, documents, bank details | Yes | Yes |
6.2 The self-service catalogue (final adjustment 2)
Fourteen keys, all in the self namespace, all granted to every staff member on their first day, all revocable by the owner, all permanently scoped to the resolved identity.
| Key | Grants | | --- | --- | | self.profile | View and update own name, phone, address, emergency contact | | self.photo | Upload and replace own profile picture (private storage) | | self.availability | Maintain own weekly availability and dated exceptions | | self.schedule | View own published shifts and eligible open shifts | | self.clock | Clock in, clock out, start and end own breaks | | self.timesheet | Submit own weekly timesheet; view own approved history | | self.swap | Request a swap, cover or drop of own shift | | self.pay | View own pay rate, pay type and pay history summary | | self.payslip | View and download own payslips | | self.bank | Submit and update own payout details (masked only) | | self.leave | View own balances and policies; submit and cancel own requests | | self.documents | Upload own documents, fulfil own document requests, acknowledge handbook | | self.messages | Read and post in the team channels the employee belongs to | | self.announcements | Read announcements addressed to them and acknowledge where required | | self.notifications | Manage own notification preferences |
6.3 The wall between self-service and operations (final adjustment 3)
Self-service keys are a separate namespace with no path into operational data. The wall is structural, not a convention:
- Self-service endpoints read only self-service tables. The allowed set is explicit: Employee (own record, publicEmployee projection), EmployeeAvailability, Shift (own), ShiftSwapRequest (own), TimeClockEntry (own), TimesheetPeriod (own), TimeOffRequest (own), LeaveBalance (own), PayRate (own), Payslip (own), EmployeeBankProfile (own, masked), EmployeeDocument (own), EmployeeDocumentRequest (own), Conversation and Message (member only), Announcement and AnnouncementRead (audience only), StaffNotification (own).
- Order, OrderItem, MenuItem, AddOn, ServiceSchedule, PaymentRecord, DeliveryBatch, DeliveryStop, Driver, Compensation, PricingRules, reports and every customer table are absent from that set. A self-service call cannot reach them even with a forged id.
- No self-service endpoint accepts an employee id. The identity is resolved from the session; any id in the request body is ignored.
- A self-service key never unlocks an operational endpoint and an operational key never unlocks another person's self-service data. The two checks live in different functions.
- A restaurant_employee record that somehow carries an operational key is refused at the gate and the write is audited as a security event.
- Automated test in every phase: a cashier session attempts to read orders, customers, menu items, recipes and financial reports; all five must fail, and the test is part of the phase exit criteria.
6.4 Final permission matrix
Legend: Full = full access. Granted = only when the owner grants it. Own = own records only, enforced server-side. — = no access at all. Operational grants shown for internal roles are defaults the owner can change; the self-service column is on by default and revocable.
| Area | Owner | Admin user | Manager | Chef | Cashier / Server | Dishwasher / Cleaner | | --- | --- | --- | --- | --- | --- | --- | | SELF-SERVICE | | | | | | | | Own profile and contact details | Full | Own | Own | Own | Own | Own | | Own profile picture | Full | Own | Own | Own | Own | Own | | Own availability | Full | Own | Own | Own | Own | Own | | Own schedule | Full | Own | Own | Own | Own | Own | | Own clock in / out and breaks | Full | Own | Own | Own | Own | Own | | Own timesheet submission | Full | Own | Own | Own | Own | Own | | Own shift swap / cover request | Full | Own | Own | Own | Own | Own | | Own pay rate and pay summary | Full | Own | Own | Own | Own | Own | | Own payslips | Full | Own | Own | Own | Own | Own | | Own bank / payout details (masked) | Full | Own | Own | Own | Own | Own | | Own leave balances and requests | Full | Own | Own | Own | Own | Own | | Own documents and handbook | Full | Own | Own | Own | Own | Own | | Team messages (channels they belong to) | Full | Own | Own | Own | Own | Own | | Own announcements and acknowledgement | Full | Own | Own | Own | Own | Own | | Own notification preferences | Full | Own | Own | Own | Own | Own | | OPERATIONS | | | | | | | | Customer orders | Full | Granted | Granted | Kitchen view only | — | — | | Customer information | Full | Granted | Granted | — | — | — | | Menu and food prices | Full | Granted | Granted | Granted | — | — | | Recipes, ingredients, costs | Full | Granted | Granted | Granted | — | — | | Sales, revenue, financial reports | Full | Granted | Granted | — | — | — | | Business and delivery operations | Full | Granted | Granted | — | — | — | | Schedule building | Full | Granted | Granted | Kitchen only | — | — | | Time clock approval and corrections | Full | Granted | Granted | Kitchen only | — | — | | Leave policy and approvals | Full | Granted | Granted | Kitchen only | — | — | | Employee directory | Full | Granted | Granted | — | — | — | | Employee documents review | Full | Granted | Granted | — | — | — | | Announcements to others | Full | Granted | Granted | Kitchen only | — | — | | Drivers and driver approval | Full | Granted | Granted | — | — | — | | Promotion / pay change | Owner only | — | — | — | — | — | | Payroll runs, others' payslips, others' bank data | Owner only (payroll view delegable, payroll manage owner-only) | Payroll view, delegable | — | — | — | — | | Merchants and marketplace settings | Owner only | Granted | — | — | — | — | | Security, audit, integrations | Full | Audit read only | — | — | — | — | | Departments, positions, roles, permissions | Owner only | — | — | — | — | — | | Account administration: invitations, status changes, delegation | Full — every account on every platform | Granted, only inside a delegation scope; never the owner account, never delegation itself | Granted, narrow scope only | — | — | — | | QR-code issue and revoke | Full | Granted by delegation | — | — | — | — |
Reading a column straight down: cashier, server, dishwasher and cleaner hold fifteen self-service keys and nothing else; chef is an internal user whose operational reach the owner sets, but promotion, payroll runs, bank data and access configuration are never available to them.
6.5 Chef, manager and admin permissions are configurable and independent (final adjustment 4)
- Every operational capability is an independent key. No bundle is hardcoded: orders, customers, menu, prices, recipes, inventory, reports, delivery, drivers, scheduling, time approval, leave approval, announcements and audit are each toggled separately.
- JobPosition carries default_permissions. Editing a position changes the default for future assignments and offers to re-apply to current holders.
- StaffRole is owner-editable. chef, manager, admin and any custom role can be renamed, duplicated or rebuilt, and its permission list changes at any time. Owner access itself is fixed and cannot be reduced or removed.
- EmployeeAccessGrant holds per-employee deviations, with who, when and why. Two managers can therefore hold materially different access.
- Effective access = role plus position defaults, then the owner's overrides. Recomputed on every request, never cached in the client.
- Every change writes EmploymentHistory (permissions_changed), AuditLog and a StaffNotification to the affected person, and takes effect on their next request.
- Self-service keys are configured in the same interface, so the owner can both widen a manager's operational reach and narrow a single employee's self-service in one place.
6.6 One owner-controlled administration interface (final adjustment 8)
A single owner console at /crew/admin (the existing /admin console, extended — not a second console) with one section per subject, all owner-gated:
| Section | What the owner controls there | | --- | --- | | People | Every internal administrative user and every restaurant employee, one list, filterable by class, department, position, status | | Employee record | Profile, photo, department, position, manager, hire date, status, documents, notes | | Access | Role, position defaults, per-employee operational grants and self-service grants, with a before-and-after diff | | Promotion | Promote This Employee: position, responsibilities, permissions, pay, then owner approval | | Positions and departments | Full create, edit, archive, default permissions, pay structure | | Pay and bank | Pay rates, payroll runs, payout profiles (masked), bank-change alerts | | Scheduling and time | Shifts, timesheets, corrections, leave policies and balances | | Organisation settings | Timezone, week start, overtime rules, rounding, geofence, auto clock-out, leave year, payroll provider, document alerts | | Drivers, orders, menu, delivery, reports, security, audit | Exactly the sections that exist today, unchanged |
The owner never needs a second tool, a second login or a database view to manage any of it.
7. Entity Relationship Diagram
User -1:1- Employee -n:1- JobPosition -n:1- Department
| |-1:n- EmployeeAccessGrant
| |-1:n- EmploymentHistory
| |-1:n- PromotionRequest
| |-1:n- PayRate --------> PayrollRun -1:n- Payslip
| |-1:n- EmployeeBankProfile (masked, chained for history)
| |-1:n- EmployeeDocument -1:n- EmployeeDocumentRequest
| |-1:n- EmployeeAvailability
| |-1:n- Shift -1:n- ShiftSwapRequest
| | |-1:n- TimeClockEntry -n:1- TimesheetPeriod
| |-1:n- EmployeeLeaveEnrollment -n:1- LeavePolicy
| | |-1:n- LeaveBalance -1:n- LeaveAdjustment
| |-1:n- TimeOffRequest ---------> LeavePolicy
| |-1:n- StaffNotification
| |-1:n- AnnouncementRead -n:1- Announcement
|-1:1- Driver -1:n- DeliveryBatch -1:n- DeliveryStop -1:1- Order
Conversation -1:n- Message (members: employee ids)
-- deferred to Phase 12, not created now --
Merchant -1:n- Store -1:n- Product -n:n- MarketplaceOrder -1:n- DeliveryBatch
8. Shared Backend and Preservation
8.1 No duplication
| Need | Reuse | New | | --- | --- | --- | | Identity and gating | User, staffIdentity.ts, workspaceGate, publicEmployee | staff_class branch | | Roles and permissions | StaffRole, permission catalogue, PermissionPicker, RoleManager | self namespace, 14 self keys, operational keys, EmployeeAccessGrant | | Employee record | Employee (extended) | — | | Notifications | NotificationLog and DriverNotification patterns | StaffNotification | | File storage | Private storage and signed URLs already used for driver documents | same helper, no second mechanism | | Audit | AuditLog, already written by every admin function | new events in the same log | | Scheduling vs delivery | ServiceSchedule stays food-service hours; Shift is staff hours | separate, never merged | | Pay | Compensation stays driver batch pay | PayRate, PayrollRun, Payslip for employees | | Messaging | SupportTicket stays customer and driver support | internal crew messaging | | Orders and delivery | Order, OrderItem, DeliveryBatch, DeliveryStop | untouched |
Driver pay (Compensation, per batch) and employee pay (PayRate, per hour or salary) stay deliberately apart; merging them would corrupt driver records.
8.2 Preservation register (final adjustment 6)
| Protected surface | Guarantee | | --- | --- | | DELICES public site, 24 pages, all routes and URLs | No route renamed, no page removed, no visual redesign | | Admin console, 26 sections | Extended with new sections; no existing section removed or reworked | | DROP DRIVER, 20 pages | Zero code change in this programme | | Driver onboarding, 10 steps, invitations, QR | Zero behaviour change | | Driver identity, approval, suspension, revocation | Zero behaviour change | | Orders, batches, dispatch, pricing, compensation, withdrawals | Zero schema change, zero logic change | | Support desk, customer and driver | Zero change | | Security: TOTP, sessions, devices, policy, lockout, step-up | Extended, never weakened | | Existing RLS rules | Additive only; no loosening of any existing rule | | Existing 24 permission keys | Kept; new keys are added, none removed | | Existing functions | Extended only where a new field is required; never rewritten |
Enforcement: additive schema only, new functions in new files, a smoke test of every preserved route at the end of each phase in development mode, and no phase merges while any preserved surface regresses.
9. Feature Specifications
9.1 Time clock
- Punch in and out from web, from a shared kiosk with PIN, or from a manager backfill when a punch was missed.
- Location captured at the punch only: latitude, longitude, accuracy, distance from site, and a geofence result of inside, outside or unknown. Outside the fence is accepted and flagged, or refused when the site requires the fence. No background or continuous tracking exists.
- Breaks tracked as segments, paid or unpaid, totalled per entry.
- Overtime from the organisation settings: weekly threshold, daily threshold, multiplier, optional seventh-day rule.
- Automatic clock-out: a maximum shift length closes an open entry, an end-of-day sweep closes forgotten punches, and both are labelled auto_closed with a reason.
- Reminders: shift starting, shift not started, still clocked in past the expected end, missing punch at the end of a scheduled shift.
- Timesheet approval: entries collect into a weekly TimesheetPeriod that the employee submits and a manager approves or returns with a note. Only approved timesheets feed payroll.
- Every correction requires a note and records who changed what.
- Connectivity: a punch requires a connection. There is no offline mode to rely on (Section 15), so the design does not promise an offline queue; a manager can backfill a punch with a reason.
9.2 Scheduling and availability
- Employees set weekly availability and dated exceptions; managers see coverage against it before publishing.
- Shifts are drafted, then published; publishing sends a shift notification with date, time, position and location.
- A published change is recorded and re-notified; nothing is edited silently after publication.
- Swap, cover and drop requests go to the manager for approval; the shift changes only on approval.
- Employees see only their own shifts and the open shifts they are eligible for.
9.3 Promote This Employee (review-first)
- Owner opens the employee and chooses Promote This Employee.
- Selects the new position. The screen shows that position's responsibilities, default permissions and pay structure.
- Access is editable before anything is saved: every proposed operational key and every self-service key can be kept or removed, and additions are listed explicitly beside removals.
- Pay change is optional and effective-dated, hourly or salary according to the position.
- The owner writes a reason, sets an effective date, and saves a draft request. The employee record is still untouched.
- The request appears as pending review with a plain before-and-after comparison.
- On approval, in one transaction: position_id, role_key, permissions, EmployeeAccessGrant, pay_type, PayRate, EmploymentHistory, PromotionRequest status, AuditLog and the employee notification are all written, and the new access applies on the employee's next request.
- Rejecting or cancelling leaves the employee exactly as they were, with the reason kept.
Owner-only. Managers can propose, never approve.
9.4 Leave
- The owner defines policies: paid or unpaid, accrual method, caps, carryover, waiting period, notice period, maximum consecutive days, document requirement, blackout dates, eligibility.
- Each employee is enrolled with a balance per policy per year.
- The employee requests a full day, several days or a partial day, with a reason and an optional private document.
- The manager approves or declines; approval deducts the balance and writes paid-leave minutes into the payroll period, declining releases them.
- Sick leave can skip advance notice and require a document beyond a set number of days.
- Balances, accruals and adjustments are visible to the employee and to whoever holds leave approval.
9.5 Documents
- The employee uploads into private storage; the owner can also upload on their behalf.
- The owner requests a missing document with a due date; the employee sees the open request and fulfils it.
- Each document carries an optional expiry date and alert window; a scheduled job flags expiring documents to the employee and the owner.
- Review states: pending, verified, rejected with a note, expired. Replacing a document keeps the previous version linked.
9.6 Internal communication
- Conversations: one channel all staff can read, department and team channels, and direct threads.
- Announcements: audience by class, department, position or named employees, with severity, optional acknowledgement, optional expiry, and a read and acknowledgement record.
- Operational notifications for shifts, swaps, punches, timesheets, leave, payslips, bank changes, document expiry.
- Attachments live in private storage, limited to conversation members or the announcement audience, delivered as short-lived signed links.
- Restaurant employees only ever see the channels they belong to and announcements addressed to them.
9.7 Payroll
- Effective-dated pay: hourly rate or annual salary, overtime eligibility, exemption status, standard weekly hours.
- Hourly: approved timesheet minutes at the rate in force on that date, plus overtime at the configured multiplier.
- Salary: period gross from the annual figure, prorated for mid-period joins, departures and unpaid leave; overtime only when non-exempt.
- A run is prepared, reviewed, locked, then exported as CSV or PDF for an external provider; payslips are generated as private documents.
- Locked runs are immutable; corrections appear in a later run as an adjustment line.
- The system calculates and documents. It does not file taxes or move money.
9.8 Self-service in practice (final adjustments 1 and 2)
The employee workspace at /crew/me opens on one screen with the same shape for everyone, whatever their other permissions:
| Tile | What the employee can do | What they can never see there | | --- | --- | --- | | My profile | Edit name, phone, address, emergency contact, photo | Any other employee's record | | My schedule | See published shifts, request a swap, view eligible open shifts | The full schedule, other people's shifts, labour cost | | My clock | Punch in, start and end breaks, punch out, submit the week | Others' punches, the approval queue | | My pay | See own rate, pay type and a payslip list | Any other person's rate, payroll totals, business margin | | My bank details | Submit or change payout details; see the masked destination and their own change history | Any full account number, anyone else's details | | My leave | Balances, request, cancel, see decisions | Policy administration, others' balances | | My documents | Upload, fulfil requests, acknowledge handbook | Review queues, others' documents | | Team | Read and post in own channels, read own announcements | Operations channels, customer threads, support tickets |
Every one of these is a backend-only table reached through a function that resolves the session identity, ignores any id in the request, and returns a masked projection.
9.9 Owner administration, one place
Covered in Section 6.6. Practically: one console, one login, every person in one list, and every permission, position, department, promotion and organisation setting reachable in two clicks from that list — with the existing /admin sections kept exactly where they are.
10. Data Protection
| Data | Stored | Who can read it | How | | --- | --- | --- | --- | | Employee record | Employee, backend-only | Owner, employees.view holders, and the employee's own record | Through functions; the client receives publicEmployee, never owner_notes or SSO ids | | Pay rates | PayRate, backend-only | Payroll view holders, and the employee's own rate | Payroll functions only; own rate through self.pay | | Payslips | Payslip, backend-only, private document | Payroll view, and the employee's own slip | Signed URL, expires | | Bank details | EmployeeBankProfile, backend-only | Owner and payroll see the masked label; the employee sees their own masked label | Full number never stored, never returned; token plus last four only; change chain retained | | Time and leave | TimeClockEntry, TimesheetPeriod, LeaveBalance | The employee, their approver, payroll | Self scope enforced server-side | | Employee documents | EmployeeDocument | The employee, the reviewer | Private storage, signed links | | Messages | Message | Conversation members only | Membership checked before a signed link is issued | | Merchant data | Marketplace tables (future) | The owning merchant and merchants.manage holders | merchant_id isolation plus function checks | | Everything else | Existing entities | Unchanged rules | Unchanged |
Standing rules: no sensitive table readable from the browser; no function trusts a client-supplied id; permission re-checked on every call; every privileged write lands in AuditLog; sessions expire under the existing policy; a suspended or revoked account loses access on the next request even with a valid token.
11. Migration and Preservation Plan
- Additive only: new tables, new nullable fields, no renames, no retypes, no deletions.
- Employee is extended while it holds 0 records, so migration cost today is zero.
- staffIdentity.ts keeps its resolution order and gate; staff_class is a branch, not a rewrite. Existing admin permissions behave exactly as now.
- Driver, order, batch and compensation logic untouched, and Driver and DeliveryBatch schemas untouched until Phase 12.
- New functions live in new files and import shared logic; existing functions are extended only where a new field is needed.
- Each phase ships alone, is verified in development mode, and passes the preservation smoke test and the self-service boundary test before the next phase starts.
12. Security Plan
Enforced order on every call: identity, then account status, then staff class, then delegation scope, then permission, then record scope. A non-active account is refused before any of the rest is evaluated. UI hiding is convenience, never control. Self-service endpoints ignore client ids and read from an explicit self table set. Payroll and bank access requires an explicit permission and is fully audited. Bank changes are re-authenticated, alerted and never destructive. Promotion requires owner approval and writes history before it takes effect. A restaurant employee holding an operational key is a security event, not a UI quirk, and is audited as one.
13. Requires External Services
Payments (Stripe or Base44 Payments) — payout provider with tokenisation, required before real bank numbers can be captured (Stripe Connect class) — real payroll processing and tax filing (Gusto or ADP class) — custom email domain for people who are not registered users — SMS for punch reminders, only if wanted — Azure app registration for Microsoft Entra SSO — Apple Developer and Google Play accounts with an APNs key and Firebase files, required for store builds and push.
14. Development Roadmap (final)
| Phase | Scope | Depends on | Complexity | | --- | --- | --- | --- | | 1 | Approval of this revision | — | — | | 2 | Org foundation and access engine: Department, JobPosition, EmployeeAccessGrant, additive Employee fields, staff_class split, self namespace with 14 keys, operational catalogue extended, owner-editable roles and position defaults, organisation settings, plus the Section 18 gate: AccessInvitation, AccountStatusEvent, DelegationGrant and the account-status check ahead of everything else | 1 | High | | 3 | Employee 360, documents and self-service profile: profile, photo, private documents, requests, expiry alerts, activity history, invitation issuing and revocation screens, pending-application review queue, self-service boundary test | 2 | High | | 4 | Promotion workflow: draft, position and responsibilities review, editable permissions with explicit diff, pay change, owner approval, applied transaction, history and audit | 2, 3 | High | | 5 | Crew workspace: /crew/me employee shell (profile, photo, schedule, clock, pay, bank, leave, documents, team) and /crew/admin shell; employment-only roles hold nothing else | 2, 3 | High | | 6 | Scheduling and availability: shifts, availability, publish, change log, notifications, swaps and cover | 5 | High | | 7 | Time clock and timesheets: punch, foreground location and geofence, breaks, overtime, auto clock-out, reminders, submission and approval, manager backfill | 6 | Very high | | 8 | Leave: policy builder, enrolment, balances and accrual, requests, approvals, payroll hand-off | 5, 7 | Medium-high | | 9 | Payroll and payout details: pay rates, runs, payslips, CSV and PDF export, locked periods, masked bank profiles with change chain and alerts | 7, 8 | Very high | | 10 | Internal communication: conversations, announcements with acknowledgement, notification feed, authorised file sharing | 5 | Medium | | 11 | Automation: workflows for shift reminders, missed punches, timesheet cut-off, document expiry, leave accrual, payroll closing, bank-change alerts | 6–10 | Medium | | 12 | Marketplace backbone: merchant schema and isolation, merchant onboarding, and only here the deferred Driver.merchant_id and DeliveryBatch.merchant_id | 1 | Medium | | 13 | Merchant portal and LLOU DROP: storefronts, products, checkout, payouts | 12 | Very high | | 14 | Store mobile apps: app-store builds of the crew experience, push notifications, no background location and no offline mode | 5–11 | Medium |
15. Base44 Mobile Publishing — Actual Capabilities and Limitations (final adjustment 7)
What the platform genuinely does today, and what it does not:
| Capability | Supported today | What it means for the crew app | | --- | --- | --- | | Publishing to App Store and Google Play | Yes. Publish → Mobile app → Build Stores Files produces an iOS build and an Android build; the owner uploads them through their own Apple and Google accounts. Downloading the files needs a paid Builder plan or higher, and Base44 does not submit on the owner's behalf | The crew experience can ship as a store app. Budget the plan level, the two developer accounts, and store review time | | What the store app actually is | A secure web view of the published app, not a custom native application | No custom native modules, no native SDKs of our own. Anything the app cannot do in a browser, it cannot do here either. The web app must be published and working first | | Push notifications | Yes, for store-installed apps. Enabled while generating the store files, with an APNs auth key for iOS and Firebase files for Android | Shift published, shift changed, missed punch, timesheet returned, announcement, payslip ready. Does not reach browser users or home-screen shortcuts, and a new store version is needed before existing installs receive pushes | | Location | Only while the app is open on screen. No background or locked-phone tracking | Clock-in geofencing works because a punch happens with the app open. Continuous tracking, automatic arrival detection and location while driving are not possible. The design therefore captures location only at punch time and never promises tracking | | Offline mode | Not supported. There is no full offline mode | A punch cannot be captured reliably without a connection. Design: online punch required, kiosk as the fallback, manager backfill with a reason for missed punches. Do not promise staff an offline time clock | | Biometrics (Face ID, fingerprint) | Not supported for app unlock or punch authorisation | Sign-in uses the app's configured methods, and the session persists when the app is closed and reopened. Shared devices use the kiosk PIN instead. Biometric punch authorisation is not on the roadmap | | Camera, file upload, private documents | Yes, through the web view with the operating system's own permission prompts | Document upload, profile pictures and delivery-style photo capture all work | | Install without the store | A home-screen shortcut to the published site works | Gives an app-like icon without store review, but no push notifications |
Consequences, stated plainly:
- The crew web workspace is the single source of truth; the store app wraps it. No separate mobile business logic, and every action goes through a backend function so web and app cannot diverge.
- Push is the one genuinely mobile-only benefit, and it requires a store install, credentials and a plan level.
- Geofenced clock-in is a foreground feature by design, not a compromise to be fixed later.
- Offline is out of scope. Missed punches are handled by kiosk and manager backfill.
- The owner console stays web-first; store apps are for employees and managers on the move.
16. Risk Assessment
| Risk | Impact | Mitigation | | --- | --- | --- | | Operational data reaching an employment-only account | Critical | Zero operational keys by role, staff_class checked in every function, explicit self table set, boundary test in each phase | | Payroll or bank data exposure | Critical | Backend-only tables, full numbers never stored, token plus last four, masked everywhere, re-authentication, mandatory change alerts, audit | | Bank-detail fraud (payroll diversion) | Critical | Change creates a new record, old destination stays active until verification, owner and payroll alerted instantly, change count on the record, full chain retained | | Promotion applied without review | High | Draft then approve, before-and-after diff, transactional apply, history row, owner-only approval | | Owner misconfigures an internal role | Medium | Before-and-after diff, per-employee deviations visible, every change audited and notified, owner role itself immutable | | Expecting background tracking or offline punches | High | Section 15 states the platform limits; the design captures location only at punch and requires a connection | | GPS seen as surveillance | High | Location at punch only, employee sees their own data, configurable fence, no continuous tracking | | Overtime miscalculated | High | Configurable thresholds, approval before payroll, locked runs with adjustment lines | | Two shells drifting | High | /crew/admin reuses the existing admin sections; no second console is built | | Duplicated messaging or pay logic | Medium | Section 8.1 reuse table, one shared module per domain | | Regressing a live surface | High | Preservation register, additive-only schema, smoke test per phase | | Payroll and tax law | Legal | Calculate and export only; external provider files | | Menu still has 3 items | Medium | Content task, not code |
17. Decisions Needed Before Phase 2
- Confirm the fourteen self-service keys are granted to every staff member by default and revocable individually.
- Bank details: wait for a payout provider with tokenisation before accepting real account numbers, or launch in preference-only mode (holder, institution, last four) now.
- Geofence: required or optional at launch, and what radius; refuse an outside punch or accept and flag it.
- Overtime: weekly only, or daily and weekly, and the multiplier.
- Leave policies at launch: PTO and sick only, or also personal, unpaid and bereavement.
- Promotion approval: owner only, or owner plus one designated admin.
- Payroll output: CSV and PDF for an external provider, or wait for a provider integration.
- Employee document retention: keep expired documents indefinitely, or auto-archive after a period.
- Mobile: store apps now (paid plan, Apple and Google accounts, APNs and Firebase credentials) or the installable web app first, with push later.
- Confirm owner-only control of departments, positions, roles and permissions, with payroll view delegable but payroll management never delegable.
- Default expiration for an individual invitation, and whether invitations are single-use by default.
- Which platforms may issue a general registration QR code at launch: driver applications only, or crew applications too.
- Whether a delegation grant carries an expiry date by default, and whether it may span several platforms.
- Confirm that removing an internal account archives the person and keeps employment, payroll, financial, delivery and audit records, with no hard deletion available in the console.
18. Account Access, Invitations and Authorization Policy
This section is the policy of record. It governs every internal platform — LLOU Admin, the employee and crew workspace and any future employee app, DROP DRIVER, the future merchant portal and merchant app, and any future operational, management or team application — whatever those products are finally named. Customer accounts are deliberately outside it (Section 18.7).
18.1 Owner authority
The owner holds final authority over every internal account in the ecosystem. Each capability below is enforced on the server, not by hiding a control.
| Owner capability | How it is enforced | | --- | --- | | Invite users, issue individual invitations | AccessInvitation written by an owner-only endpoint; every invitation is attributed to its issuer | | Activate, deactivate, suspend, reinstate, remove accounts | AccountStatusEvent records from status, to status, actor, date and reason; the status field on the record changes in the same transaction | | Assign and change roles and permissions | StaffRole, JobPosition defaults and EmployeeAccessGrant, each change diffed and audited | | Approve or reject registration applications | Application review queue; a general QR code only ever creates a pending application | | Revoke invitations, QR codes, sessions and access immediately | Invitation status becomes revoked; the gate refuses an inactive account on its next request; admin sessions are terminated on the server | | View account activity and access history | One activity view per person, built from AccountStatusEvent, AuditLog and EmploymentHistory |
No one else can grant themselves authority, promote themselves, reverse an owner decision or reduce the owner's control. The owner account is immutable from inside the app: its role cannot be changed or removed by any endpoint.
18.2 Delegated account administration
Delegation is explicit, narrow, recorded and instantly revocable.
| DelegationGrant field | Meaning | | --- | --- | | delegate_user_id, delegate_email | Who holds the delegated authority | | platform | crew_admin, crew_employee, driver, merchant, or a set of them | | account_types | Which account types they may act on: internal_admin, restaurant_employee, driver, merchant | | actions | Which of invite, approve, reject, suspend, reinstate, deactivate, remove, revoke they may perform | | role_keys | The roles they may assign, e.g. a driver administrator may assign driver roles only | | granted_by, granted_at, expires_at, revoked_at, reason | Full provenance, optional expiry, instant revocation |
Hard limits, checked on every delegated action:
- A delegate cannot act outside its platform, account types, actions or role keys. A driver administrator cannot touch a cashier; an employee administrator cannot touch a driver.
- A delegate cannot grant permissions, roles or delegation to themselves, and no delegate can issue another DelegationGrant. Delegation is owner-only.
- A delegate cannot act on the owner account in any way, and cannot reverse, edit or override an owner decision.
- A delegate cannot remove the owner's authority or revoke an owner grant.
- Revoking a delegation takes effect on the delegate's next request, and every action they took remains attributed to the grant that authorised it.
- Every delegated action is audited twice: the actor is the delegate, the authority is the grant.
Supported examples: a driver administrator reviews driver applications and manages driver accounts; an employee administrator runs staff onboarding; a merchant administrator onboards merchants in a later phase. Each is the same structure with a different scope.
18.3 Invitation and QR-code access
All internal registration flows through AccessInvitation. Three mechanisms, one entity:
| Kind | What it does | | --- | --- | | Individual invitation link | One named person, one platform, one intended role or position, expiring link | | Individual QR code | The same invitation rendered as a QR code, for in-person issuing | | General registration QR code | Points at an application or registration process for a platform and a role family. Never activates an account; it creates a pending application only |
| AccessInvitation field | Meaning | | --- | --- | | code, token_hash | Invitation reference and a hashed secret; the raw token is never stored | | kind | individual_link, individual_qr, general_qr | | platform, intended_role_key, intended_position_id | What the invitation grants if approved | | invited_email, invited_name | For individual invitations; empty for a general QR code | | issued_by, issued_by_email, issued_at, expires_at | Provenance and expiry | | single_use, max_uses, used_count | Single-use by default; configurable limits where a link is shared | | status | active, consumed, expired, revoked | | revoked_by, revoked_at, revoke_reason | Immediate revocation | | application_id | Links to the pending application a general QR code produced | | note | Free text for the issuer |
Rules:
- An invitation never creates an active account by itself. It creates, at most, a pending application.
- Individual invitations carry an expiry date, are single-use by default, support configurable use limits and are revocable at any moment.
- A revoked or expired invitation cannot be used or resurrected, and is kept on record so the history of who was invited, and by whom, survives.
- A general QR code can be disabled per platform without touching any individual invitation.
- Where an internal account also needs a platform user, the platform invitation is issued only after approval — never by the QR code itself.
18.4 Account lifecycle
| Status | Meaning | Who may move it | | --- | --- | --- | | invited | An invitation exists, no account yet | Owner or authorised delegate | | pending_approval | An application or registration awaits a decision | Owner or authorised delegate | | active | Full access within role, position and delegation scope | Owner or authorised delegate | | suspended | Temporarily blocked, record intact | Owner or authorised delegate | | deactivated | Blocked, employment usually ended, record intact | Owner or authorised delegate | | removed | Access gone for good, records archived, never erased | Owner or authorised delegate |
On any move to suspended, deactivated or removed:
- Access is revoked on the next request, because the gate reads the live status before anything else. There is no waiting for a token to expire.
- The platform session is ended wherever the app controls the session. Sessions the app manages itself — the admin second factor, admin devices, kiosk sessions — are terminated outright.
- Tokens issued by the platform cannot be destroyed by app code. The app makes them worthless instead: every protected function refuses a non-active account, so a still-valid token reaches nothing. Permanent removal of the person from the app itself is done by the owner on the app's Users page in the dashboard, which is the only place that can delete the platform user.
- The action, the administrator, the date and the reason are recorded in AccountStatusEvent and AuditLog.
- Records survive. Suspending, deactivating or removing never deletes employment, payroll, timesheet, financial, delivery, compensation, document or audit records. The person is archived — archived_at and archived_reason are set, history stays queryable and payroll and audit obligations continue to be met.
- Reactivation is a new recorded event. A reinstated person returns with the permissions they held, and confirms their availability and bank details again before their first shift.
18.5 Platforms covered
| Platform | Namespace | Accounts | Invitation mechanism | Customer-facing | | --- | --- | --- | --- | --- | | LLOU Admin | /crew/admin | internal_admin | Individual only | No | | Employee and crew workspace, and any future employee app | /crew/me | restaurant_employee | Individual, plus a general crew QR code that only creates applications | No | | DROP DRIVER | /driver | driver | Individual, plus the general driver QR code already in service | No | | Merchant portal and merchant app (future) | /merchant | merchant | Individual only | No | | Future operational, management or team applications | to be decided | internal | Individual only | No | | LLOU DELICES website and customer experience | / | customer | Open registration | Yes — excepted, Section 18.7 | | LLOU DROP marketplace, future | /drop | customer | Open registration | Yes — excepted, Section 18.7 |
The policy is defined by account class, not by product name, so renaming or adding an application changes nothing in the rules.
18.6 Tables added by this policy
| Table | Purpose | Key fields | | --- | --- | --- | | AccessInvitation | Every invitation and QR code on every internal platform | as in 18.3 | | AccountStatusEvent | Immutable lifecycle history per account | subject_type, subject_id, from_status, to_status, action, actor_user_id, actor_email, actor_class, delegated_grant_id, reason, at, audit_log_id | | DelegationGrant | Explicit, scoped, revocable delegated authority | as in 18.2 | | Employee, Driver, Merchant | Gain archived_at, archived_reason, status_changed_at, status_changed_by, access_version | Additive only |
The access_version field is the practical revocation handle: it increments on every status change and permission change, and the gate compares it with the value the client last presented, so a stale screen is refused until it refreshes.
18.7 Customer-account exception
Customer accounts are never invitation-gated, and internal authorisation never depends on them.
- Customers register normally on the LLOU DELICES site today, and on the future LLOU DROP marketplace site and customer app.
- The existing customer login, registration, verification, social sign-in and password reset are unchanged.
- A customer account carries no staff class, no position and no operational permission. It cannot be promoted into an internal account, and an internal account cannot be used as a customer account.
- Customer registration never creates an employee, driver or merchant record. Those only start from an invitation or an application.
- Customer and internal identities live in the same platform user table but in different account classes, separated by the gate in 18.8, not by a hidden button.
18.8 Enforcement and audit
Gate order on every protected call — the first failing check ends the request:
- Identity resolved from the session.
- Account status is active; invited, pending, suspended, deactivated, removed and archived all fail.
- Account class and staff class match the endpoint's class.
- Delegation scope, when the action is account management rather than permission-based.
- Permission key held, for permission-based actions.
- Record scope: own records, own department, own batch, own merchant.
- access_version matches, so a revoked or altered grant cannot be used from a stale screen.
Audited events: invitation issued, used, expired or revoked; application submitted, approved or rejected; account activated, suspended, reinstated, deactivated or removed; role, position, permission or delegation granted, changed or revoked; QR code issued, enabled or disabled; sign-in, failed sign-in and second-factor events; every self-service bank change. Each row carries who, what, when, why and the authority used.
Visibility: the owner sees one activity view per person, and one account-access view across every platform — invitations outstanding, applications pending, accounts suspended, delegations active, and anything unusual such as repeated failed sign-ins or a bank change immediately after a profile change.
Nothing has been implemented. Approval of this revision starts Phase 2 only.