# firsttris/haben architecture

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

- Interactive diagram: https://gitdiagram.com/firsttris/haben
- Repository: https://github.com/firsttris/haben

## Overview

Haben is a self-hosted German bookkeeping and tax web application. The principal workflow runs from recording invoices and receipts, through payment matching and bookkeeping, to tax calculations, review, and submission to ELSTER. The graph preserves major documented capabilities—bank imports, payroll, assets, annual accounts, reporting, and migration—alongside the app’s API, persistence, and accounting foundations. Some links are documented in the README; source-level evidence is limited to the sampled excerpts and SOURCE INDEX, so unsampled subsystem connections are not asserted.

Main entry points: [`apps/web/src/routes/_app/index.tsx`](https://github.com/firsttris/haben/blob/main/apps/web/src/routes/_app/index.tsx) (Haben web app), [`apps/web/src/server/functions/ledger.ts`](https://github.com/firsttris/haben/blob/main/apps/web/src/server/functions/ledger.ts) (Bookkeeping ledger), [`apps/web/src/server/modules/belege`](https://github.com/firsttris/haben/tree/main/apps/web/src/server/modules/belege) (Receipts and documents), [`apps/web/src/server/functions/invoices.ts`](https://github.com/firsttris/haben/blob/main/apps/web/src/server/functions/invoices.ts) (Invoices and quotes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_work["Books and business records"]
  node_invoices["Invoices and quotes<br/>[invoices.ts]"]
  node_receipts["Receipts and documents"]
  node_bank["Bank reconciliation<br/>[bank.ts]"]
  node_ledger["Bookkeeping ledger<br/>[ledger.ts]"]
  node_payroll["Payroll<br/>[lohn.ts]"]
  node_assets["Assets and depreciation<br/>[assets.ts]"]
  node_archive["Archive and migration"]
end

subgraph group_tax["Tax and reporting"]
  node_annual["Annual accounts<br/>[annual.ts]"]
  node_vat["VAT returns<br/>[vat.ts]"]
  node_reports["Reports and exports<br/>[reports.ts]"]
end

subgraph group_platform["Application platform"]
  node_app["Haben web app<br/>[index.tsx]"]
  node_database[("PostgreSQL database<br/>[schema.ts]")]
  node_file_store[("Document file store<br/>[storage.ts]")]
  node_api["Application API<br/>[routes.ts]"]
  node_search["Cross-area search<br/>[search-query.ts]"]
  node_portal["Company access portal<br/>[server.ts]"]
end

subgraph group_integrations["External integrations"]
  node_elster["ELSTER submissions<br/>[xml.ts]"]
  node_einvoice["E-invoice rendering<br/>[typst-compiler.ts]"]
  node_bankservices["Bank import services<br/>[client.ts]"]
end

subgraph group_foundation["Accounting foundations"]
  node_accounting["Accounting calculations"]
  node_employee["Employee and payroll calculations<br/>[index.ts]"]
end

node_owner(("Business owner"))

node_owner -->|"records business activity"| node_app
node_app -.->|"creates invoices"| node_invoices
node_app -.->|"records receipts"| node_receipts
node_app -->|"matches payments"| node_bank
node_invoices -->|"posts transactions"| node_ledger
node_receipts -->|"supports bookkeeping"| node_ledger
node_bankservices -->|"imports transactions"| node_bank
node_app -.->|"manages payroll"| node_payroll
node_app -.->|"tracks assets"| node_assets
node_ledger -->|"supplies tax figures"| node_vat
node_vat -->|"submits returns"| node_elster
node_ledger -->|"supports annual accounts"| node_annual
node_ledger -->|"produces reports"| node_reports
node_archive -->|"imports accounting data"| node_ledger
node_invoices -->|"renders e-invoices"| node_einvoice
node_app -.->|"exposes operations"| node_api
node_api -->|"routes document requests"| node_receipts
node_app -->|"searches business records"| node_search
node_search -->|"queries archive"| node_archive
node_receipts -->|"stores files"| node_file_store
node_app -->|"persists records"| node_database
node_payroll -.->|"calculates payroll"| node_employee
node_owner -.->|"selects company access"| node_portal
node_portal -.->|"opens company workspace"| node_app

click node_app "https://github.com/firsttris/haben/blob/main/apps/web/src/routes/_app/index.tsx"
click node_invoices "https://github.com/firsttris/haben/blob/main/apps/web/src/server/functions/invoices.ts"
click node_receipts "https://github.com/firsttris/haben/tree/main/apps/web/src/server/modules/belege"
click node_bank "https://github.com/firsttris/haben/blob/main/apps/web/src/server/functions/bank.ts"
click node_ledger "https://github.com/firsttris/haben/blob/main/apps/web/src/server/functions/ledger.ts"
click node_payroll "https://github.com/firsttris/haben/blob/main/apps/web/src/server/functions/lohn.ts"
click node_assets "https://github.com/firsttris/haben/blob/main/apps/web/src/server/functions/assets.ts"
click node_annual "https://github.com/firsttris/haben/blob/main/apps/web/src/server/functions/annual.ts"
click node_vat "https://github.com/firsttris/haben/blob/main/apps/web/src/server/functions/vat.ts"
click node_elster "https://github.com/firsttris/haben/blob/main/packages/elster/src/xml.ts"
click node_reports "https://github.com/firsttris/haben/blob/main/apps/web/src/server/functions/reports.ts"
click node_archive "https://github.com/firsttris/haben/tree/main/apps/web/src/server/modules/archiv"
click node_einvoice "https://github.com/firsttris/haben/blob/main/packages/einvoice/src/typst-compiler.ts"
click node_bankservices "https://github.com/firsttris/haben/blob/main/packages/import/src/enablebanking/client.ts"
click node_accounting "https://github.com/firsttris/haben/tree/main/packages/core/src"
click node_database "https://github.com/firsttris/haben/blob/main/apps/web/src/server/db/schema.ts"
click node_file_store "https://github.com/firsttris/haben/blob/main/apps/web/src/server/storage.ts"
click node_api "https://github.com/firsttris/haben/blob/main/apps/web/src/server/modules/api/routes.ts"
click node_search "https://github.com/firsttris/haben/blob/main/apps/web/src/server/functions/search-query.ts"
click node_portal "https://github.com/firsttris/haben/blob/main/apps/firmenportal/src/server.ts"
click node_employee "https://github.com/firsttris/haben/blob/main/packages/core/src/lohnabrechnung/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_invoices,node_receipts,node_bank,node_ledger,node_payroll,node_assets,node_archive toneBlue
class node_annual,node_vat,node_reports toneAmber
class node_app,node_database,node_file_store,node_api,node_search,node_portal toneMint
class node_elster,node_einvoice,node_bankservices toneRose
class node_accounting,node_employee,node_owner toneIndigo
```

## Components

### Books and business records

- [Invoices and quotes](https://github.com/firsttris/haben/blob/main/apps/web/src/server/functions/invoices.ts): `apps/web/src/server/functions/invoices.ts`
- [Receipts and documents](https://github.com/firsttris/haben/tree/main/apps/web/src/server/modules/belege): `apps/web/src/server/modules/belege`
- [Bank reconciliation](https://github.com/firsttris/haben/blob/main/apps/web/src/server/functions/bank.ts): `apps/web/src/server/functions/bank.ts`
- [Bookkeeping ledger](https://github.com/firsttris/haben/blob/main/apps/web/src/server/functions/ledger.ts): `apps/web/src/server/functions/ledger.ts`
- [Payroll](https://github.com/firsttris/haben/blob/main/apps/web/src/server/functions/lohn.ts): `apps/web/src/server/functions/lohn.ts`
- [Assets and depreciation](https://github.com/firsttris/haben/blob/main/apps/web/src/server/functions/assets.ts): `apps/web/src/server/functions/assets.ts`
- [Archive and migration](https://github.com/firsttris/haben/tree/main/apps/web/src/server/modules/archiv): `apps/web/src/server/modules/archiv`

### Tax and reporting

- [Annual accounts](https://github.com/firsttris/haben/blob/main/apps/web/src/server/functions/annual.ts): `apps/web/src/server/functions/annual.ts`
- [VAT returns](https://github.com/firsttris/haben/blob/main/apps/web/src/server/functions/vat.ts): `apps/web/src/server/functions/vat.ts`
- [Reports and exports](https://github.com/firsttris/haben/blob/main/apps/web/src/server/functions/reports.ts): `apps/web/src/server/functions/reports.ts`

### Application platform

- [Haben web app](https://github.com/firsttris/haben/blob/main/apps/web/src/routes/_app/index.tsx): `apps/web/src/routes/_app/index.tsx`
- [PostgreSQL database](https://github.com/firsttris/haben/blob/main/apps/web/src/server/db/schema.ts): `apps/web/src/server/db/schema.ts`
- [Document file store](https://github.com/firsttris/haben/blob/main/apps/web/src/server/storage.ts): `apps/web/src/server/storage.ts`
- [Application API](https://github.com/firsttris/haben/blob/main/apps/web/src/server/modules/api/routes.ts): `apps/web/src/server/modules/api/routes.ts`
- [Cross-area search](https://github.com/firsttris/haben/blob/main/apps/web/src/server/functions/search-query.ts): `apps/web/src/server/functions/search-query.ts`
- [Company access portal](https://github.com/firsttris/haben/blob/main/apps/firmenportal/src/server.ts): `apps/firmenportal/src/server.ts`

### External integrations

- [ELSTER submissions](https://github.com/firsttris/haben/blob/main/packages/elster/src/xml.ts): `packages/elster/src/xml.ts`
- [E-invoice rendering](https://github.com/firsttris/haben/blob/main/packages/einvoice/src/typst-compiler.ts): `packages/einvoice/src/typst-compiler.ts`
- [Bank import services](https://github.com/firsttris/haben/blob/main/packages/import/src/enablebanking/client.ts): `packages/import/src/enablebanking/client.ts`

### Accounting foundations

- [Accounting calculations](https://github.com/firsttris/haben/tree/main/packages/core/src): `packages/core/src`
- [Employee and payroll calculations](https://github.com/firsttris/haben/blob/main/packages/core/src/lohnabrechnung/index.ts): `packages/core/src/lohnabrechnung/index.ts`

### Other components

- **Business owner**

## Connections

- Business owner → Haben web app: records business activity
- Haben web app → Invoices and quotes: creates invoices
- Haben web app → Receipts and documents: records receipts
- Haben web app → Bank reconciliation: matches payments
- Invoices and quotes → Bookkeeping ledger: posts transactions
- Receipts and documents → Bookkeeping ledger: supports bookkeeping
- Bank import services → Bank reconciliation: imports transactions
- Haben web app → Payroll: manages payroll
- Haben web app → Assets and depreciation: tracks assets
- Bookkeeping ledger → VAT returns: supplies tax figures
- VAT returns → ELSTER submissions: submits returns
- Bookkeeping ledger → Annual accounts: supports annual accounts
- Bookkeeping ledger → Reports and exports: produces reports
- Archive and migration → Bookkeeping ledger: imports accounting data
- Invoices and quotes → E-invoice rendering: renders e-invoices
- Haben web app → Application API: exposes operations
- Application API → Receipts and documents: routes document requests (evidence: `apps/web/src/server/modules/api/routes.ts`)
- Haben web app → Cross-area search: searches business records (evidence: `apps/web/src/server/functions/search-query.ts`)
- Cross-area search → Archive and migration: queries archive (evidence: `apps/web/src/server/functions/search-query.ts`)
- Receipts and documents → Document file store: stores files (evidence: `apps/web/src/server/storage.ts`)
- Haben web app → PostgreSQL database: persists records
- Payroll → Employee and payroll calculations: calculates payroll
- Business owner → Company access portal: selects company access
- Company access portal → Haben web app: opens company workspace
