# nox-mob/openledgerapp architecture

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

- Interactive diagram: https://gitdiagram.com/nox-mob/openledgerapp
- Repository: https://github.com/nox-mob/openledgerapp

## Overview

Open Ledger is a self-hostable double-entry accounting application for small businesses and nonprofits. Users sign in, set up an organization and accounts, then record transactions directly or import bank statements as reviewable evidence before posting. They can reconcile accounts, view reports, and perform period close; organization membership, permissions, and audit history support these workflows. The supplied excerpts show authentication, organization context, and import processing; several other product capabilities are documented in the README or indexed but their implementation details were not sampled, so their internal links are conservative.

Main entry points: [`src/lib/org.functions.ts`](https://github.com/nox-mob/openledgerapp/blob/main/src/lib/org.functions.ts) (Organization setup), [`src/lib/import.functions.ts`](https://github.com/nox-mob/openledgerapp/blob/main/src/lib/import.functions.ts) (Import batch operations), [`src/integrations/supabase/client.ts`](https://github.com/nox-mob/openledgerapp/blob/main/src/integrations/supabase/client.ts) (Supabase client), [`src/routes/_authenticated/route.tsx`](https://github.com/nox-mob/openledgerapp/blob/main/src/routes/_authenticated/route.tsx) (Authenticated area)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and organization"]
  node_signin["Sign in<br/>[auth.tsx]"]
  node_authenticated["Authenticated area<br/>[route.tsx]"]
  node_legal["Legal acceptance<br/>[LegalGate.tsx]"]
  node_shell["App shell and org context<br/>[AppShell.tsx]"]
  node_orgsetup["Organization setup<br/>[org.functions.ts]"]
end

subgraph group_ledger["Ledger workflows"]
  node_accounts["Accounts and funds<br/>[accounts.tsx]"]
  node_transactions["Transaction entry"]
  node_bankimport["Bank statement import<br/>[import.tsx]"]
  node_importservice["Import batch operations"]
  node_parsers["Statement parsers"]
end

subgraph group_insight["Reconciliation and reports"]
  node_reconcile["Reconciliation"]
  node_reports["Financial reports"]
  node_periodclose["Period close<br/>[close.functions.ts]"]
end

subgraph group_platform["Data and controls"]
  node_audit["Audit trail<br/>[audit.ts]"]
  node_permissions["Permission checks<br/>[permissions.ts]"]
  node_authmiddleware["Server auth middleware<br/>[auth-middleware.ts]"]
  node_client["Supabase client<br/>[client.ts]"]
  node_database[("Postgres and row security")]
  node_supabaseauth["Supabase Auth"]
end

node_user(("Business user"))

node_user -->|"signs in"| node_signin
node_signin -->|"authenticates with"| node_client
node_authenticated -->|"checks user"| node_client
node_authenticated -->|"wraps routes"| node_legal
node_authenticated -.->|"opens workflows"| node_shell
node_legal -.->|"loads legal status"| node_database
node_shell -->|"loads organizations"| node_orgsetup
node_user -.->|"sets up organization"| node_orgsetup
node_orgsetup -->|"requires auth"| node_authmiddleware
node_orgsetup -->|"checks access"| node_permissions
node_orgsetup -->|"records changes"| node_audit
node_orgsetup -.->|"reads and writes"| node_database
node_user -.->|"configures accounts"| node_accounts
node_user -.->|"records entries"| node_transactions
node_user -->|"imports statements"| node_bankimport
node_bankimport -->|"parses and checks"| node_parsers
node_bankimport -->|"submits batches"| node_importservice
node_importservice -->|"requires auth"| node_authmiddleware
node_importservice -->|"checks write access"| node_permissions
node_importservice -->|"records posting"| node_audit
node_importservice -.->|"stores evidence and posts"| node_database
node_user -.->|"reconciles accounts"| node_reconcile
node_user -.->|"reviews reports"| node_reports
node_user -.->|"closes period"| node_periodclose
node_reconcile -.->|"reads and updates"| node_database
node_reports -.->|"queries ledger"| node_database
node_periodclose -.->|"updates close state"| node_database
node_authmiddleware -.->|"validates claims"| node_supabaseauth
node_client -.->|"uses auth"| node_supabaseauth
node_client -.->|"queries via Supabase"| node_database
node_database -.->|"enforces ledger invariant"| node_audit

click node_signin "https://github.com/nox-mob/openledgerapp/blob/main/src/routes/auth.tsx"
click node_authenticated "https://github.com/nox-mob/openledgerapp/blob/main/src/routes/_authenticated/route.tsx"
click node_legal "https://github.com/nox-mob/openledgerapp/blob/main/src/components/LegalGate.tsx"
click node_shell "https://github.com/nox-mob/openledgerapp/blob/main/src/components/AppShell.tsx"
click node_orgsetup "https://github.com/nox-mob/openledgerapp/blob/main/src/lib/org.functions.ts"
click node_accounts "https://github.com/nox-mob/openledgerapp/blob/main/src/routes/_authenticated/accounts.tsx"
click node_transactions "https://github.com/nox-mob/openledgerapp/blob/main/src/lib/transactions.functions.ts"
click node_bankimport "https://github.com/nox-mob/openledgerapp/blob/main/src/routes/_authenticated/import.tsx"
click node_importservice "https://github.com/nox-mob/openledgerapp/blob/main/src/lib/import.functions.ts"
click node_parsers "https://github.com/nox-mob/openledgerapp/tree/main/src/lib/parsers"
click node_reconcile "https://github.com/nox-mob/openledgerapp/blob/main/src/lib/reconcile.functions.ts"
click node_reports "https://github.com/nox-mob/openledgerapp/blob/main/src/lib/reports.functions.ts"
click node_periodclose "https://github.com/nox-mob/openledgerapp/blob/main/src/lib/close.functions.ts"
click node_audit "https://github.com/nox-mob/openledgerapp/blob/main/src/lib/audit.ts"
click node_permissions "https://github.com/nox-mob/openledgerapp/blob/main/src/lib/permissions.ts"
click node_authmiddleware "https://github.com/nox-mob/openledgerapp/blob/main/src/integrations/supabase/auth-middleware.ts"
click node_client "https://github.com/nox-mob/openledgerapp/blob/main/src/integrations/supabase/client.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_signin,node_authenticated,node_legal,node_shell,node_orgsetup,node_user toneBlue
class node_accounts,node_transactions,node_bankimport,node_importservice,node_parsers toneAmber
class node_reconcile,node_reports,node_periodclose toneMint
class node_audit,node_permissions,node_authmiddleware,node_client,node_database,node_supabaseauth toneRose
```

## Components

### Access and organization

- [Sign in](https://github.com/nox-mob/openledgerapp/blob/main/src/routes/auth.tsx): `src/routes/auth.tsx`
- [Authenticated area](https://github.com/nox-mob/openledgerapp/blob/main/src/routes/_authenticated/route.tsx): `src/routes/_authenticated/route.tsx`
- [Legal acceptance](https://github.com/nox-mob/openledgerapp/blob/main/src/components/LegalGate.tsx): `src/components/LegalGate.tsx`
- [App shell and org context](https://github.com/nox-mob/openledgerapp/blob/main/src/components/AppShell.tsx): `src/components/AppShell.tsx`
- [Organization setup](https://github.com/nox-mob/openledgerapp/blob/main/src/lib/org.functions.ts): `src/lib/org.functions.ts`

### Ledger workflows

- [Accounts and funds](https://github.com/nox-mob/openledgerapp/blob/main/src/routes/_authenticated/accounts.tsx): `src/routes/_authenticated/accounts.tsx`
- [Transaction entry](https://github.com/nox-mob/openledgerapp/blob/main/src/lib/transactions.functions.ts): `src/lib/transactions.functions.ts`
- [Bank statement import](https://github.com/nox-mob/openledgerapp/blob/main/src/routes/_authenticated/import.tsx): `src/routes/_authenticated/import.tsx`
- [Import batch operations](https://github.com/nox-mob/openledgerapp/blob/main/src/lib/import.functions.ts): `src/lib/import.functions.ts`
- [Statement parsers](https://github.com/nox-mob/openledgerapp/tree/main/src/lib/parsers): `src/lib/parsers`

### Reconciliation and reports

- [Reconciliation](https://github.com/nox-mob/openledgerapp/blob/main/src/lib/reconcile.functions.ts): `src/lib/reconcile.functions.ts`
- [Financial reports](https://github.com/nox-mob/openledgerapp/blob/main/src/lib/reports.functions.ts): `src/lib/reports.functions.ts`
- [Period close](https://github.com/nox-mob/openledgerapp/blob/main/src/lib/close.functions.ts): `src/lib/close.functions.ts`

### Data and controls

- [Audit trail](https://github.com/nox-mob/openledgerapp/blob/main/src/lib/audit.ts): `src/lib/audit.ts`
- [Permission checks](https://github.com/nox-mob/openledgerapp/blob/main/src/lib/permissions.ts): `src/lib/permissions.ts`
- [Server auth middleware](https://github.com/nox-mob/openledgerapp/blob/main/src/integrations/supabase/auth-middleware.ts): `src/integrations/supabase/auth-middleware.ts`
- [Supabase client](https://github.com/nox-mob/openledgerapp/blob/main/src/integrations/supabase/client.ts): `src/integrations/supabase/client.ts`
- **Postgres and row security**
- **Supabase Auth**

### Other components

- **Business user**

## Connections

- Business user → Sign in: signs in (evidence: `src/routes/auth.tsx`)
- Sign in → Supabase client: authenticates with (evidence: `src/routes/auth.tsx`)
- Authenticated area → Supabase client: checks user (evidence: `src/routes/_authenticated/route.tsx`)
- Authenticated area → Legal acceptance: wraps routes (evidence: `src/routes/_authenticated/route.tsx`)
- Authenticated area → App shell and org context: opens workflows
- Legal acceptance → Postgres and row security: loads legal status
- App shell and org context → Organization setup: loads organizations (evidence: `src/components/AppShell.tsx`)
- Business user → Organization setup: sets up organization
- Organization setup → Server auth middleware: requires auth (evidence: `src/lib/org.functions.ts`)
- Organization setup → Permission checks: checks access (evidence: `src/lib/org.functions.ts`)
- Organization setup → Audit trail: records changes (evidence: `src/lib/org.functions.ts`)
- Organization setup → Postgres and row security: reads and writes
- Business user → Accounts and funds: configures accounts
- Business user → Transaction entry: records entries
- Business user → Bank statement import: imports statements (evidence: `src/routes/_authenticated/import.tsx`)
- Bank statement import → Statement parsers: parses and checks (evidence: `src/routes/_authenticated/import.tsx`)
- Bank statement import → Import batch operations: submits batches (evidence: `src/routes/_authenticated/import.tsx`)
- Import batch operations → Server auth middleware: requires auth (evidence: `src/lib/import.functions.ts`)
- Import batch operations → Permission checks: checks write access (evidence: `src/lib/import.functions.ts`)
- Import batch operations → Audit trail: records posting (evidence: `src/lib/import.functions.ts`)
- Import batch operations → Postgres and row security: stores evidence and posts
- Business user → Reconciliation: reconciles accounts
- Business user → Financial reports: reviews reports
- Business user → Period close: closes period
- Reconciliation → Postgres and row security: reads and updates
- Financial reports → Postgres and row security: queries ledger
- Period close → Postgres and row security: updates close state
- Server auth middleware → Supabase Auth: validates claims
- Supabase client → Supabase Auth: uses auth
- Supabase client → Postgres and row security: queries via Supabase
- Postgres and row security → Audit trail: enforces ledger invariant
