# jainulabidalam-lgtm/goledger architecture

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

- Interactive diagram: https://gitdiagram.com/jainulabidalam-lgtm/goledger
- Repository: https://github.com/jainulabidalam-lgtm/goledger

## Overview

GoLedger is a lightweight double-entry bookkeeping web application. An administrator can provision credentials at startup; users then authenticate in the browser, manage accounts, post balanced journal entries, and inspect account ledgers. Journal reversal preserves historical entries, while audit records track key changes. The Go server exposes HTTP endpoints backed by SQLite, with browser views calling those endpoints and an optional exchange-rate service supporting display conversion. The route-registration implementation and ledger-domain source were not excerpted, so some subsystem links remain unverified.

Main entry points: [`internal/http/server.go`](https://github.com/jainulabidalam-lgtm/goledger/blob/main/internal/http/server.go) (HTTP server and routes), [`web/js/app.js`](https://github.com/jainulabidalam-lgtm/goledger/blob/main/web/js/app.js) (Browser interface), [`cmd/goledger/main.go`](https://github.com/jainulabidalam-lgtm/goledger/blob/main/cmd/goledger/main.go) (Application bootstrap), [`internal/database/db.go`](https://github.com/jainulabidalam-lgtm/goledger/blob/main/internal/database/db.go) (SQLite database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Server runtime"]
  node_config["Runtime configuration<br/>[config.go]"]
  node_bootstrap["Application bootstrap<br/>[main.go]"]
  node_httpserver["HTTP server and routes<br/>[server.go]"]
  node_sqlite[("SQLite database<br/>[db.go]")]
end

subgraph group_security["Identity and audit"]
  node_authroutes["Login and access control<br/>[auth_routes.go]"]
  node_auth["Users and sessions<br/>[auth.go]"]
  node_audit["Audit trail<br/>[audit.go]"]
end

subgraph group_accounting["Accounting domain"]
  node_accounts["Account management<br/>[accounts.go]"]
  node_journals["Journal entries<br/>[journals.go]"]
  node_ledger["Posting and reversal rules<br/>[ledger.go]"]
  node_ledgerapi["Account ledger endpoint<br/>[ledger.go]"]
end

subgraph group_experience["Web experience"]
  node_webassets["Embedded web assets<br/>[web.go]"]
  node_browser["Browser interface<br/>[app.js]"]
end

node_operator(("Administrator"))
node_user(("Bookkeeping user"))
node_rates["Exchange-rate service"]

node_operator -->|"provisions admin"| node_bootstrap
node_bootstrap -->|"loads settings"| node_config
node_bootstrap -->|"initializes database"| node_sqlite
node_bootstrap -->|"registers routes"| node_httpserver
node_bootstrap -.->|"serves requests"| node_httpserver
node_httpserver -.->|"serves interface"| node_webassets
node_user -->|"uses interface"| node_browser
node_browser -.->|"calls API"| node_httpserver
node_browser -->|"requests accounts"| node_accounts
node_browser -->|"requests journals"| node_journals
node_browser -->|"requests ledger"| node_ledgerapi
node_browser -->|"fetches rates"| node_rates
node_httpserver -.->|"dispatches auth"| node_authroutes
node_authroutes -->|"authenticates sessions"| node_auth
node_authroutes -->|"validates sessions"| node_sqlite
node_accounts -->|"reads and writes"| node_sqlite
node_accounts -->|"records creation"| node_audit
node_journals -->|"posts or reverses"| node_ledger
node_journals -->|"reads entries"| node_sqlite
node_ledgerapi -->|"queries ledger"| node_sqlite
node_ledger -.->|"records changes"| node_audit
node_httpserver -.->|"routes requests"| node_accounts
node_httpserver -.->|"routes requests"| node_journals
node_httpserver -.->|"routes requests"| node_ledgerapi

click node_config "https://github.com/jainulabidalam-lgtm/goledger/blob/main/internal/config/config.go"
click node_bootstrap "https://github.com/jainulabidalam-lgtm/goledger/blob/main/cmd/goledger/main.go"
click node_httpserver "https://github.com/jainulabidalam-lgtm/goledger/blob/main/internal/http/server.go"
click node_sqlite "https://github.com/jainulabidalam-lgtm/goledger/blob/main/internal/database/db.go"
click node_authroutes "https://github.com/jainulabidalam-lgtm/goledger/blob/main/internal/http/auth_routes.go"
click node_auth "https://github.com/jainulabidalam-lgtm/goledger/blob/main/internal/auth/auth.go"
click node_audit "https://github.com/jainulabidalam-lgtm/goledger/blob/main/internal/audit/audit.go"
click node_accounts "https://github.com/jainulabidalam-lgtm/goledger/blob/main/internal/http/accounts.go"
click node_journals "https://github.com/jainulabidalam-lgtm/goledger/blob/main/internal/http/journals.go"
click node_ledger "https://github.com/jainulabidalam-lgtm/goledger/blob/main/internal/ledger/ledger.go"
click node_ledgerapi "https://github.com/jainulabidalam-lgtm/goledger/blob/main/internal/http/ledger.go"
click node_webassets "https://github.com/jainulabidalam-lgtm/goledger/blob/main/web/web.go"
click node_browser "https://github.com/jainulabidalam-lgtm/goledger/blob/main/web/js/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_config,node_bootstrap,node_httpserver,node_sqlite,node_user toneBlue
class node_authroutes,node_auth,node_audit toneAmber
class node_accounts,node_journals,node_ledger,node_ledgerapi toneMint
class node_webassets,node_browser toneRose
class node_operator,node_rates toneIndigo
```

## Components

### Server runtime

- [Runtime configuration](https://github.com/jainulabidalam-lgtm/goledger/blob/main/internal/config/config.go): `internal/config/config.go`
- [Application bootstrap](https://github.com/jainulabidalam-lgtm/goledger/blob/main/cmd/goledger/main.go): `cmd/goledger/main.go`
- [HTTP server and routes](https://github.com/jainulabidalam-lgtm/goledger/blob/main/internal/http/server.go): `internal/http/server.go`
- [SQLite database](https://github.com/jainulabidalam-lgtm/goledger/blob/main/internal/database/db.go): `internal/database/db.go`

### Identity and audit

- [Login and access control](https://github.com/jainulabidalam-lgtm/goledger/blob/main/internal/http/auth_routes.go): `internal/http/auth_routes.go`
- [Users and sessions](https://github.com/jainulabidalam-lgtm/goledger/blob/main/internal/auth/auth.go): `internal/auth/auth.go`
- [Audit trail](https://github.com/jainulabidalam-lgtm/goledger/blob/main/internal/audit/audit.go): `internal/audit/audit.go`

### Accounting domain

- [Account management](https://github.com/jainulabidalam-lgtm/goledger/blob/main/internal/http/accounts.go): `internal/http/accounts.go`
- [Journal entries](https://github.com/jainulabidalam-lgtm/goledger/blob/main/internal/http/journals.go): `internal/http/journals.go`
- [Posting and reversal rules](https://github.com/jainulabidalam-lgtm/goledger/blob/main/internal/ledger/ledger.go): `internal/ledger/ledger.go`
- [Account ledger endpoint](https://github.com/jainulabidalam-lgtm/goledger/blob/main/internal/http/ledger.go): `internal/http/ledger.go`

### Web experience

- [Embedded web assets](https://github.com/jainulabidalam-lgtm/goledger/blob/main/web/web.go): `web/web.go`
- [Browser interface](https://github.com/jainulabidalam-lgtm/goledger/blob/main/web/js/app.js): `web/js/app.js`

### Other components

- **Administrator**
- **Bookkeeping user**
- **Exchange-rate service**

## Connections

- Administrator → Application bootstrap: provisions admin (evidence: `cmd/goledger/main.go`)
- Application bootstrap → Runtime configuration: loads settings (evidence: `cmd/goledger/main.go`)
- Application bootstrap → SQLite database: initializes database (evidence: `cmd/goledger/main.go`)
- Application bootstrap → HTTP server and routes: registers routes (evidence: `cmd/goledger/main.go`)
- Application bootstrap → HTTP server and routes: serves requests
- HTTP server and routes → Embedded web assets: serves interface
- Bookkeeping user → Browser interface: uses interface (evidence: `README.md`)
- Browser interface → HTTP server and routes: calls API
- Browser interface → Account management: requests accounts (evidence: `web/js/app.js`)
- Browser interface → Journal entries: requests journals (evidence: `web/js/app.js`)
- Browser interface → Account ledger endpoint: requests ledger (evidence: `web/js/app.js`)
- Browser interface → Exchange-rate service: fetches rates (evidence: `web/js/app.js`)
- HTTP server and routes → Login and access control: dispatches auth
- Login and access control → Users and sessions: authenticates sessions (evidence: `internal/http/auth_routes.go`)
- Login and access control → SQLite database: validates sessions (evidence: `internal/http/auth_routes.go`)
- Account management → SQLite database: reads and writes (evidence: `internal/http/accounts.go`)
- Account management → Audit trail: records creation (evidence: `internal/http/accounts.go`)
- Journal entries → Posting and reversal rules: posts or reverses (evidence: `internal/http/journals.go`)
- Journal entries → SQLite database: reads entries (evidence: `internal/http/journals.go`)
- Account ledger endpoint → SQLite database: queries ledger (evidence: `internal/http/ledger.go`)
- Posting and reversal rules → Audit trail: records changes
- HTTP server and routes → Account management: routes requests
- HTTP server and routes → Journal entries: routes requests
- HTTP server and routes → Account ledger endpoint: routes requests
