Compliance & Document Control
Centralised document management, multi-step approval workflows, expiry tracking, and a tamper-evident audit trail — all in one compliance mode.
Quick Start
Switch to Compliance Mode from the app-mode switcher in the header. You will see four screens in the sidebar:
- Open Document Library and click Add Document to upload your first policy or procedure.
- Use the ⋯ menu on any document and choose Submit for Approval to start an approval request.
- Switch to Approval Workflow → Pending Approvals to approve or reject as a reviewer.
- Check Expiry Reminders to see which documents need renewal in the next 30 days.
- Use Audit Trail to search and export a complete action history.
All data persists on the server
Every document, approval request, and audit log entry is stored in JSON files on the server under data/ — surviving page refreshes and deployments. All endpoints follow the standard TotalApp /api/data/{resource} GET/POST pattern.
The Four Screens
Document Library
Centralised repository for policies, procedures, work instructions, forms, contracts, and certificates. Full version history, status lifecycle, tag search, and an embedded document viewer.
Approval Workflow
Multi-step approval chains per document category. Authors submit; role-based or user-specific approvers review, approve, or reject — with mandatory comments on rejections.
Expiry Reminders
Colour-coded dashboard showing all documents by days remaining. Configurable reminder schedule (30, 15, 7, 1 day) with owner or custom email recipients. One-click renew.
Audit Trail
Tamper-evident, searchable log of every action. Filter by date range, user, action type, and module. CSV/JSON export. Entry detail panel with before/after diff for update actions.
Document Status Lifecycle
A document can also become Expired (when the review date passes with no renewal) or Archived (manually removed from active use). Expired documents are read-only for standard users — only admins and document owners can view or renew them.
| Status | Badge colour | Who can view | Next action |
|---|---|---|---|
| Draft | Slate | Owner + admins | Submit for approval |
| In Review | Amber | Owner + reviewers + admins | Approve or reject |
| Approved | Sky blue | Owner + admins | Publish |
| Published | Emerald | All users | Submit new version when update needed |
| Expired | Red | Owner + admins only | Renew (creates new version) |
| Archived | Slate (dim) | Admins only | Restore or leave archived |
Document Categories
| Category | Typical use | Example |
|---|---|---|
| Policy | Organisational mandates and principles | Quality Management Manual, Data Privacy Policy |
| Procedure | Step-by-step processes for teams | IT Security Incident Response, Onboarding Process |
| Work Instruction | Operator-level how-to guides | Machine Calibration Steps, Packing Line Instructions |
| Form | Fillable templates for routine tasks | Employee Onboarding Checklist, Non-Conformance Report |
| Contract | Legal agreements with counterparties | Vendor Contract Template, NDA Template |
| Certificate | Periodic compliance certificates | Workplace Health & Safety Certificate, ISO 9001 Certificate |
Document Actions
Each document row has a ⋯ context menu with the following actions. Some also appear as toolbar buttons in the document viewer.
| Action | Where | What it does |
|---|---|---|
| View | Row button + viewer | Opens the document viewer modal showing the latest version's metadata, version history list, tags, and a Download button. Every open fires a view audit entry. |
| Edit | ⋯ menu | Opens the Edit modal — update name, description, category, owner, review frequency, next review date, and tags. Saving updates the document and appends an update audit entry. |
| Upload New Version | ⋯ menu | Opens the Upload Version modal. Drag-and-drop or click to select a file (up to 20 MB). Optionally add a changelog note. Uploads to POST /api/compliance/upload (multipart), stores the returned URL, increments the version counter, and resets status to Draft. |
| Submit for Approval | ⋯ menu | Opens the Submit for Approval modal. Shows a dropdown of available approval workflows (filtered to those matching the document's category). Add an optional note and click Submit — creates an approval request and sets document status to In Review. |
| Download | Viewer footer | Fetches the file with your session credentials attached (the file endpoint is access-controlled). Creates a temporary object URL, triggers a browser download, then revokes the URL. Every download fires a download audit entry. |
| Archive | ⋯ menu | Soft-deletes the document (status → Archived). Admins can still view it. Fires a delete audit entry. |
Submit for Approval requires a matching workflow
If no approval workflow exists for the document's category, the Submit for Approval option shows a message directing you to the Approval Workflow screen. Create a workflow for the category first, then return to submit.
File Upload & Serving
Compliance files are stored server-side under server/data/tenants/{tenantId}/compliance-files/ and served through a JWT-gated endpoint — they are never publicly accessible via a direct URL.
| Endpoint | Method | Description |
|---|---|---|
/api/compliance/upload | POST (multipart) | Accepts a single file field named file. Maximum 20 MB. Returns { url: "/api/compliance/files/{tenantId}/{filename}" }. Requires a valid app JWT. |
/api/compliance/files/:tenantId/:filename | GET | Streams the stored file. Requires a valid app JWT — the browser cannot access this URL without authentication. Files are always downloaded with your session credentials attached, via a temporary object URL. |
Why not a signed URL?
Because all storage is local to the server (not S3 or similar), signed URLs are not applicable. Every file request goes through the /api/compliance/files/ handler which validates the JWT and resolves the tenant path — this prevents one tenant from accessing another tenant's files even if the filename is guessed.
Data Storage
All data is persisted on the server as tenant-scoped JSON files under server/data/tenants/{tenantId}/. Seven endpoints serve the four compliance screens:
| File | API Endpoint | Contents |
|---|---|---|
compliance-documents.json | /api/data/compliance-documents | All documents with embedded version arrays. |
compliance-approvals.json | /api/data/compliance-approvals | Workflow definitions + approval requests. |
compliance-acknowledgments.json | /api/data/compliance-acknowledgments | Per-user document acknowledgment records. |
compliance-reminders.json | /api/data/compliance-reminders | Reminder settings (days, recipients, enabled). |
compliance-audit.json | /api/data/compliance-audit | Append-only audit log (max 5,000 entries per tenant). |
| — | POST /api/compliance/upload | Multipart file upload — stores file, returns serving URL. |
| — | GET /api/compliance/files/:tenantId/:filename | JWT-gated file serving for downloaded compliance documents. |
Firebase migration path
The storage layer is designed to migrate cleanly to Firebase or any other backend without affecting how the screens work. File upload/serving would migrate to cloud storage (e.g. S3) with no change to how documents are uploaded or downloaded.