# darkveteran28/doc_analyzer architecture

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

- Interactive diagram: https://gitdiagram.com/darkveteran28/doc_analyzer
- Repository: https://github.com/darkveteran28/doc_analyzer

## Overview

Doc Analyzer is a PDF upload and question-answering product: users submit a document, then ask questions and receive generated answers with page-level sources. Its documented RAG path extracts page text, chunks it, indexes it in both semantic and keyword stores, retrieves according to vector/BM25/hybrid mode, fuses hybrid rankings, and generates an answer. The frontend and FastAPI entry point are represented, but route implementations and their connection to the RAG service were not sampled; those links are therefore omitted. The RAG orchestration and retrieval wiring are supported by sampled source and the README.

Main entry points: [`rag/rag_pipeline.py`](https://github.com/darkveteran28/doc_analyzer/blob/main/rag/rag_pipeline.py) (RAG orchestration), [`rag/retrieval.py`](https://github.com/darkveteran28/doc_analyzer/blob/main/rag/retrieval.py) (Mode selection and retrieval), [`Frontend/src/App.jsx`](https://github.com/darkveteran28/doc_analyzer/blob/main/Frontend/src/App.jsx) (Upload and analysis UI), [`app/main.py`](https://github.com/darkveteran28/doc_analyzer/blob/main/app/main.py) (API application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web frontend"]
  node_app_ui["Upload and analysis UI<br/>[App.jsx]"]
  node_upload_widget["File upload<br/>[FileUpload.jsx]"]
  node_analysis_page["Analysis page<br/>[AnalysisPage.jsx]"]
  node_web_api["API client<br/>[api.js]"]
end

subgraph group_api["HTTP API"]
  node_fastapi["API application<br/>[main.py]"]
  node_document_routes["Document routes<br/>[documents.py]"]
  node_chat_routes["Chat routes<br/>[chat.py]"]
  node_document_service["Document operations"]
end

subgraph group_rag["RAG pipeline"]
  node_pdf_extract["PDF extraction<br/>[ingestion.py]"]
  node_chunking["Page chunking<br/>[chunking.py]"]
  node_pipeline["RAG orchestration<br/>[rag_pipeline.py]"]
  node_retrieval["Mode selection and retrieval<br/>[retrieval.py]"]
  node_fusion["Rank fusion<br/>[fusion.py]"]
  node_generation["Answer generation<br/>[generation.py]"]
  node_sources["Page citations<br/>[sources.py]"]
end

subgraph group_storage["Stores and models"]
  node_embedding_model["MiniLM embeddings<br/>[embeddings.py]"]
  node_vector_store[("Chroma vector store<br/>[vector_store.py]")]
  node_bm25_index[("BM25 index<br/>[bm25.py]")]
  node_document_db[("Document metadata DB<br/>[database.py]")]
end

node_user(("Document user"))
node_ollama["Ollama LLM"]

node_user -->|"selects PDF"| node_upload_widget
node_upload_widget -->|"submits file"| node_app_ui
node_app_ui -->|"uploads document"| node_web_api
node_web_api -->|"HTTP requests"| node_fastapi
node_fastapi -->|"dispatches"| node_document_routes
node_fastapi -->|"dispatches"| node_chat_routes
node_document_routes -->|"document operations"| node_document_service
node_document_service -->|"reads and writes"| node_document_db
node_chat_routes -->|"database access"| node_document_db
node_app_ui -->|"shows analysis"| node_analysis_page
node_user -->|"asks questions"| node_analysis_page
node_pipeline -->|"extracts pages"| node_pdf_extract
node_pipeline -->|"creates chunks"| node_chunking
node_pipeline -->|"embeds chunks"| node_embedding_model
node_pipeline -->|"stores chunks"| node_vector_store
node_pipeline -->|"indexes chunks"| node_bm25_index
node_pipeline -->|"requests results"| node_retrieval
node_retrieval -->|"embeds query"| node_embedding_model
node_retrieval -->|"queries vectors"| node_vector_store
node_retrieval -->|"queries keywords"| node_bm25_index
node_retrieval -->|"fuses rankings"| node_fusion
node_pipeline -->|"generates answer"| node_generation
node_generation -->|"sends prompt"| node_ollama
node_pipeline -->|"builds citations"| node_sources

click node_app_ui "https://github.com/darkveteran28/doc_analyzer/blob/main/Frontend/src/App.jsx"
click node_upload_widget "https://github.com/darkveteran28/doc_analyzer/blob/main/Frontend/src/components/FileUpload.jsx"
click node_analysis_page "https://github.com/darkveteran28/doc_analyzer/blob/main/Frontend/src/pages/AnalysisPage.jsx"
click node_web_api "https://github.com/darkveteran28/doc_analyzer/blob/main/Frontend/src/services/api.js"
click node_fastapi "https://github.com/darkveteran28/doc_analyzer/blob/main/app/main.py"
click node_document_routes "https://github.com/darkveteran28/doc_analyzer/blob/main/app/routes/documents.py"
click node_chat_routes "https://github.com/darkveteran28/doc_analyzer/blob/main/app/routes/chat.py"
click node_document_service "https://github.com/darkveteran28/doc_analyzer/blob/main/app/services/document_service.py"
click node_pdf_extract "https://github.com/darkveteran28/doc_analyzer/blob/main/rag/ingestion.py"
click node_chunking "https://github.com/darkveteran28/doc_analyzer/blob/main/rag/chunking.py"
click node_pipeline "https://github.com/darkveteran28/doc_analyzer/blob/main/rag/rag_pipeline.py"
click node_retrieval "https://github.com/darkveteran28/doc_analyzer/blob/main/rag/retrieval.py"
click node_fusion "https://github.com/darkveteran28/doc_analyzer/blob/main/rag/fusion.py"
click node_generation "https://github.com/darkveteran28/doc_analyzer/blob/main/rag/generation.py"
click node_sources "https://github.com/darkveteran28/doc_analyzer/blob/main/rag/sources.py"
click node_embedding_model "https://github.com/darkveteran28/doc_analyzer/blob/main/rag/embeddings.py"
click node_vector_store "https://github.com/darkveteran28/doc_analyzer/blob/main/rag/vector_store.py"
click node_bm25_index "https://github.com/darkveteran28/doc_analyzer/blob/main/rag/bm25.py"
click node_document_db "https://github.com/darkveteran28/doc_analyzer/blob/main/app/database/database.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_app_ui,node_upload_widget,node_analysis_page,node_web_api,node_user toneBlue
class node_fastapi,node_document_routes,node_chat_routes,node_document_service toneAmber
class node_pdf_extract,node_chunking,node_pipeline,node_retrieval,node_fusion,node_generation,node_sources toneMint
class node_embedding_model,node_vector_store,node_bm25_index,node_document_db toneRose
class node_ollama toneIndigo
```

## Components

### Web frontend

- [Upload and analysis UI](https://github.com/darkveteran28/doc_analyzer/blob/main/Frontend/src/App.jsx): `Frontend/src/App.jsx`
- [File upload](https://github.com/darkveteran28/doc_analyzer/blob/main/Frontend/src/components/FileUpload.jsx): `Frontend/src/components/FileUpload.jsx`
- [Analysis page](https://github.com/darkveteran28/doc_analyzer/blob/main/Frontend/src/pages/AnalysisPage.jsx): `Frontend/src/pages/AnalysisPage.jsx`
- [API client](https://github.com/darkveteran28/doc_analyzer/blob/main/Frontend/src/services/api.js): `Frontend/src/services/api.js`

### HTTP API

- [API application](https://github.com/darkveteran28/doc_analyzer/blob/main/app/main.py): `app/main.py`
- [Document routes](https://github.com/darkveteran28/doc_analyzer/blob/main/app/routes/documents.py): `app/routes/documents.py`
- [Chat routes](https://github.com/darkveteran28/doc_analyzer/blob/main/app/routes/chat.py): `app/routes/chat.py`
- [Document operations](https://github.com/darkveteran28/doc_analyzer/blob/main/app/services/document_service.py): `app/services/document_service.py`

### RAG pipeline

- [PDF extraction](https://github.com/darkveteran28/doc_analyzer/blob/main/rag/ingestion.py): `rag/ingestion.py`
- [Page chunking](https://github.com/darkveteran28/doc_analyzer/blob/main/rag/chunking.py): `rag/chunking.py`
- [RAG orchestration](https://github.com/darkveteran28/doc_analyzer/blob/main/rag/rag_pipeline.py): `rag/rag_pipeline.py`
- [Mode selection and retrieval](https://github.com/darkveteran28/doc_analyzer/blob/main/rag/retrieval.py): `rag/retrieval.py`
- [Rank fusion](https://github.com/darkveteran28/doc_analyzer/blob/main/rag/fusion.py): `rag/fusion.py`
- [Answer generation](https://github.com/darkveteran28/doc_analyzer/blob/main/rag/generation.py): `rag/generation.py`
- [Page citations](https://github.com/darkveteran28/doc_analyzer/blob/main/rag/sources.py): `rag/sources.py`

### Stores and models

- [MiniLM embeddings](https://github.com/darkveteran28/doc_analyzer/blob/main/rag/embeddings.py): `rag/embeddings.py`
- [Chroma vector store](https://github.com/darkveteran28/doc_analyzer/blob/main/rag/vector_store.py): `rag/vector_store.py`
- [BM25 index](https://github.com/darkveteran28/doc_analyzer/blob/main/rag/bm25.py): `rag/bm25.py`
- [Document metadata DB](https://github.com/darkveteran28/doc_analyzer/blob/main/app/database/database.py): `app/database/database.py`

### Other components

- **Document user**
- **Ollama LLM**

## Connections

- Document user → File upload: selects PDF
- File upload → Upload and analysis UI: submits file
- Upload and analysis UI → API client: uploads document
- API client → API application: HTTP requests
- API application → Document routes: dispatches
- API application → Chat routes: dispatches
- Document routes → Document operations: document operations
- Document operations → Document metadata DB: reads and writes
- Chat routes → Document metadata DB: database access
- Upload and analysis UI → Analysis page: shows analysis
- Document user → Analysis page: asks questions
- RAG orchestration → PDF extraction: extracts pages
- RAG orchestration → Page chunking: creates chunks
- RAG orchestration → MiniLM embeddings: embeds chunks
- RAG orchestration → Chroma vector store: stores chunks
- RAG orchestration → BM25 index: indexes chunks
- RAG orchestration → Mode selection and retrieval: requests results
- Mode selection and retrieval → MiniLM embeddings: embeds query
- Mode selection and retrieval → Chroma vector store: queries vectors
- Mode selection and retrieval → BM25 index: queries keywords
- Mode selection and retrieval → Rank fusion: fuses rankings
- RAG orchestration → Answer generation: generates answer
- Answer generation → Ollama LLM: sends prompt
- RAG orchestration → Page citations: builds citations
