Documents
The Documents app provides a full-featured document management system. Users can upload files, organize them with categories and custom statuses, share documents via links or direct permissions, and track every operation through an audit trail.
Key Features
Section titled “Key Features”- Upload and storage with file size tracking and storage usage stats
- Categories and statuses for organizing documents with custom labels and color codes
- Version control with numbered document versions
- Sharing via direct user permissions (view, download, edit) or shareable links with optional passwords and expiration
- Archiving and retention policies with configurable retention days and auto-actions (archive or delete)
- Audit trail logging every operation (created, updated, archived, downloaded, shared, etc.)
- Comments on documents for collaboration
Page Structure
Section titled “Page Structure”| Route | Purpose |
|---|---|
/business/apps/documents | Dashboard with stats (total, archived, storage used) and recent documents table |
/business/apps/documents/all | Full document listing with filters |
/business/apps/documents/upload | Upload new documents |
/business/apps/documents/categories | Manage document categories |
/business/apps/documents/statuses | Manage custom document statuses |
/business/apps/documents/[id] | Single document detail view |
/business/apps/documents/[id]/edit | Edit document metadata |
Data Model Overview
Section titled “Data Model Overview”Document
Section titled “Document”The core entity. Each document belongs to a user and has a storage path, file type, file size, and optional category/status references. Supports archiving, expiration, and a flexible metadata JSON field.
DocumentCategory
Section titled “DocumentCategory”Hierarchical categories with a parent_id for nesting and sort_order for display ordering.
DocumentStatus
Section titled “DocumentStatus”Custom statuses with a color_code for visual distinction and an is_default flag.
DocumentVersion
Section titled “DocumentVersion”Tracks uploaded versions with a sequential version_number and independent file_size per version.
DocumentShare
Section titled “DocumentShare”Permission-based sharing (view, download, edit) with optional time-bound access via starts_at / expires_at.
DocumentLink
Section titled “DocumentLink”Shareable links identified by a link_code, with optional password_hash, download toggle, and expiration.
DocumentAuditTrail
Section titled “DocumentAuditTrail”Immutable log of operations (created, updated, archived, restored, downloaded, shared, version_uploaded, comment_added, deleted) with JSON details.
DocumentComment
Section titled “DocumentComment”Simple threaded comments tied to a document and user.
Key Components
Section titled “Key Components”- Stats cards — display total documents, archived count, and formatted storage usage (auto-scales B/KB/MB/GB)
- Quick nav grid — icon-linked cards for All Documents, Upload, Categories, and Statuses
- Recent documents table — shows document name, active/archived badge, and creation date with links to detail pages
Notable Integrations
Section titled “Notable Integrations”- Services:
getDocumentStatsandlistDocumentsfrom$lib/apps/documents/services - Auth: Uses
locals.safeGetSession()for user-scoped data loading - Database: Stored in a separate
ext_documentsschema (not auto-generated types)