Skip to main content

Architecture

Verified against konsolidat 54d072a and konsol 3e220ba8 on 2026-11-05.

Overview​

Konsolidat is two products and a client:

RepositoryRuns asHolds
konsolidat (grynn-in/konsolidat)The Docker stack (docker-compose.yml, deploy.sh)ClickHouse, the dbt project (101 models), Caddy, the backup job, the Airbyte source connectors
konsol (grynn-in/konsol)A Frappe v16 app inside that stack (Python 3.14, Node 24)65 doctypes, the REST API, the period-close app served at /close, the Excel add-in under konsol/public/excel-addin/
konsol-cli (grynn-in/konsol-cli)A Python CLI and MCP serverConfigures konsol over bench execute or the HTTP API

The warehouse holds the numbers. konsol holds every declaration that drives them and every approval. Excel reads and writes through konsol. Nothing reads ClickHouse from outside the stack.

Data flow​

┌────────────────────────────────────────────────────────────────────┐
│ Clients │
│ Excel add-in (K.* functions, task pane) Close app /close │
│ Frappe Desk /desk konsol-cli / MCP │
└──────────────┬──────────────────────────────┬──────────────────────┘
│ HTTPS: session cookie, or X-Konsolidat-Token (add-in)
▼
┌────────────────────────────────────────────────────────────────────┐
│ konsol (Frappe v16) MariaDB: declarations, approvals│
│ doctypes · REST API · close app · Assertion Runs · Build Approvals │
│ write-through ──► epm_staging (reference tables, sync_watermark) │
│ trial-balance upload ──► epm_raw │
│ reads ──► epm_gold over HTTP (requests, one query per batch group) │
└──────────────┬─────────────────────────────────────────────────────┘
▼
┌────────────────────────────────────────────────────────────────────┐
│ ClickHouse 24.8 (loopback ports by default) │
│ epm_raw ← trial-balance submissions, Airbyte landings │
│ epm_staging ← konsol write-through; 30 dbt staging views │
│ epm_bronze ← dbt, 16 tables │
│ epm_silver ← dbt, 10 tables │
│ epm_gold ← dbt, 45 tables (consolidation, close, budget, CF) │
│ dbt runs inside the Frappe image, started by konsol builds │
└────────────────────────────────────────────────────────────────────┘

Six databases are created by clickhouse/init-db.sql; the sixth, epm, is dbt's default profile schema (profiles.yml), where a model without a layer schema would land. Airbyte, when used, lands in epm_raw (_d365_fo__sources.yml), not in epm_bronze.

How a number gets to a cell​

  1. An Entity Accountant uploads a trial balance (Trial Balance Upload → Trial Balance Submission). Rows land in epm_raw; the submission is the canonical intake (konsol#218).
  2. konsol requests a governed build (Build Approval); dbt builds staging → bronze → silver → gold inside the Frappe image. Reference tables are read from epm_staging, where konsol wrote them.
  3. The Close Lead runs Checks (an Assertion Run executes the dbt singular tests), approves rates, journals and deals, and signs off.
  4. =K.EPM(...) in Excel posts an epm_batch request; konsol/api.py resolves the Dataset, checks entity access, and runs one ClickHouse query per group of cells.

Component stack​

ComponentVersionRole
ClickHouseclickhouse/clickhouse-server:24.8-alpineWarehouse; MergeTree tables, incremental consolidation models
dbt Core + dbt-clickhouse1.12.3 / 1.9.3 pinned in CI; installed in the Frappe image venv101 models, 144 singular and 129 schema tests, 16 macro files
Frappev16 (version-16), Python 3.14, Node 24 since 2026-11-04 (konsol#358, konsolidat#272)konsol host: auth, roles, doctypes, workflows, REST, background jobs
MariaDB / Redis10.11 / 7Frappe database; cache and queue
Caddy2TLS when the site has a hostname; plain HTTP for an IP or localhost
Airbytevia abctl, outside ComposeOptional extraction for D365 F&O and ERPNext into epm_raw
close-uiVue + Vite SPA in konsol/close-ui/The close app at /close
Excel add-inOffice.js, manifest 2.0.2.0, namespace KEight functions, the task pane and the ribbon refresh buttons
konsol-cliPython package, konsol and konsol-mcp commandsDimension, measure, fact, connector, config and schema commands

Compose runs eleven services: mariadb, redis_cache, redis_queue, clickhouse, configurator (setup profile), frappe_backend, frappe_worker, frappe_scheduler, dbt_init (setup profile), caddy, backup (backup profile).

Where things live in konsol​

ModuleContents
konsol/epm/Entity, EPM Fiscal Year, Main Account, Dimension, Measure, Dataset, Scenario, Spread Profile, Budget Cycle / Sheet / Line / Annual Input, Reporting Hierarchy, Cash Flow Category, ISO Currency (25 doctypes)
konsol/consolidation/Consolidation Group, Ownership Period, Group Exchange Rate, Historical Equity Rate, Intercompany Account, IC Balance, Consolidation Journal, Business Combination, Business Disposal, Trial Balance Upload / Submission, TB Exception, Assertion Run, Close Settings, Close Event, Statement Commentary (27 doctypes); the Desk reports
konsol/pipeline/EPM Settings, Connector and its health, Pipeline, Pipeline Schedule, Pipeline Run, Build Approval, Build Model, Build Scope (13 doctypes)
konsol/close/21 *_api.py modules (57 whitelisted methods) and their models: period, trial balances, checks, sign-off, journals, rates, statements, approvals, audit trail
konsol/orchestrator/Pipeline runs as a DAG of steps, schedules, single-flight lock, reapers
konsol/api.pyepm_value, epm_batch, budgets, hierarchy trees, add-in auth, report templates
konsol/clickhouse.pyHTTP client (requests), write-through, reconcile_all, the sync watermark

Design decisions, as built​

Each entry names where the decision is recorded. Older ADRs for FastAPI, Streamlit, Dagster and seed-driven allocations are retired; the components are gone (see the roadmap's Removed table).

  • ClickHouse as the warehouse. Financial reporting is SUM ... GROUP BY; MergeTree tables and incremental-by-period consolidation models (konsolidat#116, #154) fit it.
  • Frappe as the application layer. Users, roles, doctypes, workflows and the REST API come with the framework; MariaDB holds declarations and approvals only.
  • The trial balance is the canonical intake (konsol#218, decided 2026-09-16). Airbyte delivers a thin raw file; konsol maps it. The D365 and ERPNext staging trees are being removed (konsolidat#221, Deepak Pai, 2026-09-17; rejected: keeping the tree dormant).
  • Reference data is governed in konsol, not seeded in dbt (konsolidat#146/#147, 85dff3b). Every table dbt reads as a source is written through from a doctype and stamped in sync_watermark.
  • Translation uses governed group rates only (konsol#103; konsolidat#93 decided 2026-09-13). No ERP rate reaches consolidation; a missing rate stops the build.
  • The balance sheet is translated at the closing rate and the year-end close moves no CTA (konsolidat#257, #259, decided 2026-10-06).
  • Cube was removed from the stack (konsol#232, 2026-09-16, ratified by Deepak Pai 2026-11-07; konsolidat#283): a 500-cell sheet answers in 52 ms straight from ClickHouse, so pre-aggregation buys nothing, and nothing in konsol called Cube. The decision record is konsolidat#283.
  • Cost allocation was removed (konsol#264, Deepak Pai, 2026-09-18, option C "remove and redesign from first principles"; konsolidat de468fa). The redesign is konsol#269.
  • Frappe v16 (konsol#358, 2026-11-04): verified on a side-by-side stack before the live upgrade; deploy.sh refuses a .env that still pins version-15.

Security​

See Security Architecture. In short: Frappe session login; the add-in uses a bearer token with an 8-hour life; roles are EPM Admin, EPM Analyst, EPM User, Entity Accountant and the Budget roles; entity scope comes from Frappe User Permissions on Entity; ClickHouse ports bind to loopback unless CLICKHOUSE_BIND says otherwise; Caddy terminates TLS; Entra ID SSO is not built.

Excel functions​

FunctionReads
K.EPM(entity, year, period, account, …)Any Dataset: optional measure, scenario, dimensions, scenarioId, hierarchy, node, layer
K.EPM_BUDGET(entity, year, period, account, …)The budget Dataset, optionally one layer
K.EPM_VARIANCE(entity, year, period, account, …)variance_abs for the declared budget scenario
K.EPM_DEBIT / K.EPM_CREDIT(entity, year, period, account, …)Period debits or credits
K.CF(group, year, period, line)A consolidated cash-flow line
K.EPMSAVE(amount, entity, year, period, account, scenarioId, layer, …)Writes a Budget Line; HTTP 423 when the cycle is locked
K.PING()Confirms the add-in is loaded

Full signatures and errors: Excel Custom Functions.