# manoj-gif-b/silent-change-detector architecture

> Architecture diagram of the GitHub repository manoj-gif-b/silent-change-detector, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/manoj-gif-b/silent-change-detector
- Repository: https://github.com/manoj-gif-b/silent-change-detector

## Overview

Silent Change Detector investigates a company’s public disclosures and produces one evidence-backed financial finding. The principal workflow runs from document ingestion and KPI extraction through anomaly detection, hypothesis formation, adversarial review, and report assembly. A supporting layer provides arithmetic, period handling, prompts, configuration, caching, and LLM access. The repository also contains a web API and a Next.js interface; their detailed wiring is not established by the sampled backend excerpts, so those links are shown as unverified. The README documents the Streamlit dashboard, but its component internals were not sampled.

Main entry points: [`run.py`](https://github.com/manoj-gif-b/silent-change-detector/blob/main/run.py) (CLI runner), [`detectors.py`](https://github.com/manoj-gif-b/silent-change-detector/blob/main/detectors.py) (Anomaly detectors), [`hypothesis.py`](https://github.com/manoj-gif-b/silent-change-detector/blob/main/hypothesis.py) (Claim and timeline), [`scd/llm.py`](https://github.com/manoj-gif-b/silent-change-detector/blob/main/scd/llm.py) (Gemini and offline LLM)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and interface"]
  node_cli["CLI runner<br/>[run.py]"]
  node_api["Web API<br/>[api.py]"]
  node_streamlit["Streamlit dashboard<br/>[app.py]"]
  node_webui["Web interface<br/>[page.tsx]"]
  node_webclient["API client<br/>[api.ts]"]
  node_evidenceui["Evidence selection"]
end

subgraph group_research["Disclosure research"]
  node_ingest["Document ingestion<br/>[ingest.py]"]
  node_ledger[("KPI ledger<br/>[ledger.py]")]
end

subgraph group_analysis["Finding analysis"]
  node_detectors["Anomaly detectors<br/>[detectors.py]"]
  node_hypothesis["Claim and timeline<br/>[hypothesis.py]"]
  node_redteam["Adversarial review<br/>[redteam.py]"]
  node_report["Report assembly<br/>[report.py]"]
end

subgraph group_support["Shared services"]
  node_arithmetic["Verified arithmetic<br/>[arithmetic.py]"]
  node_periods["Period handling<br/>[periods.py]"]
  node_llm["Gemini and offline LLM<br/>[llm.py]"]
  node_cache[("Disk cache<br/>[cache.py]")]
  node_chunking["Chunking<br/>[chunking.py]"]
  node_pdf["PDF parsing<br/>[pdf.py]"]
  node_config["Configuration<br/>[config.py]"]
  node_prompts["LLM prompts<br/>[prompts.py]"]
  node_demo["Offline demo data<br/>[demo.py]"]
end

node_user(("Researcher"))

node_user -->|"names company"| node_cli
node_cli -->|"starts ingestion"| node_ingest
node_ingest -->|"parses PDFs"| node_pdf
node_ingest -->|"chunks text"| node_chunking
node_ingest -->|"caches downloads"| node_cache
node_cli -->|"builds ledger"| node_ledger
node_ledger -->|"extracts KPIs"| node_llm
node_cli -->|"scores anomalies"| node_detectors
node_detectors -->|"computes comparisons"| node_arithmetic
node_detectors -->|"tags narrative"| node_llm
node_detectors -->|"uses templates"| node_prompts
node_cli -->|"builds claim"| node_hypothesis
node_hypothesis -->|"ranks anomalies"| node_detectors
node_cli -->|"tests claim"| node_redteam
node_redteam -->|"challenges claim"| node_hypothesis
node_redteam -->|"assesses evidence"| node_llm
node_cli -->|"assembles report"| node_report
node_report -->|"saves finding"| node_user
node_hypothesis -->|"normalizes timeline"| node_periods
node_hypothesis -->|"phrases finding"| node_llm
node_ledger -->|"uses templates"| node_prompts
node_llm -->|"caches responses"| node_cache
node_cli -->|"enables demo"| node_demo
node_user -.->|"requests analysis"| node_api
node_api -.->|"dispatches run"| node_cli
node_api -.->|"serves reports"| node_report
node_user -.->|"uses interface"| node_webui
node_webui -.->|"requests API"| node_webclient
node_webclient -.->|"calls API"| node_api
node_webui -.->|"selects evidence"| node_evidenceui
node_streamlit -->|"shows finding"| node_report
node_cli -->|"reads settings"| node_config

click node_cli "https://github.com/manoj-gif-b/silent-change-detector/blob/main/run.py"
click node_api "https://github.com/manoj-gif-b/silent-change-detector/blob/main/api.py"
click node_streamlit "https://github.com/manoj-gif-b/silent-change-detector/blob/main/app.py"
click node_webui "https://github.com/manoj-gif-b/silent-change-detector/blob/main/web/src/app/page.tsx"
click node_webclient "https://github.com/manoj-gif-b/silent-change-detector/blob/main/web/src/lib/api.ts"
click node_evidenceui "https://github.com/manoj-gif-b/silent-change-detector/blob/main/web/src/components/evidence-context.tsx"
click node_ingest "https://github.com/manoj-gif-b/silent-change-detector/blob/main/ingest.py"
click node_ledger "https://github.com/manoj-gif-b/silent-change-detector/blob/main/ledger.py"
click node_detectors "https://github.com/manoj-gif-b/silent-change-detector/blob/main/detectors.py"
click node_hypothesis "https://github.com/manoj-gif-b/silent-change-detector/blob/main/hypothesis.py"
click node_redteam "https://github.com/manoj-gif-b/silent-change-detector/blob/main/redteam.py"
click node_report "https://github.com/manoj-gif-b/silent-change-detector/blob/main/report.py"
click node_arithmetic "https://github.com/manoj-gif-b/silent-change-detector/blob/main/scd/arithmetic.py"
click node_periods "https://github.com/manoj-gif-b/silent-change-detector/blob/main/scd/periods.py"
click node_llm "https://github.com/manoj-gif-b/silent-change-detector/blob/main/scd/llm.py"
click node_cache "https://github.com/manoj-gif-b/silent-change-detector/blob/main/scd/cache.py"
click node_chunking "https://github.com/manoj-gif-b/silent-change-detector/blob/main/scd/chunking.py"
click node_pdf "https://github.com/manoj-gif-b/silent-change-detector/blob/main/scd/pdf.py"
click node_config "https://github.com/manoj-gif-b/silent-change-detector/blob/main/scd/config.py"
click node_prompts "https://github.com/manoj-gif-b/silent-change-detector/blob/main/scd/prompts.py"
click node_demo "https://github.com/manoj-gif-b/silent-change-detector/blob/main/scd/demo.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_api,node_streamlit,node_webui,node_webclient,node_evidenceui toneBlue
class node_ingest,node_ledger toneAmber
class node_detectors,node_hypothesis,node_redteam,node_report toneMint
class node_arithmetic,node_periods,node_llm,node_cache,node_chunking,node_pdf,node_config,node_prompts,node_demo toneRose
class node_user toneIndigo
```

## Components

### Entry and interface

- [CLI runner](https://github.com/manoj-gif-b/silent-change-detector/blob/main/run.py): `run.py`
- [Web API](https://github.com/manoj-gif-b/silent-change-detector/blob/main/api.py): `api.py`
- [Streamlit dashboard](https://github.com/manoj-gif-b/silent-change-detector/blob/main/app.py): `app.py`
- [Web interface](https://github.com/manoj-gif-b/silent-change-detector/blob/main/web/src/app/page.tsx): `web/src/app/page.tsx`
- [API client](https://github.com/manoj-gif-b/silent-change-detector/blob/main/web/src/lib/api.ts): `web/src/lib/api.ts`
- [Evidence selection](https://github.com/manoj-gif-b/silent-change-detector/blob/main/web/src/components/evidence-context.tsx): `web/src/components/evidence-context.tsx`

### Disclosure research

- [Document ingestion](https://github.com/manoj-gif-b/silent-change-detector/blob/main/ingest.py): `ingest.py`
- [KPI ledger](https://github.com/manoj-gif-b/silent-change-detector/blob/main/ledger.py): `ledger.py`

### Finding analysis

- [Anomaly detectors](https://github.com/manoj-gif-b/silent-change-detector/blob/main/detectors.py): `detectors.py`
- [Claim and timeline](https://github.com/manoj-gif-b/silent-change-detector/blob/main/hypothesis.py): `hypothesis.py`
- [Adversarial review](https://github.com/manoj-gif-b/silent-change-detector/blob/main/redteam.py): `redteam.py`
- [Report assembly](https://github.com/manoj-gif-b/silent-change-detector/blob/main/report.py): `report.py`

### Shared services

- [Verified arithmetic](https://github.com/manoj-gif-b/silent-change-detector/blob/main/scd/arithmetic.py): `scd/arithmetic.py`
- [Period handling](https://github.com/manoj-gif-b/silent-change-detector/blob/main/scd/periods.py): `scd/periods.py`
- [Gemini and offline LLM](https://github.com/manoj-gif-b/silent-change-detector/blob/main/scd/llm.py): `scd/llm.py`
- [Disk cache](https://github.com/manoj-gif-b/silent-change-detector/blob/main/scd/cache.py): `scd/cache.py`
- [Chunking](https://github.com/manoj-gif-b/silent-change-detector/blob/main/scd/chunking.py): `scd/chunking.py`
- [PDF parsing](https://github.com/manoj-gif-b/silent-change-detector/blob/main/scd/pdf.py): `scd/pdf.py`
- [Configuration](https://github.com/manoj-gif-b/silent-change-detector/blob/main/scd/config.py): `scd/config.py`
- [LLM prompts](https://github.com/manoj-gif-b/silent-change-detector/blob/main/scd/prompts.py): `scd/prompts.py`
- [Offline demo data](https://github.com/manoj-gif-b/silent-change-detector/blob/main/scd/demo.py): `scd/demo.py`

### Other components

- **Researcher**

## Connections

- Researcher → CLI runner: names company (evidence: `README.md`)
- CLI runner → Document ingestion: starts ingestion (evidence: `run.py`)
- Document ingestion → PDF parsing: parses PDFs (evidence: `ingest.py`)
- Document ingestion → Chunking: chunks text (evidence: `ingest.py`)
- Document ingestion → Disk cache: caches downloads (evidence: `ingest.py`)
- CLI runner → KPI ledger: builds ledger (evidence: `run.py`)
- KPI ledger → Gemini and offline LLM: extracts KPIs (evidence: `ledger.py`)
- CLI runner → Anomaly detectors: scores anomalies (evidence: `run.py`)
- Anomaly detectors → Verified arithmetic: computes comparisons (evidence: `detectors.py`)
- Anomaly detectors → Gemini and offline LLM: tags narrative (evidence: `detectors.py`)
- Anomaly detectors → LLM prompts: uses templates (evidence: `detectors.py`)
- CLI runner → Claim and timeline: builds claim (evidence: `run.py`)
- Claim and timeline → Anomaly detectors: ranks anomalies (evidence: `hypothesis.py`)
- CLI runner → Adversarial review: tests claim (evidence: `run.py`)
- Adversarial review → Claim and timeline: challenges claim (evidence: `redteam.py`)
- Adversarial review → Gemini and offline LLM: assesses evidence (evidence: `redteam.py`)
- CLI runner → Report assembly: assembles report (evidence: `run.py`)
- Report assembly → Researcher: saves finding (evidence: `README.md`)
- Claim and timeline → Period handling: normalizes timeline (evidence: `hypothesis.py`)
- Claim and timeline → Gemini and offline LLM: phrases finding (evidence: `hypothesis.py`)
- KPI ledger → LLM prompts: uses templates (evidence: `ledger.py`)
- Gemini and offline LLM → Disk cache: caches responses (evidence: `scd/llm.py`)
- CLI runner → Offline demo data: enables demo (evidence: `run.py`)
- Researcher → Web API: requests analysis
- Web API → CLI runner: dispatches run (evidence: `api.py`)
- Web API → Report assembly: serves reports (evidence: `api.py`)
- Researcher → Web interface: uses interface
- Web interface → API client: requests API
- API client → Web API: calls API
- Web interface → Evidence selection: selects evidence
- Streamlit dashboard → Report assembly: shows finding (evidence: `README.md`)
- CLI runner → Configuration: reads settings (evidence: `run.py`)
