# mfdel/fact-ledger architecture

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

- Interactive diagram: https://gitdiagram.com/mfdel/fact-ledger
- Repository: https://github.com/mfdel/fact-ledger

## Overview

Investor Intel builds an auditable company fact base from investor materials, checks for inconsistencies and gaps, and produces management questions—not a valuation or forecast. The main workflow is document extraction/transcription, fact storage, validation and review output. The README documents these product stages; the source index confirms key module references, but unsampled implementation details and some runtime wiring are not verified.

Main entry points: [`src/investor_intel/domain/validator.py`](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/domain/validator.py) (Fact Validator), [`src/investor_intel/cli/__init__.py`](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/cli/__init__.py) (CLI Commands), [`src/investor_intel/cli/facts.py`](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/cli/facts.py) (Facts and Brief CLI), [`src/investor_intel/cli/extract.py`](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/cli/extract.py) (Extraction Command)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User Interfaces"]
  node_cli["CLI Commands<br/>[__init__.py]"]
  node_web["Web Pages<br/>[pages.py]"]
  node_app["Web App<br/>[app.py]"]
  node_fact_cli["Facts and Brief CLI<br/>[facts.py]"]
  node_brief_cli["Brief Command<br/>[brief.py]"]
  node_health["Health Endpoint<br/>[health.py]"]
end

subgraph group_ingest["Evidence Ingestion"]
  node_source_docs["Company Documents"]
  node_extract_cli["Extraction Command<br/>[extract.py]"]
  node_extractor["Document Extraction<br/>[extract.py]"]
  node_llm["LLM Service<br/>[llm.py]"]
  node_transcripts["Transcripts<br/>[yaml_files.py]"]
end

subgraph group_domain["Fact Analysis"]
  node_dictionary["Metric Dictionary<br/>[models.py]"]
  node_observations["Fact Records<br/>[models.py]"]
  node_validator["Fact Validator<br/>[validator.py]"]
  node_checks["Identity Checks<br/>[checks.py]"]
  node_rules["Domain Rules<br/>[rules.py]"]
  node_patterns["Fact Patterns<br/>[patterns.py]"]
  node_questions["Management Questions<br/>[questions.py]"]
end

subgraph group_persistence["Fact Persistence"]
  node_fact_store[("Fact Store<br/>[facts.py]")]
  node_database[("Database<br/>[db.py]")]
  node_yaml_store["YAML Files<br/>[yaml_files.py]"]
  node_settings["Runtime Settings<br/>[settings.py]"]
end

node_investor(("Investor"))

node_investor -->|"runs commands"| node_cli
node_investor -->|"views results"| node_web
node_app -->|"serves pages"| node_web
node_app -->|"registers endpoint"| node_health
node_source_docs -->|"provides documents"| node_extract_cli
node_extract_cli -->|"invokes extraction"| node_extractor
node_extract_cli -->|"requests model output"| node_llm
node_extract_cli -->|"writes transcript"| node_yaml_store
node_extractor -->|"produces facts"| node_observations
node_llm -->|"reads configuration"| node_settings
node_fact_cli -->|"reads transcript"| node_yaml_store
node_yaml_store -->|"parses records"| node_observations
node_fact_cli -->|"loads and queries"| node_fact_store
node_fact_store -->|"persists observations"| node_database
node_cli -->|"loads settings"| node_settings
node_cli -->|"creates engine"| node_database
node_cli -->|"opens store"| node_fact_store
node_cli -->|"loads dictionary"| node_dictionary
node_yaml_store -->|"loads definitions"| node_dictionary
node_brief_cli -->|"composes commands"| node_fact_cli
node_brief_cli -->|"requests validation"| node_validator
node_fact_cli -->|"validates facts"| node_validator
node_validator -->|"runs identities"| node_checks
node_validator -->|"builds findings"| node_patterns
node_validator -->|"applies policies"| node_rules
node_validator -->|"reads stored facts"| node_fact_store
node_validator -->|"forms questions"| node_questions
node_brief_cli -->|"prints questions"| node_questions
node_fact_cli -->|"uses metric definitions"| node_dictionary

click node_cli "https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/cli/__init__.py"
click node_web "https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/web/pages.py"
click node_app "https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/app.py"
click node_extract_cli "https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/cli/extract.py"
click node_extractor "https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/extract.py"
click node_llm "https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/llm.py"
click node_transcripts "https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/store/yaml_files.py"
click node_dictionary "https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/domain/models.py"
click node_observations "https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/domain/models.py"
click node_validator "https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/domain/validator.py"
click node_checks "https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/domain/checks.py"
click node_rules "https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/domain/rules.py"
click node_patterns "https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/domain/patterns.py"
click node_questions "https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/domain/questions.py"
click node_fact_cli "https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/cli/facts.py"
click node_brief_cli "https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/cli/brief.py"
click node_fact_store "https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/store/facts.py"
click node_database "https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/store/db.py"
click node_yaml_store "https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/store/yaml_files.py"
click node_settings "https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/settings.py"
click node_health "https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/api/health.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_cli,node_web,node_app,node_fact_cli,node_brief_cli,node_health toneBlue
class node_source_docs,node_extract_cli,node_extractor,node_llm,node_transcripts toneAmber
class node_dictionary,node_observations,node_validator,node_checks,node_rules,node_patterns,node_questions toneMint
class node_fact_store,node_database,node_yaml_store,node_settings toneRose
class node_investor toneIndigo
```

## Components

### User Interfaces

- [CLI Commands](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/cli/__init__.py): `src/investor_intel/cli/__init__.py`
- [Web Pages](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/web/pages.py): `src/investor_intel/web/pages.py`
- [Web App](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/app.py): `src/investor_intel/app.py`
- [Facts and Brief CLI](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/cli/facts.py): `src/investor_intel/cli/facts.py`
- [Brief Command](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/cli/brief.py): `src/investor_intel/cli/brief.py`
- [Health Endpoint](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/api/health.py): `src/investor_intel/api/health.py`

### Evidence Ingestion

- **Company Documents**
- [Extraction Command](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/cli/extract.py): `src/investor_intel/cli/extract.py`
- [Document Extraction](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/extract.py): `src/investor_intel/extract.py`
- [LLM Service](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/llm.py): `src/investor_intel/llm.py`
- [Transcripts](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/store/yaml_files.py): `src/investor_intel/store/yaml_files.py`

### Fact Analysis

- [Metric Dictionary](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/domain/models.py): `src/investor_intel/domain/models.py`
- [Fact Records](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/domain/models.py): `src/investor_intel/domain/models.py`
- [Fact Validator](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/domain/validator.py): `src/investor_intel/domain/validator.py`
- [Identity Checks](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/domain/checks.py): `src/investor_intel/domain/checks.py`
- [Domain Rules](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/domain/rules.py): `src/investor_intel/domain/rules.py`
- [Fact Patterns](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/domain/patterns.py): `src/investor_intel/domain/patterns.py`
- [Management Questions](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/domain/questions.py): `src/investor_intel/domain/questions.py`

### Fact Persistence

- [Fact Store](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/store/facts.py): `src/investor_intel/store/facts.py`
- [Database](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/store/db.py): `src/investor_intel/store/db.py`
- [YAML Files](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/store/yaml_files.py): `src/investor_intel/store/yaml_files.py`
- [Runtime Settings](https://github.com/mfdel/fact-ledger/blob/main/src/investor_intel/settings.py): `src/investor_intel/settings.py`

### Other components

- **Investor**

## Connections

- Investor → CLI Commands: runs commands (evidence: `README.md`)
- Investor → Web Pages: views results (evidence: `README.md`)
- Web App → Web Pages: serves pages (evidence: `src/investor_intel/app.py`)
- Web App → Health Endpoint: registers endpoint (evidence: `src/investor_intel/app.py`)
- Company Documents → Extraction Command: provides documents (evidence: `README.md`)
- Extraction Command → Document Extraction: invokes extraction (evidence: `src/investor_intel/cli/extract.py`)
- Extraction Command → LLM Service: requests model output (evidence: `src/investor_intel/cli/extract.py`)
- Extraction Command → YAML Files: writes transcript (evidence: `src/investor_intel/cli/extract.py`)
- Document Extraction → Fact Records: produces facts (evidence: `README.md`)
- LLM Service → Runtime Settings: reads configuration (evidence: `src/investor_intel/llm.py`)
- Facts and Brief CLI → YAML Files: reads transcript (evidence: `src/investor_intel/cli/facts.py`)
- YAML Files → Fact Records: parses records (evidence: `src/investor_intel/store/yaml_files.py`)
- Facts and Brief CLI → Fact Store: loads and queries (evidence: `src/investor_intel/cli/facts.py`)
- Fact Store → Database: persists observations (evidence: `src/investor_intel/store/facts.py`)
- CLI Commands → Runtime Settings: loads settings (evidence: `src/investor_intel/cli/__init__.py`)
- CLI Commands → Database: creates engine (evidence: `src/investor_intel/cli/__init__.py`)
- CLI Commands → Fact Store: opens store (evidence: `src/investor_intel/cli/__init__.py`)
- CLI Commands → Metric Dictionary: loads dictionary (evidence: `src/investor_intel/cli/__init__.py`)
- YAML Files → Metric Dictionary: loads definitions (evidence: `src/investor_intel/store/yaml_files.py`)
- Brief Command → Facts and Brief CLI: composes commands (evidence: `src/investor_intel/cli/brief.py`)
- Brief Command → Fact Validator: requests validation (evidence: `src/investor_intel/cli/brief.py`)
- Facts and Brief CLI → Fact Validator: validates facts (evidence: `src/investor_intel/cli/facts.py`)
- Fact Validator → Identity Checks: runs identities (evidence: `src/investor_intel/domain/validator.py`)
- Fact Validator → Fact Patterns: builds findings (evidence: `src/investor_intel/domain/validator.py`)
- Fact Validator → Domain Rules: applies policies (evidence: `src/investor_intel/domain/validator.py`)
- Fact Validator → Fact Store: reads stored facts (evidence: `README.md`)
- Fact Validator → Management Questions: forms questions (evidence: `README.md`)
- Brief Command → Management Questions: prints questions (evidence: `src/investor_intel/cli/brief.py`)
- Facts and Brief CLI → Metric Dictionary: uses metric definitions (evidence: `src/investor_intel/cli/facts.py`)
