# bhumikaaggwl/findoc-analyzer architecture

> Architecture diagram of the GitHub repository bhumikaaggwl/findoc-analyzer, 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/bhumikaaggwl/findoc-analyzer
- Repository: https://github.com/bhumikaaggwl/findoc-analyzer

## Overview

FinDoc AI ingests financial filings into two complementary stores: page-tagged text chunks for semantic retrieval and structured metrics and ratios in SQLite. Users select a filing, ask a question, and receive an answer grounded in retrieved pages; they can also view stored metrics and ratios and request an investment recommendation. Batch ingestion orchestrates extraction, chunking, embedding, analysis, and persistence. The README also documents section-wise analyst commentary. Edges are limited to relationships supported by the README or indexed source references; unsampled implementations are not treated as inspected.

Main entry points: [`scripts/ingest_all.py`](https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/scripts/ingest_all.py) (Batch Ingestion), [`app/Home.py`](https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/app/Home.py) (Streamlit Chat UI), [`src/rag/retriever.py`](https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/src/rag/retriever.py) (Semantic Retriever), [`src/rag/rag_pipeline.py`](https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/src/rag/rag_pipeline.py) (RAG Answer Pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Filing Ingestion"]
  node_batch_ingest["Batch Ingestion<br/>[ingest_all.py]"]
  node_extractor["Document Extractor"]
  node_chunker["Text Chunker<br/>[chunker.py]"]
end

subgraph group_retrieval["Evidence Retrieval"]
  node_embedding["Embedding Engine"]
  node_vector_store["Vector Store<br/>[vector_store.py]"]
  node_retriever["Semantic Retriever<br/>[retriever.py]"]
  node_rag["RAG Answer Pipeline<br/>[rag_pipeline.py]"]
end

subgraph group_analysis["Financial Analysis"]
  node_metrics["Metrics Extractor"]
  node_ratios["Ratio Calculator"]
  node_insights["Section Insights"]
  node_recommender["Investment Recommender"]
end

subgraph group_persistence["Data Persistence"]
  node_orm["SQL Data Models<br/>[models.py]"]
  node_repository["SQL Repository<br/>[repository.py]"]
  node_sqlite[("SQLite Database<br/>[findoc.db]")]
end

subgraph group_experience["Research Experience"]
  node_ui["Streamlit Chat UI<br/>[Home.py]"]
end

node_filing_source["Filing Files"]
node_gemini{{"Gemini API"}}
node_chroma[("ChromaDB")]
node_groq{{"Groq LLM API"}}
node_researcher(("Researcher"))

node_filing_source -->|"ingests files"| node_batch_ingest
node_batch_ingest -->|"extracts pages"| node_extractor
node_batch_ingest -->|"chunks pages"| node_chunker
node_batch_ingest -->|"embeds chunks"| node_embedding
node_embedding -->|"requests embeddings"| node_gemini
node_batch_ingest -->|"stores chunks"| node_vector_store
node_vector_store -->|"persists vectors"| node_chroma
node_batch_ingest -->|"extracts metrics"| node_metrics
node_batch_ingest -->|"calculates ratios"| node_ratios
node_batch_ingest -->|"saves records"| node_repository
node_repository -->|"uses models"| node_orm
node_orm -->|"stores structured data"| node_sqlite
node_researcher -->|"asks questions"| node_ui
node_ui -->|"loads filings and figures"| node_repository
node_ui -->|"submits question"| node_rag
node_rag -->|"builds context"| node_retriever
node_retriever -->|"embeds query"| node_embedding
node_retriever -->|"searches chunks"| node_vector_store
node_rag -->|"generates answer"| node_groq
node_ui -->|"requests recommendation"| node_recommender
node_recommender -->|"retrieves evidence"| node_retriever
node_ui -.->|"shows commentary"| node_insights

click node_batch_ingest "https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/scripts/ingest_all.py"
click node_extractor "https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/src/document_processing/document_extractor.py"
click node_chunker "https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/src/document_processing/chunker.py"
click node_embedding "https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/src/embeddings/embedding_engine.py"
click node_vector_store "https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/src/embeddings/vector_store.py"
click node_retriever "https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/src/rag/retriever.py"
click node_rag "https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/src/rag/rag_pipeline.py"
click node_metrics "https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/src/financial_analysis/metrics_extractor.py"
click node_ratios "https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/src/financial_analysis/ratio_calculator.py"
click node_insights "https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/src/analysis_engine/insight_generator.py"
click node_recommender "https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/src/analysis_engine/investment_recommender.py"
click node_orm "https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/database/models.py"
click node_repository "https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/database/repository.py"
click node_sqlite "https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/data/findoc.db"
click node_ui "https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/app/Home.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_batch_ingest,node_extractor,node_chunker toneBlue
class node_embedding,node_vector_store,node_retriever,node_rag,node_chroma toneAmber
class node_metrics,node_ratios,node_insights,node_recommender,node_gemini,node_groq toneMint
class node_orm,node_repository,node_sqlite toneRose
class node_ui,node_filing_source,node_researcher toneIndigo
```

## Components

### Filing Ingestion

- [Batch Ingestion](https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/scripts/ingest_all.py): `scripts/ingest_all.py`
- [Document Extractor](https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/src/document_processing/document_extractor.py): `src/document_processing/document_extractor.py`
- [Text Chunker](https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/src/document_processing/chunker.py): `src/document_processing/chunker.py`

### Evidence Retrieval

- [Embedding Engine](https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/src/embeddings/embedding_engine.py): `src/embeddings/embedding_engine.py`
- [Vector Store](https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/src/embeddings/vector_store.py): `src/embeddings/vector_store.py`
- [Semantic Retriever](https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/src/rag/retriever.py): `src/rag/retriever.py`
- [RAG Answer Pipeline](https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/src/rag/rag_pipeline.py): `src/rag/rag_pipeline.py`

### Financial Analysis

- [Metrics Extractor](https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/src/financial_analysis/metrics_extractor.py): `src/financial_analysis/metrics_extractor.py`
- [Ratio Calculator](https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/src/financial_analysis/ratio_calculator.py): `src/financial_analysis/ratio_calculator.py`
- [Section Insights](https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/src/analysis_engine/insight_generator.py): `src/analysis_engine/insight_generator.py`
- [Investment Recommender](https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/src/analysis_engine/investment_recommender.py): `src/analysis_engine/investment_recommender.py`

### Data Persistence

- [SQL Data Models](https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/database/models.py): `database/models.py`
- [SQL Repository](https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/database/repository.py): `database/repository.py`
- [SQLite Database](https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/data/findoc.db): `data/findoc.db`

### Research Experience

- [Streamlit Chat UI](https://github.com/bhumikaaggwl/findoc-analyzer/blob/main/app/Home.py): `app/Home.py`

### Other components

- **Filing Files**
- **Gemini API**
- **ChromaDB**
- **Groq LLM API**
- **Researcher**

## Connections

- Filing Files → Batch Ingestion: ingests files (evidence: `README.md`)
- Batch Ingestion → Document Extractor: extracts pages (evidence: `scripts/ingest_all.py`)
- Batch Ingestion → Text Chunker: chunks pages (evidence: `scripts/ingest_all.py`)
- Batch Ingestion → Embedding Engine: embeds chunks (evidence: `scripts/ingest_all.py`)
- Embedding Engine → Gemini API: requests embeddings (evidence: `src/embeddings/embedding_engine.py`)
- Batch Ingestion → Vector Store: stores chunks (evidence: `scripts/ingest_all.py`)
- Vector Store → ChromaDB: persists vectors (evidence: `README.md`)
- Batch Ingestion → Metrics Extractor: extracts metrics (evidence: `scripts/ingest_all.py`)
- Batch Ingestion → Ratio Calculator: calculates ratios (evidence: `scripts/ingest_all.py`)
- Batch Ingestion → SQL Repository: saves records (evidence: `scripts/ingest_all.py`)
- SQL Repository → SQL Data Models: uses models (evidence: `database/repository.py`)
- SQL Data Models → SQLite Database: stores structured data (evidence: `database/models.py`)
- Researcher → Streamlit Chat UI: asks questions (evidence: `README.md`)
- Streamlit Chat UI → SQL Repository: loads filings and figures (evidence: `app/Home.py`)
- Streamlit Chat UI → RAG Answer Pipeline: submits question (evidence: `app/Home.py`)
- RAG Answer Pipeline → Semantic Retriever: builds context (evidence: `src/rag/rag_pipeline.py`)
- Semantic Retriever → Embedding Engine: embeds query (evidence: `src/rag/retriever.py`)
- Semantic Retriever → Vector Store: searches chunks (evidence: `src/rag/retriever.py`)
- RAG Answer Pipeline → Groq LLM API: generates answer (evidence: `README.md`)
- Streamlit Chat UI → Investment Recommender: requests recommendation (evidence: `app/Home.py`)
- Investment Recommender → Semantic Retriever: retrieves evidence (evidence: `src/analysis_engine/investment_recommender.py`)
- Streamlit Chat UI → Section Insights: shows commentary (evidence: `README.md`)
