# flango2023/echtzeit architecture

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

- Interactive diagram: https://gitdiagram.com/flango2023/echtzeit
- Repository: https://github.com/flango2023/echtzeit

## Overview

Echtzeit is a fictional SEPA Instant payment and scam-liability simulator. Its main workflow accepts bank requests through an authenticated API, checks payee identity and payment risk, processes ISO 20022 transfers into a double-entry ledger, and supports tracing and freezing funds after a scam. A separate seeded simulation compares policies and calculates loss allocation. Relationships are based on the README and the supplied source excerpts and SOURCE INDEX; unsampled subsystem links are omitted where their callers are not established.

Main entry points: [`src/echtzeit/api/app.py`](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/api/app.py) (HTTP endpoints), [`src/echtzeit/simulation.py`](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/simulation.py) (Seeded scenarios), [`src/echtzeit/payments.py`](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/payments.py) (Payment processor), [`src/echtzeit/ledger.py`](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/ledger.py) (Double-entry ledger)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Bank API"]
  node_api_app["HTTP endpoints<br/>[app.py]"]
  node_api_auth["API keys and roles<br/>[auth.py]"]
  node_api_limits["Request limits<br/>[ratelimit.py]"]
  node_api_serve["Safe launcher<br/>[serve.py]"]
end

subgraph group_payments["Payment Processing"]
  node_payments["Payment processor<br/>[payments.py]"]
  node_pacs008["Credit transfer XML<br/>[pacs008.py]"]
  node_pacs002["Status report XML<br/>[pacs002.py]"]
  node_xml["XML utilities<br/>[_xml.py]"]
  node_identifiers["Payment identifiers<br/>[identifiers.py]"]
  node_vop["Payee verification<br/>[vop.py]"]
  node_risk["Risk assessment<br/>[risk.py]"]
end

subgraph group_funds["Ledger and Recovery"]
  node_ledger["Double-entry ledger<br/>[ledger.py]"]
  node_models["Persistent records<br/>[models.py]"]
  node_db["Database setup<br/>[db.py]"]
  node_audit["Rejection and request logs<br/>[audit.py]"]
  node_holds["Funds holds<br/>[holds.py]"]
  node_tracing["Payment tracing<br/>[tracing.py]"]
  node_retention["Data retention<br/>[retention.py]"]
end

subgraph group_simulation["Scenario Analysis"]
  node_scenario["Seeded scenarios<br/>[simulation.py]"]
  node_liability["Loss allocation<br/>[liability.py]"]
  node_calibration["Reference calibration<br/>[calibration.py]"]
  node_report["Scenario reporting<br/>[scenario_report.py]"]
end

node_bank(("Bank client"))

node_bank -->|"calls"| node_api_app
node_api_app -->|"authenticates"| node_api_auth
node_api_app -->|"limits requests"| node_api_limits
node_api_serve -->|"starts"| node_api_app
node_api_app -->|"serves checks"| node_vop
node_api_app -->|"serves assessments"| node_risk
node_api_app -->|"routes payments"| node_payments
node_api_app -->|"serves account operations"| node_ledger
node_api_app -->|"serves trace requests"| node_tracing
node_api_app -->|"reads audit logs"| node_audit
node_api_app -->|"serves hold operations"| node_holds
node_payments -->|"parses messages"| node_pacs008
node_payments -->|"builds replies"| node_pacs002
node_payments -->|"books transfers"| node_ledger
node_payments -->|"records rejections"| node_audit
node_pacs008 -->|"uses XML helpers"| node_xml
node_pacs008 -->|"validates identifiers"| node_identifiers
node_pacs002 -->|"uses XML helpers"| node_xml
node_pacs002 -->|"validates identifiers"| node_identifiers
node_risk -->|"includes payee result"| node_vop
node_risk -->|"reads payment history"| node_ledger
node_ledger -->|"checks active holds"| node_holds
node_ledger -->|"persists entries"| node_models
node_models -->|"uses database setup"| node_db
node_tracing -->|"follows transfers"| node_ledger
node_tracing -->|"freezes traced funds"| node_holds
node_audit -->|"persists logs"| node_models
node_retention -->|"purges records"| node_models
node_scenario -->|"scores payments"| node_risk
node_scenario -->|"runs payment flow"| node_payments
node_scenario -->|"traces scam funds"| node_tracing
node_scenario -->|"freezes funds"| node_holds
node_liability -->|"allocates scenario losses"| node_scenario
node_calibration -->|"calibrates assumptions"| node_scenario
node_calibration -->|"uses liability outcomes"| node_liability
node_report -->|"summarizes runs"| node_scenario
node_report -->|"reports loss shares"| node_liability
node_report -->|"reports calibration"| node_calibration

click node_api_app "https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/api/app.py"
click node_api_auth "https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/api/auth.py"
click node_api_limits "https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/api/ratelimit.py"
click node_api_serve "https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/api/serve.py"
click node_payments "https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/payments.py"
click node_pacs008 "https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/iso20022/pacs008.py"
click node_pacs002 "https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/iso20022/pacs002.py"
click node_xml "https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/iso20022/_xml.py"
click node_identifiers "https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/iso20022/identifiers.py"
click node_vop "https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/vop.py"
click node_risk "https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/risk.py"
click node_ledger "https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/ledger.py"
click node_models "https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/models.py"
click node_db "https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/db.py"
click node_audit "https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/audit.py"
click node_holds "https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/holds.py"
click node_tracing "https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/tracing.py"
click node_retention "https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/retention.py"
click node_scenario "https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/simulation.py"
click node_liability "https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/liability.py"
click node_calibration "https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/calibration.py"
click node_report "https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/scenario_report.py"

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_api_app,node_api_auth,node_api_limits,node_api_serve,node_bank toneBlue
class node_payments,node_pacs008,node_pacs002,node_xml,node_identifiers,node_vop,node_risk toneAmber
class node_ledger,node_models,node_db,node_audit,node_holds,node_tracing,node_retention toneMint
class node_scenario,node_liability,node_calibration,node_report toneRose
```

## Components

### Bank API

- [HTTP endpoints](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/api/app.py): `src/echtzeit/api/app.py`
- [API keys and roles](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/api/auth.py): `src/echtzeit/api/auth.py`
- [Request limits](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/api/ratelimit.py): `src/echtzeit/api/ratelimit.py`
- [Safe launcher](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/api/serve.py): `src/echtzeit/api/serve.py`

### Payment Processing

- [Payment processor](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/payments.py): `src/echtzeit/payments.py`
- [Credit transfer XML](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/iso20022/pacs008.py): `src/echtzeit/iso20022/pacs008.py`
- [Status report XML](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/iso20022/pacs002.py): `src/echtzeit/iso20022/pacs002.py`
- [XML utilities](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/iso20022/_xml.py): `src/echtzeit/iso20022/_xml.py`
- [Payment identifiers](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/iso20022/identifiers.py): `src/echtzeit/iso20022/identifiers.py`
- [Payee verification](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/vop.py): `src/echtzeit/vop.py`
- [Risk assessment](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/risk.py): `src/echtzeit/risk.py`

### Ledger and Recovery

- [Double-entry ledger](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/ledger.py): `src/echtzeit/ledger.py`
- [Persistent records](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/models.py): `src/echtzeit/models.py`
- [Database setup](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/db.py): `src/echtzeit/db.py`
- [Rejection and request logs](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/audit.py): `src/echtzeit/audit.py`
- [Funds holds](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/holds.py): `src/echtzeit/holds.py`
- [Payment tracing](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/tracing.py): `src/echtzeit/tracing.py`
- [Data retention](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/retention.py): `src/echtzeit/retention.py`

### Scenario Analysis

- [Seeded scenarios](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/simulation.py): `src/echtzeit/simulation.py`
- [Loss allocation](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/liability.py): `src/echtzeit/liability.py`
- [Reference calibration](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/calibration.py): `src/echtzeit/calibration.py`
- [Scenario reporting](https://github.com/flango2023/echtzeit/blob/main/src/echtzeit/scenario_report.py): `src/echtzeit/scenario_report.py`

### Other components

- **Bank client**

## Connections

- Bank client → HTTP endpoints: calls (evidence: `README.md`)
- HTTP endpoints → API keys and roles: authenticates (evidence: `src/echtzeit/api/app.py`)
- HTTP endpoints → Request limits: limits requests (evidence: `src/echtzeit/api/app.py`)
- Safe launcher → HTTP endpoints: starts (evidence: `src/echtzeit/api/serve.py`)
- HTTP endpoints → Payee verification: serves checks (evidence: `src/echtzeit/api/app.py`)
- HTTP endpoints → Risk assessment: serves assessments (evidence: `src/echtzeit/api/app.py`)
- HTTP endpoints → Payment processor: routes payments (evidence: `README.md`)
- HTTP endpoints → Double-entry ledger: serves account operations (evidence: `src/echtzeit/api/app.py`)
- HTTP endpoints → Payment tracing: serves trace requests (evidence: `src/echtzeit/api/app.py`)
- HTTP endpoints → Rejection and request logs: reads audit logs (evidence: `src/echtzeit/api/app.py`)
- HTTP endpoints → Funds holds: serves hold operations (evidence: `README.md`)
- Payment processor → Credit transfer XML: parses messages (evidence: `src/echtzeit/payments.py`)
- Payment processor → Status report XML: builds replies (evidence: `src/echtzeit/payments.py`)
- Payment processor → Double-entry ledger: books transfers (evidence: `README.md`)
- Payment processor → Rejection and request logs: records rejections (evidence: `README.md`)
- Credit transfer XML → XML utilities: uses XML helpers (evidence: `src/echtzeit/iso20022/pacs008.py`)
- Credit transfer XML → Payment identifiers: validates identifiers (evidence: `src/echtzeit/iso20022/pacs008.py`)
- Status report XML → XML utilities: uses XML helpers (evidence: `src/echtzeit/iso20022/pacs002.py`)
- Status report XML → Payment identifiers: validates identifiers (evidence: `src/echtzeit/iso20022/pacs002.py`)
- Risk assessment → Payee verification: includes payee result (evidence: `src/echtzeit/risk.py`)
- Risk assessment → Double-entry ledger: reads payment history (evidence: `src/echtzeit/risk.py`)
- Double-entry ledger → Funds holds: checks active holds (evidence: `src/echtzeit/ledger.py`)
- Double-entry ledger → Persistent records: persists entries (evidence: `src/echtzeit/ledger.py`)
- Persistent records → Database setup: uses database setup (evidence: `src/echtzeit/models.py`)
- Payment tracing → Double-entry ledger: follows transfers (evidence: `src/echtzeit/tracing.py`)
- Payment tracing → Funds holds: freezes traced funds (evidence: `src/echtzeit/tracing.py`)
- Rejection and request logs → Persistent records: persists logs (evidence: `src/echtzeit/audit.py`)
- Data retention → Persistent records: purges records (evidence: `src/echtzeit/retention.py`)
- Seeded scenarios → Risk assessment: scores payments (evidence: `src/echtzeit/simulation.py`)
- Seeded scenarios → Payment processor: runs payment flow (evidence: `src/echtzeit/simulation.py`)
- Seeded scenarios → Payment tracing: traces scam funds (evidence: `src/echtzeit/simulation.py`)
- Seeded scenarios → Funds holds: freezes funds (evidence: `src/echtzeit/simulation.py`)
- Loss allocation → Seeded scenarios: allocates scenario losses (evidence: `src/echtzeit/liability.py`)
- Reference calibration → Seeded scenarios: calibrates assumptions (evidence: `src/echtzeit/calibration.py`)
- Reference calibration → Loss allocation: uses liability outcomes (evidence: `src/echtzeit/calibration.py`)
- Scenario reporting → Seeded scenarios: summarizes runs (evidence: `src/echtzeit/scenario_report.py`)
- Scenario reporting → Loss allocation: reports loss shares (evidence: `src/echtzeit/scenario_report.py`)
- Scenario reporting → Reference calibration: reports calibration (evidence: `src/echtzeit/scenario_report.py`)
