# yaokl-nju/capital-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/yaokl-nju/capital-tracker
- Repository: https://github.com/yaokl-nju/capital-tracker

## Overview

Capital Tracker is a command-line financial intelligence assistant. A user selects domestic or international tracking topics; the investment tracker creates focused queries, gathers and processes search evidence, and analyzes it with an LLM when configured. The orchestrator runs topics concurrently, then produces PDF reports and can optionally email them. The product also supports SEC holdings, evidence-quality reporting, searchable-result caching, and report archives for comparison or replay. Edges reflect the README and SOURCE INDEX references; unsampled implementation details and some optional integrations are represented conservatively.

Main entry points: [`core/search_service.py`](https://github.com/yaokl-nju/capital-tracker/blob/main/core/search_service.py) (Search service), [`core/orchestrator.py`](https://github.com/yaokl-nju/capital-tracker/blob/main/core/orchestrator.py) (Topic orchestration), [`core/tracker.py`](https://github.com/yaokl-nju/capital-tracker/blob/main/core/tracker.py) (Query and analysis), [`run.py`](https://github.com/yaokl-nju/capital-tracker/blob/main/run.py) (Command entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Command and orchestration"]
  node_cli["Command entry<br/>[run.py]"]
  node_orchestrator["Topic orchestration<br/>[orchestrator.py]"]
end

subgraph group_research["Investment research"]
  node_investment["Investment tracker<br/>[investment.py]"]
  node_tracker["Query and analysis<br/>[tracker.py]"]
  node_search["Search service<br/>[search_service.py]"]
  node_funds["Fund identity mappings<br/>[fund_mappings.py]"]
  node_profiles["Research profiles"]
  node_settings["Runtime settings<br/>[settings.py]"]
  node_search_policy["Search policy<br/>[search_policy.py]"]
  node_search_cache[("Search cache<br/>[search_cache.py]")]
  node_sec_holdings["SEC holdings<br/>[sec_holdings.py]"]
  node_llm["LLM analysis<br/>[llm_service.py]"]
end

subgraph group_evidence["Evidence and archives"]
  node_diagnostics["Diagnostics<br/>[diagnostics.py]"]
  node_evidence_quality["Evidence quality"]
  node_citations["Citation checks<br/>[citations.py]"]
  node_artifacts["Report archive<br/>[artifacts.py]"]
  node_checkpoint["Checkpoint recovery"]
  node_archive_compare["Archive comparison<br/>[archive_compare.py]"]
end

subgraph group_delivery["Report delivery"]
  node_pdf["PDF generation"]
  node_email["Email delivery<br/>[email_service.py]"]
end

node_user(("CLI user"))
node_search_providers{{"Search providers"}}
node_sec{{"SEC filings"}}
node_smtp{{"SMTP service"}}

node_user -->|"runs"| node_cli
node_cli -->|"selects tracker"| node_investment
node_cli -->|"starts run"| node_orchestrator
node_cli -->|"loads profile"| node_profiles
node_cli -->|"configures"| node_settings
node_investment -->|"extends"| node_tracker
node_investment -->|"constructs"| node_search
node_investment -->|"constructs"| node_llm
node_investment -->|"uses mappings"| node_funds
node_tracker -->|"searches queries"| node_search
node_tracker -->|"generates and analyzes"| node_llm
node_tracker -->|"records evidence"| node_evidence_quality
node_tracker -->|"validates citations"| node_citations
node_search -->|"reads configuration"| node_settings
node_search -->|"resolves fund names"| node_funds
node_search -->|"uses policy"| node_search_policy
node_search -->|"reads and writes"| node_search_cache
node_search -->|"retrieves holdings"| node_sec_holdings
node_search -->|"records events"| node_diagnostics
node_search -->|"queries providers"| node_search_providers
node_sec_holdings -.->|"retrieves filings"| node_sec
node_llm -->|"uses configuration"| node_settings
node_llm -->|"records events"| node_diagnostics
node_orchestrator -->|"processes topics"| node_tracker
node_orchestrator -->|"renders reports"| node_pdf
node_orchestrator -->|"saves report data"| node_artifacts
node_orchestrator -->|"recovers progress"| node_checkpoint
node_orchestrator -->|"sends report"| node_email
node_orchestrator -.->|"compares archives"| node_archive_compare
node_artifacts -->|"summarizes coverage"| node_evidence_quality
node_artifacts -->|"validates citations"| node_citations
node_checkpoint -->|"reads archive"| node_artifacts
node_archive_compare -->|"reads archives"| node_artifacts
node_archive_compare -->|"assesses evidence"| node_evidence_quality
node_archive_compare -->|"uses search utilities"| node_search
node_pdf -->|"uses configuration"| node_settings
node_pdf -->|"uses URL utilities"| node_search
node_email -->|"sends via SMTP"| node_smtp

click node_cli "https://github.com/yaokl-nju/capital-tracker/blob/main/run.py"
click node_orchestrator "https://github.com/yaokl-nju/capital-tracker/blob/main/core/orchestrator.py"
click node_investment "https://github.com/yaokl-nju/capital-tracker/blob/main/trackers/investment.py"
click node_tracker "https://github.com/yaokl-nju/capital-tracker/blob/main/core/tracker.py"
click node_search "https://github.com/yaokl-nju/capital-tracker/blob/main/core/search_service.py"
click node_funds "https://github.com/yaokl-nju/capital-tracker/blob/main/config/fund_mappings.py"
click node_profiles "https://github.com/yaokl-nju/capital-tracker/blob/main/config/research_profiles.py"
click node_settings "https://github.com/yaokl-nju/capital-tracker/blob/main/config/settings.py"
click node_search_policy "https://github.com/yaokl-nju/capital-tracker/blob/main/core/search_policy.py"
click node_search_cache "https://github.com/yaokl-nju/capital-tracker/blob/main/core/search_cache.py"
click node_sec_holdings "https://github.com/yaokl-nju/capital-tracker/blob/main/core/sec_holdings.py"
click node_llm "https://github.com/yaokl-nju/capital-tracker/blob/main/core/llm_service.py"
click node_diagnostics "https://github.com/yaokl-nju/capital-tracker/blob/main/core/diagnostics.py"
click node_evidence_quality "https://github.com/yaokl-nju/capital-tracker/blob/main/core/evidence_quality.py"
click node_citations "https://github.com/yaokl-nju/capital-tracker/blob/main/core/citations.py"
click node_artifacts "https://github.com/yaokl-nju/capital-tracker/blob/main/core/artifacts.py"
click node_checkpoint "https://github.com/yaokl-nju/capital-tracker/blob/main/core/checkpoint_recovery.py"
click node_archive_compare "https://github.com/yaokl-nju/capital-tracker/blob/main/core/archive_compare.py"
click node_pdf "https://github.com/yaokl-nju/capital-tracker/blob/main/core/report_generator.py"
click node_email "https://github.com/yaokl-nju/capital-tracker/blob/main/core/email_service.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_orchestrator,node_user toneBlue
class node_investment,node_tracker,node_search,node_funds,node_profiles,node_settings,node_search_policy,node_search_cache,node_sec_holdings,node_llm toneAmber
class node_diagnostics,node_evidence_quality,node_citations,node_artifacts,node_checkpoint,node_archive_compare toneMint
class node_pdf,node_email toneRose
class node_search_providers,node_sec,node_smtp toneIndigo
```

## Components

### Command and orchestration

- [Command entry](https://github.com/yaokl-nju/capital-tracker/blob/main/run.py): `run.py`
- [Topic orchestration](https://github.com/yaokl-nju/capital-tracker/blob/main/core/orchestrator.py): `core/orchestrator.py`

### Investment research

- [Investment tracker](https://github.com/yaokl-nju/capital-tracker/blob/main/trackers/investment.py): `trackers/investment.py`
- [Query and analysis](https://github.com/yaokl-nju/capital-tracker/blob/main/core/tracker.py): `core/tracker.py`
- [Search service](https://github.com/yaokl-nju/capital-tracker/blob/main/core/search_service.py): `core/search_service.py`
- [Fund identity mappings](https://github.com/yaokl-nju/capital-tracker/blob/main/config/fund_mappings.py): `config/fund_mappings.py`
- [Research profiles](https://github.com/yaokl-nju/capital-tracker/blob/main/config/research_profiles.py): `config/research_profiles.py`
- [Runtime settings](https://github.com/yaokl-nju/capital-tracker/blob/main/config/settings.py): `config/settings.py`
- [Search policy](https://github.com/yaokl-nju/capital-tracker/blob/main/core/search_policy.py): `core/search_policy.py`
- [Search cache](https://github.com/yaokl-nju/capital-tracker/blob/main/core/search_cache.py): `core/search_cache.py`
- [SEC holdings](https://github.com/yaokl-nju/capital-tracker/blob/main/core/sec_holdings.py): `core/sec_holdings.py`
- [LLM analysis](https://github.com/yaokl-nju/capital-tracker/blob/main/core/llm_service.py): `core/llm_service.py`

### Evidence and archives

- [Diagnostics](https://github.com/yaokl-nju/capital-tracker/blob/main/core/diagnostics.py): `core/diagnostics.py`
- [Evidence quality](https://github.com/yaokl-nju/capital-tracker/blob/main/core/evidence_quality.py): `core/evidence_quality.py`
- [Citation checks](https://github.com/yaokl-nju/capital-tracker/blob/main/core/citations.py): `core/citations.py`
- [Report archive](https://github.com/yaokl-nju/capital-tracker/blob/main/core/artifacts.py): `core/artifacts.py`
- [Checkpoint recovery](https://github.com/yaokl-nju/capital-tracker/blob/main/core/checkpoint_recovery.py): `core/checkpoint_recovery.py`
- [Archive comparison](https://github.com/yaokl-nju/capital-tracker/blob/main/core/archive_compare.py): `core/archive_compare.py`

### Report delivery

- [PDF generation](https://github.com/yaokl-nju/capital-tracker/blob/main/core/report_generator.py): `core/report_generator.py`
- [Email delivery](https://github.com/yaokl-nju/capital-tracker/blob/main/core/email_service.py): `core/email_service.py`

### Other components

- **CLI user**
- **Search providers**
- **SEC filings**
- **SMTP service**

## Connections

- CLI user → Command entry: runs (evidence: `README.md`)
- Command entry → Investment tracker: selects tracker (evidence: `run.py`)
- Command entry → Topic orchestration: starts run (evidence: `run.py`)
- Command entry → Research profiles: loads profile (evidence: `run.py`)
- Command entry → Runtime settings: configures (evidence: `run.py`)
- Investment tracker → Query and analysis: extends (evidence: `trackers/investment.py`)
- Investment tracker → Search service: constructs (evidence: `trackers/investment.py`)
- Investment tracker → LLM analysis: constructs (evidence: `trackers/investment.py`)
- Investment tracker → Fund identity mappings: uses mappings (evidence: `trackers/investment.py`)
- Query and analysis → Search service: searches queries (evidence: `core/tracker.py`)
- Query and analysis → LLM analysis: generates and analyzes (evidence: `core/tracker.py`)
- Query and analysis → Evidence quality: records evidence (evidence: `core/tracker.py`)
- Query and analysis → Citation checks: validates citations (evidence: `core/tracker.py`)
- Search service → Runtime settings: reads configuration (evidence: `core/search_service.py`)
- Search service → Fund identity mappings: resolves fund names (evidence: `core/search_service.py`)
- Search service → Search policy: uses policy (evidence: `core/search_service.py`)
- Search service → Search cache: reads and writes (evidence: `core/search_service.py`)
- Search service → SEC holdings: retrieves holdings (evidence: `core/search_service.py`)
- Search service → Diagnostics: records events (evidence: `core/search_service.py`)
- Search service → Search providers: queries providers (evidence: `README.md`)
- SEC holdings → SEC filings: retrieves filings
- LLM analysis → Runtime settings: uses configuration (evidence: `core/llm_service.py`)
- LLM analysis → Diagnostics: records events (evidence: `core/llm_service.py`)
- Topic orchestration → Query and analysis: processes topics (evidence: `core/orchestrator.py`)
- Topic orchestration → PDF generation: renders reports (evidence: `core/orchestrator.py`)
- Topic orchestration → Report archive: saves report data (evidence: `core/orchestrator.py`)
- Topic orchestration → Checkpoint recovery: recovers progress (evidence: `core/orchestrator.py`)
- Topic orchestration → Email delivery: sends report (evidence: `core/orchestrator.py`)
- Topic orchestration → Archive comparison: compares archives
- Report archive → Evidence quality: summarizes coverage (evidence: `core/artifacts.py`)
- Report archive → Citation checks: validates citations (evidence: `core/artifacts.py`)
- Checkpoint recovery → Report archive: reads archive (evidence: `core/checkpoint_recovery.py`)
- Archive comparison → Report archive: reads archives (evidence: `core/archive_compare.py`)
- Archive comparison → Evidence quality: assesses evidence (evidence: `core/archive_compare.py`)
- Archive comparison → Search service: uses search utilities (evidence: `core/archive_compare.py`)
- PDF generation → Runtime settings: uses configuration (evidence: `core/report_generator.py`)
- PDF generation → Search service: uses URL utilities (evidence: `core/report_generator.py`)
- Email delivery → SMTP service: sends via SMTP (evidence: `core/email_service.py`)
