H1Molino — Architecture (Canonical Rules)
H2Core Identity
Document + Entity Graph system
Truth → Document → Folio → UI → Intent → Actions → DB → Rebuild
H2Structure (strict)
app/(entity)/<entity>/ page.tsx → read-only server orchestrator actions/ → ONLY mutation authority components/ → dumb UI (client) context/ → ephemeral UI state types/ → domain truth api/route.ts → external boundary only
H2Rules (non-negotiable)
- No Prisma outside actions
- No mutation in pages
- API routes are external only
- One entity = one folder
- UI never owns truth
- All writes go through server actions
H2Persistence Pattern
Client intent → emitIntent / setForm → compute helpers (pure) → queueSave / action → Prisma → revalidate → server re-render
H2Document Engine
H3Layers
- rawBlocks (input)
- FlowUnits (normalized)
- pagination (layout)
- wagons (render)
H3Guarantees
- deterministic IDs
- pure transforms
- pagination = layout only
H2Trip Module Position
Trip = specialized document
- stops = FlowUnits equivalent
- normalizeStops = compute layer
- TripEngine = projection layer
H2Integration Strategy
H3External systems
- FareHarbor → inventory only
- Apps Script → output layer (docs, pdf, email, calendar)
H3Principle
Internal = fast path External = adapters only
H2Output Layer (critical)
Trip →
- Google Doc
- Calendar event
via Apps Script bridge
H2Evolution Path
- Stabilize entity patterns
- Inline editing (no side tools)
- Output automation (Apps Script)
- External integrations (FH API)
H2Guiding Principle
"One source of truth, many projections"