Skip to content

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.

  • 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
RoutePurpose
/business/apps/documentsDashboard with stats (total, archived, storage used) and recent documents table
/business/apps/documents/allFull document listing with filters
/business/apps/documents/uploadUpload new documents
/business/apps/documents/categoriesManage document categories
/business/apps/documents/statusesManage custom document statuses
/business/apps/documents/[id]Single document detail view
/business/apps/documents/[id]/editEdit document metadata

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.

Hierarchical categories with a parent_id for nesting and sort_order for display ordering.

Custom statuses with a color_code for visual distinction and an is_default flag.

Tracks uploaded versions with a sequential version_number and independent file_size per version.

Permission-based sharing (view, download, edit) with optional time-bound access via starts_at / expires_at.

Shareable links identified by a link_code, with optional password_hash, download toggle, and expiration.

Immutable log of operations (created, updated, archived, restored, downloaded, shared, version_uploaded, comment_added, deleted) with JSON details.

Simple threaded comments tied to a document and user.

  • 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
  • Services: getDocumentStats and listDocuments from $lib/apps/documents/services
  • Auth: Uses locals.safeGetSession() for user-scoped data loading
  • Database: Stored in a separate ext_documents schema (not auto-generated types)