# chugwanisahil-eng/astra_intel-sahil_chugwani- architecture

> Architecture diagram of the GitHub repository chugwanisahil-eng/astra_intel-sahil_chugwani-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chugwanisahil-eng/astra_intel-sahil_chugwani-
- Repository: https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-

## Overview

Astra Intel is a PDF document-intelligence application. Users upload documents, which are extracted page by page (using OCR when needed), chunked, embedded, and stored; they then search or ask questions, receiving grounded answers with page citations. Separate workflows provide summaries, comparisons, and persistent conversation management. The graph follows evidenced Flask route ownership and frontend API/state calls. README-described OCR and other capabilities are retained where their implementation exists in the tree; edges without direct source evidence are omitted.

Main entry points: [`app.py`](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/app.py) (Flask app), [`routes/document_routes.py`](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/routes/document_routes.py) (Document routes), [`services/retrieval_service.py`](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/services/retrieval_service.py) (Hybrid retrieval), [`src/context/AppContext.jsx`](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/src/context/AppContext.jsx) (App state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web workspace"]
  node_webapp["Workspace shell<br/>[App.jsx]"]
  node_appstate["App state<br/>[AppContext.jsx]"]
  node_apiclient["API client<br/>[client.js]"]
  node_workspaceui["Workspace panels<br/>[Sidebar.jsx]"]
  node_chatui["Chat and summaries<br/>[ChatPanel.jsx]"]
  node_searchui["Search panel<br/>[SearchPanel.jsx]"]
  node_pdfui["PDF viewer<br/>[PdfViewer.jsx]"]
end

subgraph group_api["Flask API"]
  node_flask["Flask app<br/>[app.py]"]
  node_documents["Document routes<br/>[document_routes.py]"]
  node_chatroutes["Chat routes<br/>[chat_routes.py]"]
  node_conversations["Conversation routes"]
  node_searchroutes["Search routes<br/>[search_routes.py]"]
  node_summaryroutes["Summary routes<br/>[summary_routes.py]"]
  node_compareroutes["Comparison routes<br/>[compare_routes.py]"]
end

subgraph group_processing["Document processing"]
  node_pdfextract["PDF extraction<br/>[pdf_service.py]"]
  node_ocr["OCR<br/>[ocr_service.py]"]
  node_chunking["Text chunking<br/>[chunk_service.py]"]
  node_embeddingstore["Embedding storage<br/>[embedding_store.py]"]
end

subgraph group_intelligence["Search and generation"]
  node_embedding["Embedding model"]
  node_retrieval["Hybrid retrieval"]
  node_llm["LLM services<br/>[llm_service.py]"]
end

subgraph group_persistence["Persistent data"]
  node_db[("SQLite database<br/>[db.py]")]
end

node_user(("User"))
node_openrouter{{"OpenRouter"}}
node_pdfstore["Uploaded PDFs"]

node_user -->|"uses"| node_webapp
node_webapp -->|"renders"| node_workspaceui
node_webapp -->|"renders"| node_pdfui
node_webapp -->|"renders"| node_chatui
node_workspaceui -->|"uses state"| node_appstate
node_chatui -->|"uses state"| node_appstate
node_searchui -->|"uses state"| node_appstate
node_pdfui -->|"uses state"| node_appstate
node_appstate -->|"calls"| node_apiclient
node_searchui -->|"searches via"| node_apiclient
node_apiclient -->|"HTTP requests"| node_flask
node_flask -->|"registers"| node_documents
node_flask -->|"registers"| node_chatroutes
node_flask -->|"registers"| node_conversations
node_flask -->|"registers"| node_searchroutes
node_flask -->|"registers"| node_summaryroutes
node_flask -->|"registers"| node_compareroutes
node_documents -->|"extracts pages"| node_pdfextract
node_pdfextract -->|"uses OCR"| node_ocr
node_documents -->|"chunks pages"| node_chunking
node_documents -->|"stores vectors"| node_embeddingstore
node_embeddingstore -->|"creates embeddings"| node_embedding
node_documents -->|"writes metadata"| node_db
node_documents -->|"saves PDF"| node_pdfstore
node_searchroutes -->|"retrieves passages"| node_retrieval
node_chatroutes -->|"retrieves context"| node_retrieval
node_conversations -->|"retrieves context"| node_retrieval
node_retrieval -->|"reads chunks"| node_db
node_retrieval -->|"embeds query"| node_embedding
node_chatroutes -->|"generates answer"| node_llm
node_conversations -->|"generates response"| node_llm
node_summaryroutes -->|"generates summary"| node_llm
node_compareroutes -->|"compares documents"| node_llm
node_llm -.->|"requests generation"| node_openrouter
node_summaryroutes -->|"reads and saves"| node_db
node_conversations -->|"persists history"| node_db
node_compareroutes -->|"loads documents"| node_db

click node_webapp "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/src/App.jsx"
click node_appstate "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/src/context/AppContext.jsx"
click node_apiclient "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/src/api/client.js"
click node_workspaceui "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/src/components/Sidebar.jsx"
click node_chatui "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/src/components/ChatPanel.jsx"
click node_searchui "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/src/components/SearchPanel.jsx"
click node_pdfui "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/src/components/PdfViewer.jsx"
click node_flask "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/app.py"
click node_documents "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/routes/document_routes.py"
click node_chatroutes "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/routes/chat_routes.py"
click node_conversations "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/routes/conversation_routes.py"
click node_searchroutes "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/routes/search_routes.py"
click node_summaryroutes "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/routes/summary_routes.py"
click node_compareroutes "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/routes/compare_routes.py"
click node_pdfextract "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/services/pdf_service.py"
click node_ocr "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/services/ocr_service.py"
click node_chunking "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/services/chunk_service.py"
click node_embeddingstore "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/services/embedding_store.py"
click node_embedding "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/services/embedding_service.py"
click node_retrieval "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/services/retrieval_service.py"
click node_llm "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/services/llm_service.py"
click node_db "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/database/db.py"
click node_pdfstore "https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/tree/main/uploads"

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_webapp,node_appstate,node_apiclient,node_workspaceui,node_chatui,node_searchui,node_pdfui,node_user toneBlue
class node_flask,node_documents,node_chatroutes,node_conversations,node_searchroutes,node_summaryroutes,node_compareroutes toneAmber
class node_pdfextract,node_ocr,node_chunking,node_embeddingstore,node_openrouter toneMint
class node_embedding,node_retrieval,node_llm toneRose
class node_db toneIndigo
class node_pdfstore toneTeal
```

## Components

### Web workspace

- [Workspace shell](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/src/App.jsx): `src/App.jsx`
- [App state](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/src/context/AppContext.jsx): `src/context/AppContext.jsx`
- [API client](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/src/api/client.js): `src/api/client.js`
- [Workspace panels](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/src/components/Sidebar.jsx): `src/components/Sidebar.jsx`
- [Chat and summaries](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/src/components/ChatPanel.jsx): `src/components/ChatPanel.jsx`
- [Search panel](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/src/components/SearchPanel.jsx): `src/components/SearchPanel.jsx`
- [PDF viewer](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/src/components/PdfViewer.jsx): `src/components/PdfViewer.jsx`

### Flask API

- [Flask app](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/app.py): `app.py`
- [Document routes](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/routes/document_routes.py): `routes/document_routes.py`
- [Chat routes](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/routes/chat_routes.py): `routes/chat_routes.py`
- [Conversation routes](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/routes/conversation_routes.py): `routes/conversation_routes.py`
- [Search routes](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/routes/search_routes.py): `routes/search_routes.py`
- [Summary routes](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/routes/summary_routes.py): `routes/summary_routes.py`
- [Comparison routes](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/routes/compare_routes.py): `routes/compare_routes.py`

### Document processing

- [PDF extraction](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/services/pdf_service.py): `services/pdf_service.py`
- [OCR](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/services/ocr_service.py): `services/ocr_service.py`
- [Text chunking](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/services/chunk_service.py): `services/chunk_service.py`
- [Embedding storage](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/services/embedding_store.py): `services/embedding_store.py`

### Search and generation

- [Embedding model](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/services/embedding_service.py): `services/embedding_service.py`
- [Hybrid retrieval](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/services/retrieval_service.py): `services/retrieval_service.py`
- [LLM services](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/services/llm_service.py): `services/llm_service.py`

### Persistent data

- [SQLite database](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/blob/main/database/db.py): `database/db.py`

### Other components

- **User**
- **OpenRouter**
- [Uploaded PDFs](https://github.com/chugwanisahil-eng/astra_intel-sahil_chugwani-/tree/main/uploads): `uploads`

## Connections

- User → Workspace shell: uses (evidence: `README.md`)
- Workspace shell → Workspace panels: renders (evidence: `src/App.jsx`)
- Workspace shell → PDF viewer: renders (evidence: `src/App.jsx`)
- Workspace shell → Chat and summaries: renders (evidence: `src/App.jsx`)
- Workspace panels → App state: uses state (evidence: `src/components/Sidebar.jsx`)
- Chat and summaries → App state: uses state (evidence: `src/components/ChatPanel.jsx`)
- Search panel → App state: uses state (evidence: `src/components/SearchPanel.jsx`)
- PDF viewer → App state: uses state (evidence: `src/components/PdfViewer.jsx`)
- App state → API client: calls (evidence: `src/context/AppContext.jsx`)
- Search panel → API client: searches via (evidence: `src/components/SearchPanel.jsx`)
- API client → Flask app: HTTP requests (evidence: `README.md`)
- Flask app → Document routes: registers (evidence: `app.py`)
- Flask app → Chat routes: registers (evidence: `app.py`)
- Flask app → Conversation routes: registers (evidence: `app.py`)
- Flask app → Search routes: registers (evidence: `app.py`)
- Flask app → Summary routes: registers (evidence: `app.py`)
- Flask app → Comparison routes: registers (evidence: `app.py`)
- Document routes → PDF extraction: extracts pages (evidence: `routes/document_routes.py`)
- PDF extraction → OCR: uses OCR (evidence: `services/pdf_service.py`)
- Document routes → Text chunking: chunks pages (evidence: `routes/document_routes.py`)
- Document routes → Embedding storage: stores vectors (evidence: `routes/document_routes.py`)
- Embedding storage → Embedding model: creates embeddings (evidence: `services/embedding_store.py`)
- Document routes → SQLite database: writes metadata (evidence: `routes/document_routes.py`)
- Document routes → Uploaded PDFs: saves PDF (evidence: `routes/document_routes.py`)
- Search routes → Hybrid retrieval: retrieves passages (evidence: `routes/search_routes.py`)
- Chat routes → Hybrid retrieval: retrieves context (evidence: `routes/chat_routes.py`)
- Conversation routes → Hybrid retrieval: retrieves context (evidence: `routes/conversation_routes.py`)
- Hybrid retrieval → SQLite database: reads chunks (evidence: `services/retrieval_service.py`)
- Hybrid retrieval → Embedding model: embeds query (evidence: `services/retrieval_service.py`)
- Chat routes → LLM services: generates answer (evidence: `routes/chat_routes.py`)
- Conversation routes → LLM services: generates response (evidence: `routes/conversation_routes.py`)
- Summary routes → LLM services: generates summary (evidence: `routes/summary_routes.py`)
- Comparison routes → LLM services: compares documents (evidence: `routes/compare_routes.py`)
- LLM services → OpenRouter: requests generation
- Summary routes → SQLite database: reads and saves (evidence: `routes/summary_routes.py`)
- Conversation routes → SQLite database: persists history (evidence: `routes/conversation_routes.py`)
- Comparison routes → SQLite database: loads documents (evidence: `routes/compare_routes.py`)
