# nuwal01/investor-doc-finder architecture

> Architecture diagram of the GitHub repository nuwal01/investor-doc-finder, 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/nuwal01/investor-doc-finder
- Repository: https://github.com/nuwal01/investor-doc-finder

## Overview

IDF turns a company-and-year query into a verified investor-document URL: it parses and resolves the request, checks cached results, searches country-appropriate sources, verifies candidate content, then returns and caches a result. The README also documents CLI and Streamlit use, worldwide EDGAR/India/web discovery, and graceful EDGAR HTML-to-PDF conversion. The graph includes documented capabilities whose implementation was not sampled; their links are omitted where no relationship was evidenced.

Main entry points: [`agent.py`](https://github.com/nuwal01/investor-doc-finder/blob/main/agent.py) (Agent graph), [`pdf_delivery.py`](https://github.com/nuwal01/investor-doc-finder/blob/main/pdf_delivery.py) (PDF delivery), [`sources/web_search.py`](https://github.com/nuwal01/investor-doc-finder/blob/main/sources/web_search.py) (Web search), [`api.py`](https://github.com/nuwal01/investor-doc-finder/blob/main/api.py) (HTTP API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_cli["CLI<br/>[main.py]"]
  node_web_ui["Streamlit UI<br/>[streamlit_app.py]"]
  node_api["HTTP API<br/>[api.py]"]
  node_frontend["Browser frontend<br/>[app.js]"]
end

subgraph group_workflow["Agent workflow"]
  node_agent["Agent graph<br/>[agent.py]"]
  node_intent["Intent parsing<br/>[intent.py]"]
  node_llm["LLM client<br/>[llm_client.py]"]
  node_resolver["Company resolver<br/>[resolver.py]"]
  node_fund_filter["Fund filtering<br/>[fund_filter.py]"]
end

subgraph group_discovery["Document discovery"]
  node_edgar["SEC EDGAR<br/>[edgar.py]"]
  node_nse["NSE source<br/>[nse.py]"]
  node_company_site["Company site<br/>[company_site.py]"]
  node_aggregators["India aggregators<br/>[aggregators.py]"]
  node_web_search["Web search<br/>[web_search.py]"]
  node_source_contract["Source contract<br/>[base.py]"]
end

subgraph group_quality["Verification and state"]
  node_verifier["Content verifier<br/>[verify.py]"]
  node_cache[("Result cache<br/>[cache.py]")]
  node_history[("Request history<br/>[history.py]")]
  node_sweep["Cache resweep<br/>[sweep_cache.py]"]
  node_pdf_delivery["PDF delivery<br/>[pdf_delivery.py]"]
end

node_user(("User"))
node_llm_services{{"LLM providers"}}
node_sec_service{{"SEC services"}}
node_search_services{{"Search providers"}}
node_wkhtmltopdf["wkhtmltopdf"]

node_user -->|"queries"| node_cli
node_user -->|"queries"| node_web_ui
node_cli -->|"runs"| node_agent
node_web_ui -->|"runs"| node_agent
node_api -->|"invokes"| node_agent
node_agent -->|"parses"| node_intent
node_intent -->|"calls"| node_llm
node_llm -->|"requests completions"| node_llm_services
node_agent -->|"resolves company"| node_resolver
node_agent -->|"filters candidates"| node_fund_filter
node_agent -->|"checks and writes"| node_cache
node_agent -->|"fetches candidates"| node_edgar
node_agent -->|"fetches candidates"| node_nse
node_agent -->|"fetches candidates"| node_company_site
node_agent -->|"fetches candidates"| node_aggregators
node_agent -->|"fetches candidates"| node_web_search
node_company_site -->|"reuses search"| node_web_search
node_aggregators -->|"reuses search"| node_web_search
node_agent -->|"verifies candidates"| node_verifier
node_sweep -->|"rechecks cached URLs"| node_verifier
node_sweep -->|"reads and purges"| node_cache
node_pdf_delivery -->|"converts filings"| node_edgar
node_pdf_delivery -->|"renders PDF"| node_wkhtmltopdf
node_api -->|"delivers documents"| node_pdf_delivery
node_web_ui -->|"delivers documents"| node_pdf_delivery
node_api -->|"records history"| node_history
node_edgar -->|"queries filings"| node_sec_service
node_web_search -->|"searches providers"| node_search_services

click node_cli "https://github.com/nuwal01/investor-doc-finder/blob/main/main.py"
click node_web_ui "https://github.com/nuwal01/investor-doc-finder/blob/main/streamlit_app.py"
click node_api "https://github.com/nuwal01/investor-doc-finder/blob/main/api.py"
click node_frontend "https://github.com/nuwal01/investor-doc-finder/blob/main/frontend/app.js"
click node_agent "https://github.com/nuwal01/investor-doc-finder/blob/main/agent.py"
click node_intent "https://github.com/nuwal01/investor-doc-finder/blob/main/intent.py"
click node_llm "https://github.com/nuwal01/investor-doc-finder/blob/main/llm_client.py"
click node_resolver "https://github.com/nuwal01/investor-doc-finder/blob/main/resolver.py"
click node_fund_filter "https://github.com/nuwal01/investor-doc-finder/blob/main/fund_filter.py"
click node_edgar "https://github.com/nuwal01/investor-doc-finder/blob/main/sources/edgar.py"
click node_nse "https://github.com/nuwal01/investor-doc-finder/blob/main/sources/nse.py"
click node_company_site "https://github.com/nuwal01/investor-doc-finder/blob/main/sources/company_site.py"
click node_aggregators "https://github.com/nuwal01/investor-doc-finder/blob/main/sources/aggregators.py"
click node_web_search "https://github.com/nuwal01/investor-doc-finder/blob/main/sources/web_search.py"
click node_source_contract "https://github.com/nuwal01/investor-doc-finder/blob/main/sources/base.py"
click node_verifier "https://github.com/nuwal01/investor-doc-finder/blob/main/verify.py"
click node_cache "https://github.com/nuwal01/investor-doc-finder/blob/main/cache.py"
click node_history "https://github.com/nuwal01/investor-doc-finder/blob/main/history.py"
click node_sweep "https://github.com/nuwal01/investor-doc-finder/blob/main/sweep_cache.py"
click node_pdf_delivery "https://github.com/nuwal01/investor-doc-finder/blob/main/pdf_delivery.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_ui,node_api,node_frontend,node_user toneBlue
class node_agent,node_intent,node_llm,node_resolver,node_fund_filter toneAmber
class node_edgar,node_nse,node_company_site,node_aggregators,node_web_search,node_source_contract toneMint
class node_verifier,node_cache,node_history,node_sweep,node_pdf_delivery toneRose
class node_llm_services,node_sec_service,node_search_services,node_wkhtmltopdf toneIndigo
```

## Components

### User interfaces

- [CLI](https://github.com/nuwal01/investor-doc-finder/blob/main/main.py): `main.py`
- [Streamlit UI](https://github.com/nuwal01/investor-doc-finder/blob/main/streamlit_app.py): `streamlit_app.py`
- [HTTP API](https://github.com/nuwal01/investor-doc-finder/blob/main/api.py): `api.py`
- [Browser frontend](https://github.com/nuwal01/investor-doc-finder/blob/main/frontend/app.js): `frontend/app.js`

### Agent workflow

- [Agent graph](https://github.com/nuwal01/investor-doc-finder/blob/main/agent.py): `agent.py`
- [Intent parsing](https://github.com/nuwal01/investor-doc-finder/blob/main/intent.py): `intent.py`
- [LLM client](https://github.com/nuwal01/investor-doc-finder/blob/main/llm_client.py): `llm_client.py`
- [Company resolver](https://github.com/nuwal01/investor-doc-finder/blob/main/resolver.py): `resolver.py`
- [Fund filtering](https://github.com/nuwal01/investor-doc-finder/blob/main/fund_filter.py): `fund_filter.py`

### Document discovery

- [SEC EDGAR](https://github.com/nuwal01/investor-doc-finder/blob/main/sources/edgar.py): `sources/edgar.py`
- [NSE source](https://github.com/nuwal01/investor-doc-finder/blob/main/sources/nse.py): `sources/nse.py`
- [Company site](https://github.com/nuwal01/investor-doc-finder/blob/main/sources/company_site.py): `sources/company_site.py`
- [India aggregators](https://github.com/nuwal01/investor-doc-finder/blob/main/sources/aggregators.py): `sources/aggregators.py`
- [Web search](https://github.com/nuwal01/investor-doc-finder/blob/main/sources/web_search.py): `sources/web_search.py`
- [Source contract](https://github.com/nuwal01/investor-doc-finder/blob/main/sources/base.py): `sources/base.py`

### Verification and state

- [Content verifier](https://github.com/nuwal01/investor-doc-finder/blob/main/verify.py): `verify.py`
- [Result cache](https://github.com/nuwal01/investor-doc-finder/blob/main/cache.py): `cache.py`
- [Request history](https://github.com/nuwal01/investor-doc-finder/blob/main/history.py): `history.py`
- [Cache resweep](https://github.com/nuwal01/investor-doc-finder/blob/main/sweep_cache.py): `sweep_cache.py`
- [PDF delivery](https://github.com/nuwal01/investor-doc-finder/blob/main/pdf_delivery.py): `pdf_delivery.py`

### Other components

- **User**
- **LLM providers**
- **SEC services**
- **Search providers**
- **wkhtmltopdf**

## Connections

- User → CLI: queries (evidence: `README.md`)
- User → Streamlit UI: queries (evidence: `README.md`)
- CLI → Agent graph: runs (evidence: `main.py`)
- Streamlit UI → Agent graph: runs (evidence: `streamlit_app.py`)
- HTTP API → Agent graph: invokes (evidence: `api.py`)
- Agent graph → Intent parsing: parses (evidence: `agent.py`)
- Intent parsing → LLM client: calls (evidence: `intent.py`)
- LLM client → LLM providers: requests completions (evidence: `llm_client.py`)
- Agent graph → Company resolver: resolves company (evidence: `agent.py`)
- Agent graph → Fund filtering: filters candidates (evidence: `agent.py`)
- Agent graph → Result cache: checks and writes (evidence: `agent.py`)
- Agent graph → SEC EDGAR: fetches candidates (evidence: `agent.py`)
- Agent graph → NSE source: fetches candidates (evidence: `agent.py`)
- Agent graph → Company site: fetches candidates (evidence: `agent.py`)
- Agent graph → India aggregators: fetches candidates (evidence: `agent.py`)
- Agent graph → Web search: fetches candidates (evidence: `agent.py`)
- Company site → Web search: reuses search (evidence: `sources/company_site.py`)
- India aggregators → Web search: reuses search (evidence: `sources/aggregators.py`)
- Agent graph → Content verifier: verifies candidates (evidence: `agent.py`)
- Cache resweep → Content verifier: rechecks cached URLs (evidence: `sweep_cache.py`)
- Cache resweep → Result cache: reads and purges (evidence: `sweep_cache.py`)
- PDF delivery → SEC EDGAR: converts filings (evidence: `pdf_delivery.py`)
- PDF delivery → wkhtmltopdf: renders PDF (evidence: `README.md`)
- HTTP API → PDF delivery: delivers documents (evidence: `api.py`)
- Streamlit UI → PDF delivery: delivers documents (evidence: `streamlit_app.py`)
- HTTP API → Request history: records history (evidence: `api.py`)
- SEC EDGAR → SEC services: queries filings (evidence: `sources/edgar.py`)
- Web search → Search providers: searches providers (evidence: `sources/web_search.py`)
