# chekshith/ledgerline-core architecture

> Architecture diagram of the GitHub repository chekshith/ledgerline-core, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chekshith/ledgerline-core
- Repository: https://github.com/chekshith/ledgerline-core

## Overview

LedgerLine is a full-stack ledger and account-management platform. Customers authenticate, manage accounts, and initiate deposits, withdrawals, and transfers; administrators and auditors have additional management or read-only capabilities. The browser client calls an Express API, whose routes and services operate with PostgreSQL-backed identity and financial workflows. The README documents database-enforced double-entry integrity, idempotency, and audit logging, but database schema and procedures are not present in the supplied tree. Some UI and service connections are therefore documented rather than source-verified.

Main entry points: [`client/src/App.jsx`](https://github.com/chekshith/ledgerline-core/blob/main/client/src/App.jsx) (SPA router), [`client/src/services/api.js`](https://github.com/chekshith/ledgerline-core/blob/main/client/src/services/api.js) (HTTP API client), [`server/src/app.js`](https://github.com/chekshith/ledgerline-core/blob/main/server/src/app.js) (Express API), [`server/src/utils/sessionContext.js`](https://github.com/chekshith/ledgerline-core/blob/main/server/src/utils/sessionContext.js) (Verified DB session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web client"]
  node_webapp["SPA router<br/>[App.jsx]"]
  node_landing["Product landing<br/>[Landing.jsx]"]
  node_authui["Login and registration<br/>[Login.jsx]"]
  node_authstate["Client auth state<br/>[AuthContext.jsx]"]
  node_apiclient["HTTP API client<br/>[api.js]"]
  node_accountui["Account views<br/>[AccountDetail.jsx]"]
  node_accountlist["Account list<br/>[Accounts.jsx]"]
  node_operationsui["Operations UI<br/>[Operations.jsx]"]
  node_transactionui["Transaction detail"]
  node_adminui["Admin console<br/>[Admin.jsx]"]
end

subgraph group_identity["Identity and access"]
  node_authroutes["Auth routes<br/>[auth.routes.js]"]
  node_authcontroller["Auth controller<br/>[auth.controller.js]"]
  node_authservice["Identity service<br/>[auth.service.js]"]
  node_authguard["JWT and role guard<br/>[auth.js]"]
end

subgraph group_accounts["Account management"]
  node_accountroutes["Account routes<br/>[account.routes.js]"]
  node_accountcontroller["Account controller"]
  node_accountservice["Account service<br/>[account.service.js]"]
end

subgraph group_money["Money movement"]
  node_transactionroutes["Transaction routes"]
  node_transactioncontroller["Transaction controller"]
  node_transactionservice["Transaction service"]
end

subgraph group_runtime["API and persistence"]
  node_session["Verified DB session<br/>[sessionContext.js]"]
  node_dbpool["PostgreSQL connection pool<br/>[db.js]"]
  node_postgres[("PostgreSQL ledger")]
  node_apiapp["Express API<br/>[app.js]"]
end

node_customer(("Customer / auditor"))
node_admin(("Administrator"))

node_customer -->|"uses"| node_webapp
node_admin -->|"uses"| node_webapp
node_webapp -->|"routes to"| node_landing
node_webapp -->|"routes to"| node_authui
node_webapp -->|"provides auth"| node_authstate
node_authstate -->|"calls"| node_apiclient
node_webapp -->|"routes to"| node_accountlist
node_webapp -->|"routes to"| node_accountui
node_webapp -->|"routes to"| node_operationsui
node_webapp -->|"routes to"| node_transactionui
node_webapp -->|"routes to"| node_adminui
node_accountui -->|"calls"| node_apiclient
node_accountlist -->|"calls"| node_apiclient
node_operationsui -->|"calls"| node_apiclient
node_transactionui -->|"calls"| node_apiclient
node_apiclient -->|"HTTP requests"| node_apiapp
node_apiapp -->|"mounts"| node_authroutes
node_apiapp -->|"mounts"| node_accountroutes
node_apiapp -->|"mounts"| node_transactionroutes
node_authroutes -->|"dispatches"| node_authcontroller
node_authroutes -->|"guards"| node_authguard
node_authcontroller -->|"calls"| node_authservice
node_authservice -->|"executes verified work"| node_session
node_authservice -->|"queries"| node_dbpool
node_accountroutes -->|"dispatches"| node_accountcontroller
node_accountroutes -->|"guards"| node_authguard
node_accountcontroller -->|"calls"| node_accountservice
node_accountservice -->|"executes verified work"| node_session
node_transactionroutes -->|"dispatches"| node_transactioncontroller
node_transactionroutes -->|"guards"| node_authguard
node_transactioncontroller -->|"calls"| node_transactionservice
node_transactionservice -->|"executes verified work"| node_session
node_session -->|"checks out"| node_dbpool
node_dbpool -->|"connects"| node_postgres
node_postgres -.->|"stores account state"| node_accountservice
node_postgres -.->|"enforces ledger invariants"| node_transactionservice

click node_webapp "https://github.com/chekshith/ledgerline-core/blob/main/client/src/App.jsx"
click node_landing "https://github.com/chekshith/ledgerline-core/blob/main/client/src/pages/Landing.jsx"
click node_authui "https://github.com/chekshith/ledgerline-core/blob/main/client/src/pages/Login.jsx"
click node_authstate "https://github.com/chekshith/ledgerline-core/blob/main/client/src/context/AuthContext.jsx"
click node_apiclient "https://github.com/chekshith/ledgerline-core/blob/main/client/src/services/api.js"
click node_accountui "https://github.com/chekshith/ledgerline-core/blob/main/client/src/pages/AccountDetail.jsx"
click node_accountlist "https://github.com/chekshith/ledgerline-core/blob/main/client/src/pages/Accounts.jsx"
click node_operationsui "https://github.com/chekshith/ledgerline-core/blob/main/client/src/pages/Operations.jsx"
click node_transactionui "https://github.com/chekshith/ledgerline-core/blob/main/client/src/pages/TransactionDetail.jsx"
click node_adminui "https://github.com/chekshith/ledgerline-core/blob/main/client/src/pages/Admin.jsx"
click node_authroutes "https://github.com/chekshith/ledgerline-core/blob/main/server/src/routes/auth.routes.js"
click node_authcontroller "https://github.com/chekshith/ledgerline-core/blob/main/server/src/controllers/auth.controller.js"
click node_authservice "https://github.com/chekshith/ledgerline-core/blob/main/server/src/services/auth.service.js"
click node_authguard "https://github.com/chekshith/ledgerline-core/blob/main/server/src/middleware/auth.js"
click node_accountroutes "https://github.com/chekshith/ledgerline-core/blob/main/server/src/routes/account.routes.js"
click node_accountcontroller "https://github.com/chekshith/ledgerline-core/blob/main/server/src/controllers/account.controller.js"
click node_accountservice "https://github.com/chekshith/ledgerline-core/blob/main/server/src/services/account.service.js"
click node_transactionroutes "https://github.com/chekshith/ledgerline-core/blob/main/server/src/routes/transaction.routes.js"
click node_transactioncontroller "https://github.com/chekshith/ledgerline-core/blob/main/server/src/controllers/transaction.controller.js"
click node_transactionservice "https://github.com/chekshith/ledgerline-core/blob/main/server/src/services/transaction.service.js"
click node_session "https://github.com/chekshith/ledgerline-core/blob/main/server/src/utils/sessionContext.js"
click node_dbpool "https://github.com/chekshith/ledgerline-core/blob/main/server/src/config/db.js"
click node_apiapp "https://github.com/chekshith/ledgerline-core/blob/main/server/src/app.js"

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_webapp,node_landing,node_authui,node_authstate,node_apiclient,node_accountui,node_accountlist,node_operationsui,node_transactionui,node_adminui toneBlue
class node_authroutes,node_authcontroller,node_authservice,node_authguard toneAmber
class node_accountroutes,node_accountcontroller,node_accountservice toneMint
class node_transactionroutes,node_transactioncontroller,node_transactionservice toneRose
class node_session,node_dbpool,node_postgres,node_apiapp,node_customer,node_admin toneIndigo
```

## Components

### Web client

- [SPA router](https://github.com/chekshith/ledgerline-core/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Product landing](https://github.com/chekshith/ledgerline-core/blob/main/client/src/pages/Landing.jsx): `client/src/pages/Landing.jsx`
- [Login and registration](https://github.com/chekshith/ledgerline-core/blob/main/client/src/pages/Login.jsx): `client/src/pages/Login.jsx`
- [Client auth state](https://github.com/chekshith/ledgerline-core/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [HTTP API client](https://github.com/chekshith/ledgerline-core/blob/main/client/src/services/api.js): `client/src/services/api.js`
- [Account views](https://github.com/chekshith/ledgerline-core/blob/main/client/src/pages/AccountDetail.jsx): `client/src/pages/AccountDetail.jsx`
- [Account list](https://github.com/chekshith/ledgerline-core/blob/main/client/src/pages/Accounts.jsx): `client/src/pages/Accounts.jsx`
- [Operations UI](https://github.com/chekshith/ledgerline-core/blob/main/client/src/pages/Operations.jsx): `client/src/pages/Operations.jsx`
- [Transaction detail](https://github.com/chekshith/ledgerline-core/blob/main/client/src/pages/TransactionDetail.jsx): `client/src/pages/TransactionDetail.jsx`
- [Admin console](https://github.com/chekshith/ledgerline-core/blob/main/client/src/pages/Admin.jsx): `client/src/pages/Admin.jsx`

### Identity and access

- [Auth routes](https://github.com/chekshith/ledgerline-core/blob/main/server/src/routes/auth.routes.js): `server/src/routes/auth.routes.js`
- [Auth controller](https://github.com/chekshith/ledgerline-core/blob/main/server/src/controllers/auth.controller.js): `server/src/controllers/auth.controller.js`
- [Identity service](https://github.com/chekshith/ledgerline-core/blob/main/server/src/services/auth.service.js): `server/src/services/auth.service.js`
- [JWT and role guard](https://github.com/chekshith/ledgerline-core/blob/main/server/src/middleware/auth.js): `server/src/middleware/auth.js`

### Account management

- [Account routes](https://github.com/chekshith/ledgerline-core/blob/main/server/src/routes/account.routes.js): `server/src/routes/account.routes.js`
- [Account controller](https://github.com/chekshith/ledgerline-core/blob/main/server/src/controllers/account.controller.js): `server/src/controllers/account.controller.js`
- [Account service](https://github.com/chekshith/ledgerline-core/blob/main/server/src/services/account.service.js): `server/src/services/account.service.js`

### Money movement

- [Transaction routes](https://github.com/chekshith/ledgerline-core/blob/main/server/src/routes/transaction.routes.js): `server/src/routes/transaction.routes.js`
- [Transaction controller](https://github.com/chekshith/ledgerline-core/blob/main/server/src/controllers/transaction.controller.js): `server/src/controllers/transaction.controller.js`
- [Transaction service](https://github.com/chekshith/ledgerline-core/blob/main/server/src/services/transaction.service.js): `server/src/services/transaction.service.js`

### API and persistence

- [Verified DB session](https://github.com/chekshith/ledgerline-core/blob/main/server/src/utils/sessionContext.js): `server/src/utils/sessionContext.js`
- [PostgreSQL connection pool](https://github.com/chekshith/ledgerline-core/blob/main/server/src/config/db.js): `server/src/config/db.js`
- **PostgreSQL ledger**
- [Express API](https://github.com/chekshith/ledgerline-core/blob/main/server/src/app.js): `server/src/app.js`

### Other components

- **Customer / auditor**
- **Administrator**

## Connections

- Customer / auditor → SPA router: uses (evidence: `README.md`)
- Administrator → SPA router: uses (evidence: `README.md`)
- SPA router → Product landing: routes to (evidence: `client/src/App.jsx`)
- SPA router → Login and registration: routes to (evidence: `client/src/App.jsx`)
- SPA router → Client auth state: provides auth (evidence: `client/src/App.jsx`)
- Client auth state → HTTP API client: calls (evidence: `client/src/context/AuthContext.jsx`)
- SPA router → Account list: routes to (evidence: `client/src/App.jsx`)
- SPA router → Account views: routes to (evidence: `client/src/App.jsx`)
- SPA router → Operations UI: routes to (evidence: `client/src/App.jsx`)
- SPA router → Transaction detail: routes to (evidence: `client/src/App.jsx`)
- SPA router → Admin console: routes to (evidence: `client/src/App.jsx`)
- Account views → HTTP API client: calls (evidence: `client/src/pages/AccountDetail.jsx`)
- Account list → HTTP API client: calls (evidence: `client/src/pages/Accounts.jsx`)
- Operations UI → HTTP API client: calls (evidence: `client/src/pages/Operations.jsx`)
- Transaction detail → HTTP API client: calls (evidence: `client/src/pages/TransactionDetail.jsx`)
- HTTP API client → Express API: HTTP requests (evidence: `client/src/services/api.js`)
- Express API → Auth routes: mounts (evidence: `server/src/app.js`)
- Express API → Account routes: mounts (evidence: `server/src/app.js`)
- Express API → Transaction routes: mounts (evidence: `server/src/app.js`)
- Auth routes → Auth controller: dispatches (evidence: `server/src/routes/auth.routes.js`)
- Auth routes → JWT and role guard: guards (evidence: `server/src/routes/auth.routes.js`)
- Auth controller → Identity service: calls (evidence: `server/src/controllers/auth.controller.js`)
- Identity service → Verified DB session: executes verified work (evidence: `server/src/services/auth.service.js`)
- Identity service → PostgreSQL connection pool: queries (evidence: `server/src/services/auth.service.js`)
- Account routes → Account controller: dispatches (evidence: `server/src/routes/account.routes.js`)
- Account routes → JWT and role guard: guards (evidence: `server/src/routes/account.routes.js`)
- Account controller → Account service: calls (evidence: `server/src/controllers/account.controller.js`)
- Account service → Verified DB session: executes verified work (evidence: `server/src/services/account.service.js`)
- Transaction routes → Transaction controller: dispatches (evidence: `server/src/routes/transaction.routes.js`)
- Transaction routes → JWT and role guard: guards (evidence: `server/src/routes/transaction.routes.js`)
- Transaction controller → Transaction service: calls (evidence: `server/src/controllers/transaction.controller.js`)
- Transaction service → Verified DB session: executes verified work (evidence: `server/src/services/transaction.service.js`)
- Verified DB session → PostgreSQL connection pool: checks out (evidence: `server/src/utils/sessionContext.js`)
- PostgreSQL connection pool → PostgreSQL ledger: connects (evidence: `server/src/config/db.js`)
- PostgreSQL ledger → Account service: stores account state (evidence: `README.md`)
- PostgreSQL ledger → Transaction service: enforces ledger invariants (evidence: `README.md`)
