# ssrlaptop/improved-fortnight architecture

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

- Interactive diagram: https://gitdiagram.com/ssrlaptop/improved-fortnight
- Repository: https://github.com/ssrlaptop/improved-fortnight

## Overview

Regulatory Circular → Live Rule Engine turns circular text into clause-traceable obligations, policy mappings and draft rules, then backtests and validates them before mandatory human approval. Approved rules can be simulated in shadow, staged rollout, monitored, rolled back or killed; “live” decisions use seeded transactions, not bank traffic. Staff use the web console or CLI, with shared engine actions and role-based write access. The graph reflects documented workflow and indexed dependencies; unsampled implementation details and unverified links are omitted.

Main entry points: [`regengine/pipeline.py`](https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/pipeline.py) (Pipeline orchestration), [`regengine/console.py`](https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/console.py) (HTTP console), [`regengine/agents.py`](https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/agents.py) (Extraction, mapping, authoring), [`regengine/deployment.py`](https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/deployment.py) (Shadow and rollout)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_intake["Intake and analysis"]
  node_pipeline["Pipeline orchestration<br/>[pipeline.py]"]
  node_agents["Extraction, mapping, authoring<br/>[agents.py]"]
  node_retrieval["Policy retrieval<br/>[retrieval.py]"]
  node_profile["Bank profile<br/>[bank_profile.py]"]
  node_llm["LLM adapters<br/>[llm.py]"]
  node_models["Domain records<br/>[models.py]"]
  node_transaction["Transaction sample"]
end

subgraph group_rules["Rule lifecycle"]
  node_dsl["Rule DSL<br/>[dsl.py]"]
  node_backtest["Backtest and impact<br/>[backtest.py]"]
  node_repository["Rule versions and integrity<br/>[rule_repository.py]"]
  node_approval["Human approval"]
end

subgraph group_operations["Operations and state"]
  node_deployment["Shadow and rollout<br/>[deployment.py]"]
  node_monitoring["Drift monitoring<br/>[monitoring.py]"]
  node_auth["Authentication and roles<br/>[auth.py]"]
  node_store[("State and audit store<br/>[store.py]")]
end

subgraph group_interfaces["Staff interfaces"]
  node_cli["CLI<br/>[cli.py]"]
  node_web["Console UI<br/>[views.tsx]"]
  node_api["UI API client<br/>[api.ts]"]
  node_console["HTTP console<br/>[console.py]"]
end

node_staff(("Bank staff"))
node_external_llm{{"LLM provider"}}

node_staff -->|"runs commands"| node_cli
node_staff -->|"uses console"| node_web
node_web -->|"requests actions"| node_api
node_api -.->|"calls HTTP API"| node_console
node_cli -->|"runs pipeline"| node_pipeline
node_console -->|"runs intake"| node_pipeline
node_pipeline -->|"runs agents"| node_agents
node_pipeline -->|"filters applicability"| node_profile
node_pipeline -->|"loads sample"| node_transaction
node_pipeline -->|"compares drafts"| node_backtest
node_pipeline -->|"records versions"| node_repository
node_pipeline -->|"persists run"| node_store
node_agents -->|"requests completion"| node_llm
node_agents -->|"retrieves policies"| node_retrieval
node_agents -->|"validates rules"| node_dsl
node_agents -->|"creates records"| node_models
node_llm -.->|"calls provider"| node_external_llm
node_backtest -->|"evaluates rules"| node_dsl
node_backtest -.->|"replays sample"| node_transaction
node_approval -->|"approves version"| node_repository
node_approval -->|"records decision"| node_store
node_deployment -->|"checks candidate"| node_repository
node_deployment -->|"evaluates traffic"| node_dsl
node_deployment -->|"records stage"| node_store
node_monitoring -->|"reads deployment state"| node_deployment
node_console -->|"verifies sessions"| node_auth
node_console -->|"decides drafts"| node_approval
node_console -->|"operates rules"| node_deployment
node_console -->|"reads and writes"| node_store

click node_cli "https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/cli.py"
click node_web "https://github.com/ssrlaptop/improved-fortnight/blob/main/web/src/views.tsx"
click node_api "https://github.com/ssrlaptop/improved-fortnight/blob/main/web/src/api.ts"
click node_console "https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/console.py"
click node_pipeline "https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/pipeline.py"
click node_agents "https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/agents.py"
click node_retrieval "https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/retrieval.py"
click node_profile "https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/bank_profile.py"
click node_llm "https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/llm.py"
click node_models "https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/models.py"
click node_transaction "https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/transaction_data.py"
click node_dsl "https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/dsl.py"
click node_backtest "https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/backtest.py"
click node_repository "https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/rule_repository.py"
click node_approval "https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/approval_workflow.py"
click node_deployment "https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/deployment.py"
click node_monitoring "https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/monitoring.py"
click node_auth "https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/auth.py"
click node_store "https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/store.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_pipeline,node_agents,node_retrieval,node_profile,node_llm,node_models,node_transaction toneBlue
class node_dsl,node_backtest,node_repository,node_approval toneAmber
class node_deployment,node_monitoring,node_auth,node_store toneMint
class node_cli,node_web,node_api,node_console toneRose
class node_staff,node_external_llm toneIndigo
```

## Components

### Intake and analysis

- [Pipeline orchestration](https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/pipeline.py): `regengine/pipeline.py`
- [Extraction, mapping, authoring](https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/agents.py): `regengine/agents.py`
- [Policy retrieval](https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/retrieval.py): `regengine/retrieval.py`
- [Bank profile](https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/bank_profile.py): `regengine/bank_profile.py`
- [LLM adapters](https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/llm.py): `regengine/llm.py`
- [Domain records](https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/models.py): `regengine/models.py`
- [Transaction sample](https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/transaction_data.py): `regengine/transaction_data.py`

### Rule lifecycle

- [Rule DSL](https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/dsl.py): `regengine/dsl.py`
- [Backtest and impact](https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/backtest.py): `regengine/backtest.py`
- [Rule versions and integrity](https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/rule_repository.py): `regengine/rule_repository.py`
- [Human approval](https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/approval_workflow.py): `regengine/approval_workflow.py`

### Operations and state

- [Shadow and rollout](https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/deployment.py): `regengine/deployment.py`
- [Drift monitoring](https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/monitoring.py): `regengine/monitoring.py`
- [Authentication and roles](https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/auth.py): `regengine/auth.py`
- [State and audit store](https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/store.py): `regengine/store.py`

### Staff interfaces

- [CLI](https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/cli.py): `regengine/cli.py`
- [Console UI](https://github.com/ssrlaptop/improved-fortnight/blob/main/web/src/views.tsx): `web/src/views.tsx`
- [UI API client](https://github.com/ssrlaptop/improved-fortnight/blob/main/web/src/api.ts): `web/src/api.ts`
- [HTTP console](https://github.com/ssrlaptop/improved-fortnight/blob/main/regengine/console.py): `regengine/console.py`

### Other components

- **Bank staff**
- **LLM provider**

## Connections

- Bank staff → CLI: runs commands (evidence: `README.md`)
- Bank staff → Console UI: uses console (evidence: `README.md`)
- Console UI → UI API client: requests actions (evidence: `web/src/views.tsx`)
- UI API client → HTTP console: calls HTTP API
- CLI → Pipeline orchestration: runs pipeline (evidence: `regengine/cli.py`)
- HTTP console → Pipeline orchestration: runs intake (evidence: `regengine/console.py`)
- Pipeline orchestration → Extraction, mapping, authoring: runs agents (evidence: `regengine/pipeline.py`)
- Pipeline orchestration → Bank profile: filters applicability (evidence: `regengine/pipeline.py`)
- Pipeline orchestration → Transaction sample: loads sample (evidence: `regengine/pipeline.py`)
- Pipeline orchestration → Backtest and impact: compares drafts (evidence: `regengine/pipeline.py`)
- Pipeline orchestration → Rule versions and integrity: records versions (evidence: `regengine/pipeline.py`)
- Pipeline orchestration → State and audit store: persists run (evidence: `regengine/pipeline.py`)
- Extraction, mapping, authoring → LLM adapters: requests completion (evidence: `regengine/agents.py`)
- Extraction, mapping, authoring → Policy retrieval: retrieves policies (evidence: `regengine/agents.py`)
- Extraction, mapping, authoring → Rule DSL: validates rules (evidence: `regengine/agents.py`)
- Extraction, mapping, authoring → Domain records: creates records (evidence: `regengine/agents.py`)
- LLM adapters → LLM provider: calls provider (evidence: `README.md`)
- Backtest and impact → Rule DSL: evaluates rules (evidence: `regengine/backtest.py`)
- Backtest and impact → Transaction sample: replays sample
- Human approval → Rule versions and integrity: approves version (evidence: `regengine/approval_workflow.py`)
- Human approval → State and audit store: records decision (evidence: `regengine/approval_workflow.py`)
- Shadow and rollout → Rule versions and integrity: checks candidate (evidence: `regengine/deployment.py`)
- Shadow and rollout → Rule DSL: evaluates traffic (evidence: `regengine/deployment.py`)
- Shadow and rollout → State and audit store: records stage (evidence: `regengine/deployment.py`)
- Drift monitoring → Shadow and rollout: reads deployment state (evidence: `regengine/monitoring.py`)
- HTTP console → Authentication and roles: verifies sessions (evidence: `regengine/console.py`)
- HTTP console → Human approval: decides drafts (evidence: `README.md`)
- HTTP console → Shadow and rollout: operates rules (evidence: `README.md`)
- HTTP console → State and audit store: reads and writes (evidence: `regengine/console.py`)
