System Architecture & Deployment Guide
This document is the Master Reference for understanding how the ColivingLiguria (CL) digital ecosystem is built, structured, and deployed.
1. Project Architecture (The Monorepo)
The project is organized as a Federated Monorepo located at ~/Projects/CL.
Core Directories
CL_Admin/: The command center. Contains monitoring scripts, database schemas, and the criticalscripts/folder for synchronization.Quartz_CL/: The Frontend. A customized Quartz (Static Site Generator) instance that renders the public website.LaTeX_CL/: The Bureaucracy. Contains official legal contracts and detailed house registries (e.g.,RE-IN-001). This is often treated as a submodule or separate entity during deployment to keep the build light.
Data Flow
- Input: User edits Markdown in
Quartz_CL/contentor LaTeX inLaTeX_CL. - Sync:
CL-syncscript orchestrates the update (see below). - Build: Cloudflare Pages builds
Quartz_CLinto a static site. - Output: Live website at
colivingliguria.pages.dev.
2. Site Structure (Quartz_CL)
The frontend is built on Quartz 4, highly customized with React/Preact components.
Layout
content/: All markdown files (.md). This aligns 1:1 with the URL structure.System/: Meta-documentation (like this guide).Diary/: Daily logs.Contracts/: Public versions of LaTeX documents.- Rule: Every folder MUST have an
index.mdfile.- Why? It acts as the “cover page” for that folder in the navigation.
- Naming: Do NOT use
Folder/Folder.md. Always rename it toFolder/index.md. - Exceptions: Internal
System/folders do not strictly require this, but it is good practice. - CRITICAL (TSX Mapping): If you rename
Folder/Folder.mdtoFolder/index.md, the slug changes fromparent/folder/foldertoparent/folder. You MUST updatequartz.layout.tsxto match the new slug, otherwise the custom TSX component will likely disconnect!
quartz/: Source code of the generator.components/: CRITICAL. These are the TSX components used to build pages.pages/: Full page templates (e.g.,Content.tsx).Head.tsx,Footer.tsx: Global layout elements.- Custom Components: Specific features like
FinancialAdvisory.tsxorWoodStove.tsx.
plugins/: Custom transformers and emitters for the build pipeline.
quartz.layout.tsx: Defines which components appear on which page types (Home vs Detail vs Tags).quartz.config.ts: Global configuration (Plugins, Colors, Fonts).
Key Packages
We use standard npm packages managed via package.json. Notable additions:
anime.js: A lightweight JavaScript animation library.- Usage: Used for complex UI animations (e.g., entrance effects, diagram flows) that CSS cannot handle.
- Integration: Imported in TSX components (
import anime from 'animejs') and triggered insideuseEffecthooks.
3. The Deployment Workflow (CL-sync)
We do NOT use standard git push for the main site. We use a custom script: CL-sync.
Why?
- Complexity: We have multiple interlinked repos (DB, LaTeX, Site).
- Safety: We need to back up databases before deployment.
- Performance:
LaTeX_CLis heavy. We exclude it from the Cloudflare build to avoid timeouts.
The CL-sync Pipeline
The script (CL_Admin/scripts/CL-sync) performs these steps in order:
- Database Sync: Runs
CL-sync-dbto backup local D1 databases. - LaTeX Sync: Runs
CL-sync-latexto compile critical documents. - Google Drive: Checks sync status (informational).
- Main Repo Sync: Commits and Pushes changes to the
mainbranch (Development history). - Bridge to Production:
- Checks out a special orphan branch:
deploy-quartz. - Merges
maininto it. - removes the
LaTeX_CLsubmodule/folder (to keep the payload small for Cloudflare). - Pushes
deploy-quartzto GitHub.
- Checks out a special orphan branch:
- Monitoring (New):
- The script polls Cloudflare API (via
wrangler) to check the build status. - It waits until the deployment is
SUCCESSorFAILURE. - If Success: Reports the live URL.
- If Failure: Reports the error and a direct link to the logs.
- The script polls Cloudflare API (via
- Restore: Switches back to
mainand restoresLaTeX_CLso you can continue working.
How to Deploy
Simply run from any terminal:
CL-syncNever manually push to deploy-quartz unless you are debugging the pipeline itself.
4. Troubleshooting
- “Timeout waiting for deployment”: The build took longer than 5 minutes. Check Cloudflare Dashboard.
- “Merge conflict in deploy-quartz”: Usually happens if
LaTeX_CLwas modified oddly. The script tries to auto-resolve by removingLaTeX_CL, but if it fails, delete thedeploy-quartzbranch locally and let the script recreate it:git branch -D deploy-quartz.