# ekwo-ai/ekwo-os architecture

> Architecture diagram of the GitHub repository ekwo-ai/ekwo-os, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ekwo-ai/ekwo-os
- Repository: https://github.com/ekwo-ai/ekwo-os

## Overview

Ekwo OS is self-hosted accounting and tax data infrastructure built around a Postgres/Supabase accounting core, with CLI installation and operations, an MCP interface for people and AI agents, country-rule packs, and independent financial-format libraries. The principal workflow is to install and configure a database, load country rules, then use tools to create or read accounting records and prepare reports. The README documents the database capabilities and supported format families; source excerpts show selected CLI, MCP, and format implementations, so unsampled runtime connections are not asserted.

Main entry points: [`packages/cli/src/commands/init.ts`](https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/cli/src/commands/init.ts) (CLI commands), [`packages/cli/src/commands/pack.ts`](https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/cli/src/commands/pack.ts) (Pack operations), [`packages/mcp/src/server.ts`](https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/mcp/src/server.ts) (MCP server), [`packages/core/src/books/backend.ts`](https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/core/src/books/backend.ts) (Accounting schema)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Setup and packs"]
  node_cli["CLI commands<br/>[init.ts]"]
  node_cli_context["Connection context<br/>[context.ts]"]
  node_pack_reader["Pack reader<br/>[read.ts]"]
  node_pack_compiler["Pack compiler<br/>[compile.ts]"]
  node_pack_commands["Pack operations<br/>[pack.ts]"]
  node_country_packs["Country rule packs<br/>[read.ts]"]
end

subgraph group_accounting["Accounting core"]
  node_supabase[("Supabase Postgres")]
  node_accounting_schema[("Accounting schema<br/>[backend.ts]")]
  node_documents["Documents and entries<br/>[documents.ts]"]
  node_imports["Book imports<br/>[imports.ts]"]
  node_client["Accounting client<br/>[client.ts]"]
end

subgraph group_agent["Agent interface"]
  node_mcp_server["MCP server<br/>[server.ts]"]
  node_mcp_backend["Database backend<br/>[backend.ts]"]
  node_read_tools["Read and reports<br/>[read.ts]"]
  node_write_tools["Write operations<br/>[write.ts]"]
  node_module_tools["Module tools<br/>[modules.ts]"]
end

subgraph group_formats["Financial formats"]
  node_format_libraries["Format libraries"]
  node_bank_readers["Bank statement readers<br/>[index.ts]"]
  node_vat_reports["VAT and journal formats<br/>[index.ts]"]
  node_fec["French FEC format<br/>[index.ts]"]
end

node_operator(("Business operator"))
node_agent_user(("AI agent or user"))

node_operator -->|"runs setup"| node_cli
node_cli -->|"opens connection"| node_cli_context
node_cli -->|"installs schema"| node_supabase
node_cli -->|"manages packs"| node_pack_commands
node_pack_commands -->|"reads packs"| node_pack_reader
node_pack_commands -->|"compiles packs"| node_pack_compiler
node_pack_reader -->|"loads rules"| node_country_packs
node_pack_compiler -->|"reads pack data"| node_pack_reader
node_pack_commands -->|"checks loaded packs"| node_supabase
node_supabase -->|"exposes accounting API"| node_accounting_schema
node_accounting_schema -->|"enforces posting"| node_documents
node_documents -->|"writes ledger"| node_accounting_schema
node_client -->|"calls accounting RPCs"| node_supabase
node_agent_user -->|"invokes tools"| node_mcp_server
node_mcp_server -->|"registers reads"| node_read_tools
node_mcp_server -->|"registers writes"| node_write_tools
node_mcp_server -->|"registers modules"| node_module_tools
node_read_tools -->|"queries through"| node_mcp_backend
node_write_tools -->|"writes through"| node_mcp_backend
node_mcp_backend -->|"accesses database"| node_supabase
node_agent_user -->|"uses format packages"| node_format_libraries
node_format_libraries -->|"includes readers"| node_bank_readers
node_format_libraries -->|"includes reporting formats"| node_vat_reports
node_client -->|"generates FEC"| node_fec
node_imports -->|"imports book data"| node_accounting_schema

click node_cli "https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/cli/src/commands/init.ts"
click node_cli_context "https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/cli/src/context.ts"
click node_pack_reader "https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/cli/src/pack/read.ts"
click node_pack_compiler "https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/cli/src/pack/compile.ts"
click node_pack_commands "https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/cli/src/commands/pack.ts"
click node_country_packs "https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/cli/src/pack/read.ts"
click node_accounting_schema "https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/core/src/books/backend.ts"
click node_documents "https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/core/src/books/documents.ts"
click node_imports "https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/core/src/books/imports.ts"
click node_client "https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/core/src/client.ts"
click node_mcp_server "https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/mcp/src/server.ts"
click node_mcp_backend "https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/mcp/src/backend.ts"
click node_read_tools "https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/mcp/src/tools/read.ts"
click node_write_tools "https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/mcp/src/tools/write.ts"
click node_module_tools "https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/mcp/src/tools/modules.ts"
click node_format_libraries "https://github.com/Ekwo-ai/ekwo-os/tree/main/packages/formats"
click node_bank_readers "https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/formats/coda/src/index.ts"
click node_vat_reports "https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/formats/vat-consignment/src/index.ts"
click node_fec "https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/formats/fec/src/index.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_cli_context,node_pack_reader,node_pack_compiler,node_pack_commands,node_country_packs,node_agent_user toneBlue
class node_supabase,node_accounting_schema,node_documents,node_imports,node_client toneAmber
class node_mcp_server,node_mcp_backend,node_read_tools,node_write_tools,node_module_tools toneMint
class node_format_libraries,node_bank_readers,node_vat_reports,node_fec toneRose
class node_operator toneIndigo
```

## Components

### Setup and packs

- [CLI commands](https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/cli/src/commands/init.ts): `packages/cli/src/commands/init.ts`
- [Connection context](https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/cli/src/context.ts): `packages/cli/src/context.ts`
- [Pack reader](https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/cli/src/pack/read.ts): `packages/cli/src/pack/read.ts`
- [Pack compiler](https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/cli/src/pack/compile.ts): `packages/cli/src/pack/compile.ts`
- [Pack operations](https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/cli/src/commands/pack.ts): `packages/cli/src/commands/pack.ts`
- [Country rule packs](https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/cli/src/pack/read.ts): `packages/cli/src/pack/read.ts`

### Accounting core

- **Supabase Postgres**
- [Accounting schema](https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/core/src/books/backend.ts): `packages/core/src/books/backend.ts`
- [Documents and entries](https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/core/src/books/documents.ts): `packages/core/src/books/documents.ts`
- [Book imports](https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/core/src/books/imports.ts): `packages/core/src/books/imports.ts`
- [Accounting client](https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/core/src/client.ts): `packages/core/src/client.ts`

### Agent interface

- [MCP server](https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/mcp/src/server.ts): `packages/mcp/src/server.ts`
- [Database backend](https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/mcp/src/backend.ts): `packages/mcp/src/backend.ts`
- [Read and reports](https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/mcp/src/tools/read.ts): `packages/mcp/src/tools/read.ts`
- [Write operations](https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/mcp/src/tools/write.ts): `packages/mcp/src/tools/write.ts`
- [Module tools](https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/mcp/src/tools/modules.ts): `packages/mcp/src/tools/modules.ts`

### Financial formats

- [Format libraries](https://github.com/Ekwo-ai/ekwo-os/tree/main/packages/formats): `packages/formats`
- [Bank statement readers](https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/formats/coda/src/index.ts): `packages/formats/coda/src/index.ts`
- [VAT and journal formats](https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/formats/vat-consignment/src/index.ts): `packages/formats/vat-consignment/src/index.ts`
- [French FEC format](https://github.com/Ekwo-ai/ekwo-os/blob/main/packages/formats/fec/src/index.ts): `packages/formats/fec/src/index.ts`

### Other components

- **Business operator**
- **AI agent or user**

## Connections

- Business operator → CLI commands: runs setup
- CLI commands → Connection context: opens connection (evidence: `packages/cli/src/context.ts`)
- CLI commands → Supabase Postgres: installs schema
- CLI commands → Pack operations: manages packs (evidence: `packages/cli/src/commands/pack.ts`)
- Pack operations → Pack reader: reads packs (evidence: `packages/cli/src/commands/pack.ts`)
- Pack operations → Pack compiler: compiles packs (evidence: `packages/cli/src/commands/pack.ts`)
- Pack reader → Country rule packs: loads rules (evidence: `packages/cli/src/pack/read.ts`)
- Pack compiler → Pack reader: reads pack data (evidence: `packages/cli/src/pack/compile.ts`)
- Pack operations → Supabase Postgres: checks loaded packs (evidence: `packages/cli/src/commands/pack.ts`)
- Supabase Postgres → Accounting schema: exposes accounting API
- Accounting schema → Documents and entries: enforces posting (evidence: `packages/core/src/books/documents.ts`)
- Documents and entries → Accounting schema: writes ledger (evidence: `packages/core/src/books/documents.ts`)
- Accounting client → Supabase Postgres: calls accounting RPCs (evidence: `packages/core/src/client.ts`)
- AI agent or user → MCP server: invokes tools
- MCP server → Read and reports: registers reads (evidence: `packages/mcp/src/server.ts`)
- MCP server → Write operations: registers writes (evidence: `packages/mcp/src/server.ts`)
- MCP server → Module tools: registers modules (evidence: `packages/mcp/src/server.ts`)
- Read and reports → Database backend: queries through (evidence: `packages/mcp/src/tools/read.ts`)
- Write operations → Database backend: writes through (evidence: `packages/mcp/src/tools/write.ts`)
- Database backend → Supabase Postgres: accesses database (evidence: `packages/mcp/src/backend.ts`)
- AI agent or user → Format libraries: uses format packages
- Format libraries → Bank statement readers: includes readers (evidence: `packages/formats/coda/src/index.ts`)
- Format libraries → VAT and journal formats: includes reporting formats (evidence: `packages/formats/vat-consignment/src/index.ts`)
- Accounting client → French FEC format: generates FEC (evidence: `packages/core/src/client.ts`)
- Book imports → Accounting schema: imports book data (evidence: `packages/core/src/books/imports.ts`)
