Architecture
System overview
A Next.js web app, a background worker and one SQLite database on one server.
The parts
| Web app | Pages, CSV import, reply entry and review controls. Reads the database; queues work but never calls Crustdata or cfo.ai itself. |
|---|---|
| Worker | Claims queued reviews with a lease and runs their steps in order: match companies, check listings, assess, forecast, sync to cfo.ai. |
| Database | SQLite: agency, clients, roles, evidence, cases, decisions, tasks, replies, forecasts and each run's steps. |
| Crustdata | Company enrichment (/company/enrich) and role listing search (/job/search), API version 2025-11-01. |
| Model gateway | An OpenAI-compatible model writes case notes and reads client replies. It never sees fees, probabilities or expected totals. |
| cfo.ai | Holds the Reviewed and Downside scenarios. Written and read back over MCP. Main is never written. |
| neatlogs | Receives a trace of each run's steps and model calls. |
Boundaries
What data goes where
Client domains and role titles go to Crustdata. Case evidence summaries and reply text go to the model gateway. Scenario totals go to cfo.ai. Run steps and model calls go to neatlogs.