# narukavya/ai-document-intelligence architecture

> Architecture diagram of the GitHub repository narukavya/ai-document-intelligence, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/narukavya/ai-document-intelligence
- Repository: https://github.com/narukavya/ai-document-intelligence

## Overview

The product is a Streamlit document-intelligence app: users upload a PDF or DOCX, which is extracted, cleaned, chunked, embedded, and stored for later question answering; separate actions provide summaries, entities, and key information. The graph also includes the shared parsing and retrieval layers and the Gemini integration. Edges reflect shown calls, imports recorded in the source index, or README documentation; several implementation files were not excerpted, so their internal behavior is not expanded.

Main entry points: [`app/frontend/streamlit_app.py`](https://github.com/narukavya/ai-document-intelligence/blob/master/app/frontend/streamlit_app.py) (Streamlit UI), [`app/processing/document_loader.py`](https://github.com/narukavya/ai-document-intelligence/blob/master/app/processing/document_loader.py) (Document Loader), [`app/backend/process_document.py`](https://github.com/narukavya/ai-document-intelligence/blob/master/app/backend/process_document.py) (Index Document), [`app/backend/summary_service.py`](https://github.com/narukavya/ai-document-intelligence/blob/master/app/backend/summary_service.py) (Summary Service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interface"]
  node_streamlit["Streamlit UI<br/>[streamlit_app.py]"]
end

subgraph group_processing["Document Processing"]
  node_document_service["Index Document"]
  node_document_loader["Document Loader<br/>[document_loader.py]"]
  node_pdf_loader["PDF Loader<br/>[pdf_loader.py]"]
  node_docx_loader["DOCX Loader<br/>[docx_loader.py]"]
  node_cleaner["Text Cleaner<br/>[text_cleaner.py]"]
  node_chunker["Text Chunker<br/>[chunker.py]"]
end

subgraph group_intelligence["Document Intelligence"]
  node_summary_service["Summary Service<br/>[summary_service.py]"]
  node_summarizer["Summarizer<br/>[summarizer.py]"]
  node_entity_service["Entity Service<br/>[entity_service.py]"]
  node_entity_extractor["Entity Extractor"]
  node_information_service["Information Service"]
  node_information_extractor["Information Extractor"]
end

subgraph group_rag["Retrieval and Generation"]
  node_vector_store[("Vector Store<br/>[vector_store.py]")]
  node_embeddings["Embedding Model<br/>[embeddings.py]"]
  node_qa_chain["Question Answering<br/>[qa_chain.py]"]
  node_retriever["Retriever<br/>[retriever.py]"]
  node_gemini_client["Gemini Client<br/>[gemini_client.py]"]
end

node_user(("User"))
node_gemini{{"Google Gemini"}}

node_user -->|"uploads and asks"| node_streamlit
node_streamlit -->|"indexes upload"| node_document_service
node_streamlit -->|"requests summary"| node_summary_service
node_streamlit -->|"requests entities"| node_entity_service
node_streamlit -->|"requests information"| node_information_service
node_streamlit -->|"asks question"| node_qa_chain
node_document_service -->|"loads document"| node_document_loader
node_document_service -->|"cleans text"| node_cleaner
node_document_service -->|"chunks text"| node_chunker
node_document_service -->|"stores chunks"| node_vector_store
node_document_loader -->|"dispatches PDF"| node_pdf_loader
node_document_loader -->|"dispatches DOCX"| node_docx_loader
node_summary_service -->|"loads document"| node_document_loader
node_summary_service -->|"cleans text"| node_cleaner
node_summary_service -->|"generates summary"| node_summarizer
node_entity_service -->|"loads document"| node_document_loader
node_entity_service -->|"cleans text"| node_cleaner
node_entity_service -->|"extracts entities"| node_entity_extractor
node_information_service -->|"loads document"| node_document_loader
node_information_service -->|"cleans text"| node_cleaner
node_information_service -->|"extracts information"| node_information_extractor
node_information_extractor -->|"generates prompt"| node_gemini_client
node_summarizer -->|"generates summary"| node_gemini_client
node_vector_store -->|"embeds chunks"| node_embeddings
node_qa_chain -->|"retrieves context"| node_retriever
node_qa_chain -->|"generates answer"| node_gemini_client
node_retriever -->|"queries vectors"| node_vector_store
node_retriever -->|"embeds query"| node_embeddings
node_gemini_client -->|"calls model"| node_gemini

click node_streamlit "https://github.com/narukavya/ai-document-intelligence/blob/master/app/frontend/streamlit_app.py"
click node_document_service "https://github.com/narukavya/ai-document-intelligence/blob/master/app/backend/process_document.py"
click node_document_loader "https://github.com/narukavya/ai-document-intelligence/blob/master/app/processing/document_loader.py"
click node_pdf_loader "https://github.com/narukavya/ai-document-intelligence/blob/master/app/processing/pdf_loader.py"
click node_docx_loader "https://github.com/narukavya/ai-document-intelligence/blob/master/app/processing/docx_loader.py"
click node_cleaner "https://github.com/narukavya/ai-document-intelligence/blob/master/app/processing/text_cleaner.py"
click node_chunker "https://github.com/narukavya/ai-document-intelligence/blob/master/app/rag/chunker.py"
click node_summary_service "https://github.com/narukavya/ai-document-intelligence/blob/master/app/backend/summary_service.py"
click node_summarizer "https://github.com/narukavya/ai-document-intelligence/blob/master/app/summarizer/summarizer.py"
click node_entity_service "https://github.com/narukavya/ai-document-intelligence/blob/master/app/backend/entity_service.py"
click node_entity_extractor "https://github.com/narukavya/ai-document-intelligence/blob/master/app/extraction/entity_extractor.py"
click node_information_service "https://github.com/narukavya/ai-document-intelligence/blob/master/app/backend/information_service.py"
click node_information_extractor "https://github.com/narukavya/ai-document-intelligence/blob/master/app/extraction/information_extractor.py"
click node_vector_store "https://github.com/narukavya/ai-document-intelligence/blob/master/app/rag/vector_store.py"
click node_embeddings "https://github.com/narukavya/ai-document-intelligence/blob/master/app/rag/embeddings.py"
click node_qa_chain "https://github.com/narukavya/ai-document-intelligence/blob/master/app/rag/qa_chain.py"
click node_retriever "https://github.com/narukavya/ai-document-intelligence/blob/master/app/rag/retriever.py"
click node_gemini_client "https://github.com/narukavya/ai-document-intelligence/blob/master/app/rag/gemini_client.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_streamlit,node_user toneBlue
class node_document_service,node_document_loader,node_pdf_loader,node_docx_loader,node_cleaner,node_chunker toneAmber
class node_summary_service,node_summarizer,node_entity_service,node_entity_extractor,node_information_service,node_information_extractor toneMint
class node_vector_store,node_embeddings,node_qa_chain,node_retriever,node_gemini_client toneRose
class node_gemini toneIndigo
```

## Components

### User Interface

- [Streamlit UI](https://github.com/narukavya/ai-document-intelligence/blob/master/app/frontend/streamlit_app.py): `app/frontend/streamlit_app.py`

### Document Processing

- [Index Document](https://github.com/narukavya/ai-document-intelligence/blob/master/app/backend/process_document.py): `app/backend/process_document.py`
- [Document Loader](https://github.com/narukavya/ai-document-intelligence/blob/master/app/processing/document_loader.py): `app/processing/document_loader.py`
- [PDF Loader](https://github.com/narukavya/ai-document-intelligence/blob/master/app/processing/pdf_loader.py): `app/processing/pdf_loader.py`
- [DOCX Loader](https://github.com/narukavya/ai-document-intelligence/blob/master/app/processing/docx_loader.py): `app/processing/docx_loader.py`
- [Text Cleaner](https://github.com/narukavya/ai-document-intelligence/blob/master/app/processing/text_cleaner.py): `app/processing/text_cleaner.py`
- [Text Chunker](https://github.com/narukavya/ai-document-intelligence/blob/master/app/rag/chunker.py): `app/rag/chunker.py`

### Document Intelligence

- [Summary Service](https://github.com/narukavya/ai-document-intelligence/blob/master/app/backend/summary_service.py): `app/backend/summary_service.py`
- [Summarizer](https://github.com/narukavya/ai-document-intelligence/blob/master/app/summarizer/summarizer.py): `app/summarizer/summarizer.py`
- [Entity Service](https://github.com/narukavya/ai-document-intelligence/blob/master/app/backend/entity_service.py): `app/backend/entity_service.py`
- [Entity Extractor](https://github.com/narukavya/ai-document-intelligence/blob/master/app/extraction/entity_extractor.py): `app/extraction/entity_extractor.py`
- [Information Service](https://github.com/narukavya/ai-document-intelligence/blob/master/app/backend/information_service.py): `app/backend/information_service.py`
- [Information Extractor](https://github.com/narukavya/ai-document-intelligence/blob/master/app/extraction/information_extractor.py): `app/extraction/information_extractor.py`

### Retrieval and Generation

- [Vector Store](https://github.com/narukavya/ai-document-intelligence/blob/master/app/rag/vector_store.py): `app/rag/vector_store.py`
- [Embedding Model](https://github.com/narukavya/ai-document-intelligence/blob/master/app/rag/embeddings.py): `app/rag/embeddings.py`
- [Question Answering](https://github.com/narukavya/ai-document-intelligence/blob/master/app/rag/qa_chain.py): `app/rag/qa_chain.py`
- [Retriever](https://github.com/narukavya/ai-document-intelligence/blob/master/app/rag/retriever.py): `app/rag/retriever.py`
- [Gemini Client](https://github.com/narukavya/ai-document-intelligence/blob/master/app/rag/gemini_client.py): `app/rag/gemini_client.py`

### Other components

- **User**
- **Google Gemini**

## Connections

- User → Streamlit UI: uploads and asks (evidence: `app/frontend/streamlit_app.py`)
- Streamlit UI → Index Document: indexes upload (evidence: `app/frontend/streamlit_app.py`)
- Streamlit UI → Summary Service: requests summary (evidence: `app/frontend/streamlit_app.py`)
- Streamlit UI → Entity Service: requests entities (evidence: `app/frontend/streamlit_app.py`)
- Streamlit UI → Information Service: requests information (evidence: `app/frontend/streamlit_app.py`)
- Streamlit UI → Question Answering: asks question (evidence: `app/frontend/streamlit_app.py`)
- Index Document → Document Loader: loads document (evidence: `app/backend/process_document.py`)
- Index Document → Text Cleaner: cleans text (evidence: `app/backend/process_document.py`)
- Index Document → Text Chunker: chunks text (evidence: `app/backend/process_document.py`)
- Index Document → Vector Store: stores chunks (evidence: `app/backend/process_document.py`)
- Document Loader → PDF Loader: dispatches PDF (evidence: `app/processing/document_loader.py`)
- Document Loader → DOCX Loader: dispatches DOCX (evidence: `app/processing/document_loader.py`)
- Summary Service → Document Loader: loads document (evidence: `app/backend/summary_service.py`)
- Summary Service → Text Cleaner: cleans text (evidence: `app/backend/summary_service.py`)
- Summary Service → Summarizer: generates summary (evidence: `app/backend/summary_service.py`)
- Entity Service → Document Loader: loads document (evidence: `app/backend/entity_service.py`)
- Entity Service → Text Cleaner: cleans text (evidence: `app/backend/entity_service.py`)
- Entity Service → Entity Extractor: extracts entities (evidence: `app/backend/entity_service.py`)
- Information Service → Document Loader: loads document (evidence: `app/backend/information_service.py`)
- Information Service → Text Cleaner: cleans text (evidence: `app/backend/information_service.py`)
- Information Service → Information Extractor: extracts information (evidence: `app/backend/information_service.py`)
- Information Extractor → Gemini Client: generates prompt (evidence: `app/extraction/information_extractor.py`)
- Summarizer → Gemini Client: generates summary (evidence: `app/summarizer/summarizer.py`)
- Vector Store → Embedding Model: embeds chunks (evidence: `app/rag/vector_store.py`)
- Question Answering → Retriever: retrieves context (evidence: `app/rag/qa_chain.py`)
- Question Answering → Gemini Client: generates answer (evidence: `app/rag/qa_chain.py`)
- Retriever → Vector Store: queries vectors (evidence: `app/rag/retriever.py`)
- Retriever → Embedding Model: embeds query (evidence: `app/rag/retriever.py`)
- Gemini Client → Google Gemini: calls model (evidence: `app/rag/gemini_client.py`)
