Architecture Overview
This section is the visual reference for how CONA is built. Diagrams are organised as C4 levels: each level zooms in one step, so you can stop at the depth you need.Every diagram in this section is derived from the code, not from intent. Edges are verified
against actual imports and call sites. If a diagram disagrees with the code, the diagram is the
bug — see Conventions.
How to read this section
L1 — Context
System Context
The single high-level picture: users, applications, infrastructure, and external providers.
Data Flows & Trust Boundaries
Where customer and financial data travels, which boundaries it crosses, and which subprocessors
touch it.
L2 — Containers
Deployment Topology
Vercel, Fly.io, Temporal Cloud, Supabase, and Redis — what runs where.
Package Graph
The monorepo’s applications and packages, their real dependency edges, and the layering rules.
L3 — Applications
Webapp
Route groups, server actions, library layers, and API ingress.
Portal
The customer-facing document portal.
Console
The superadmin console.
Temporal Workers
Worker bootstrap, task queues, and activity registration.
L3 — Business domains
Core Domain Map
The domains inside
@cona/core, grouped into bounded contexts.Accounting Engine
Posting matrix, rules engine, general ledger, job queue, and periods.
Document Lifecycle
From creation through formats and delivery to the customer portal.
Reconciliation & Payments
Payment matching, bank handoffs, and the reconciliation agent.
Data Model
The Prisma schema as domain clusters rather than one diagram.
L3 — Cross-cutting concerns
Integrations & Adapters
The adapter registry and every external provider CONA syncs from.
Ingress: OAuth & Webhooks
How external systems get in — callbacks, webhooks, and the public API.
Temporal Orchestration
Workflow to activity to core call chains, retries, and schedules.
Auth, Tenancy & Actors
Auth0, organisation isolation, and mutation attribution.
Observability
Axiom pipelines, OpenTelemetry, Sentry, and sampling.
Redis Caching
Cache key model, version prefixing, counters, and locks.
Copilot Agents
Mastra, the CopilotKit runtime, and agent tooling.
Related reading
CODEBASE_MAP.mdat the repository root — text-first navigation of the same territory- Temporal Workflow Architecture — deeper narrative on the ingestion and accounting phases
- Core Principles — the rules these diagrams should reflect