First deliverable · for review
Architecture & security design
No production database changes will be made until this design is approved.
Application architecture
Browser (React · TypeScript · Tailwind · shadcn/ui) │ user session token ▼ Server functions / Edge Functions ──► AI provider (keys server-side only) │ ▼ Independent Supabase project ├─ Auth (users) ├─ PostgreSQL + Row Level Security (organisation_id on every tenant row) ├─ Storage (bucket paths prefixed by organisation_id, RLS on objects) └─ audit_log (insert-only, written by triggers)
- Multi-tenancy: every record carries
organisation_id; RLS checks membership via a security-defineris_member(org)function. - Roles: stored in a separate
member_rolestable and checked withhas_role(org, role)— never on profiles, never in the browser. - Secrets: AI and third-party keys live only in server environment variables.
- Data provenance: every view shows whether data is none, demonstration or verified operational data.
- Regulatory content: legal entries carry a source citation and stay "unverified" until a qualified reviewer signs off.
- Backend connection: this project is not connected to Lovable Cloud. Connect your own Supabase project in Settings → External Supabase once the design is approved.