The workflow engine
The state machine (the obvious, expressive part)
Two audit systems
The PoC keeps two overlapping audit trails plus a third auth-specific log:
Tenancy model
Multi-tenancy pivots entirely on company_memberships (userid, companyid,
The email queue (Lovable-coupled)
Email is a PGMQ-based queue dispatched by a cron worker, entirely coupled to Lovable's
External portal flow (the arguido's view)
The accused employee (or external counsel) accesses the case through an unauthenticated,
Storage buckets
Four Supabase Storage buckets:
Document & dossier generation
Per-phase legal documents
Two deliverable subsystems
Investigative actions (diligências, inquiry_actions) have two parallel editor