Documents System Architecture

The Documents system mirrors the exact LaTeX folder structure into public/System/Assets/Documents/. Static assets (images, planimetrie) remain in /System/Attachments/.

Directory Structure

The CL-sync-documents script dynamically replicates whatever directory tree exists in LaTeX_CL/Contracts/:

LaTeX_CL/Contracts/               →  public/System/Assets/Documents/
├── Allegati/                     →  Documents/Allegati/
│   └── Translation/              →  Documents/Allegati/Translation/
├── Active Contracts/             →  Documents/Active Contracts/
│   ├── Contract for Event Organiser/
│   ├── Contract for Geometra/
│   ├── Contract for Social Media Manager/
│   ├── Contract for Tutor/
│   ├── Contract for Website Designer/
│   └── Master_Contract/
└── Passive Contracts/            →  Documents/Passive Contracts/
    ├── Contract for Developer Access/
    ├── Contract for Residents/
    └── Protocontract for Residents/

Key principle: If you add, rename, or remove folders in LaTeX, CL-sync-documents will automatically replicate the change. No hardcoded paths in the script.

CL-sync Integration

The script runs as step 2.5/7 in the main CL-sync pipeline (after LaTeX sync, before Google Drive check).

How It Works

  1. Mirror directories — Replicates LaTeX_CL/Contracts/ folder tree into Documents/
  2. Sync PDFs — Copies PDFs preserving relative paths. Uses MD5 checksums, only copies changed files.
  3. Remove orphans — Deletes PDFs in Documents that no longer exist in LaTeX (e.g. renamed files)
  4. Write status — Generates .sync-status.json for the dashboard

Component Path Convention

All contract components reference PDFs using mirrored LaTeX paths:

ContractPDF Path
Contract for Residents/System/Assets/Documents/Passive Contracts/Contract for Residents/Contract_for_Residents.pdf
Protocontract for Residents/System/Assets/Documents/Passive Contracts/Protocontract for Residents/Protocontract_for_Residents.pdf
Contract for Event Organiser/System/Assets/Documents/Active Contracts/Contract for Event Organiser/Contract_for_Event_Organiser.pdf

Allegati use:

  • IT: /System/Assets/Documents/Allegati/{filename}.pdf
  • EN: /System/Assets/Documents/Allegati/Translation/EN_{filename}.pdf