# shubham123-k/drdo-offline-ai-defence-knowledge-assistant architecture

> Architecture diagram of the GitHub repository shubham123-k/drdo-offline-ai-defence-knowledge-assistant, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant
- Repository: https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant

## Overview

DRDO AI is an offline-first assistant for asking questions grounded in clearance-authorized technical documents. Users register or sign in, then upload documents or images and ask global or attachment-scoped questions; the backend ingests and indexes content, retrieves permitted chunks, and returns grounded answers. Separate capabilities include offline voice transcription and administrator approval, user/document management, secure account recovery, and audit logs. The graph follows documented and indexed relationships; unsampled integrations are shown only where the README describes them.

Main entry points: [`backend/services/document_ingestion_service.py`](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/document_ingestion_service.py) (Document ingestion), [`backend/app/main.py`](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/app/main.py) (FastAPI application), [`backend/services/image_ingestion_service.py`](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/image_ingestion_service.py) (Image ingestion), [`backend/database/db.py`](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/database/db.py) (Relational database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Frontend"]
  node_frontend["Web application<br/>[App.jsx]"]
  node_routes["Page routing<br/>[AppRoutes.jsx]"]
  node_chat_ui["Chat experience"]
  node_chat_context["Chat state<br/>[ChatContext.jsx]"]
  node_theme["Theme settings<br/>[ThemeContext.jsx]"]
  node_signup["Account registration<br/>[SignUp.jsx]"]
  node_edit_user["User editing<br/>[EditUser.jsx]"]
  node_api["HTTP API clients"]
  node_admin_ui["Admin dashboard"]
end

subgraph group_access["Identity and API"]
  node_backend["FastAPI application<br/>[main.py]"]
  node_auth_routes["Authentication routes<br/>[auth.py]"]
  node_jwt["JWT handling<br/>[jwt_handler.py]"]
  node_auth_dependencies["Auth and clearance<br/>[dependencies.py]"]
end

subgraph group_knowledge["Document and AI"]
  node_document_routes["Document routes<br/>[document.py]"]
  node_ingestion["Document ingestion"]
  node_image_ingestion["Image ingestion"]
  node_extraction["Text extraction<br/>[text_extractor.py]"]
  node_ocr["OCR<br/>[ocr_service.py]"]
  node_vision["Visual analysis<br/>[vision_service.py]"]
  node_splitter["Text chunking<br/>[text_splitter.py]"]
  node_embedding["Embeddings"]
  node_vector_store[("Chroma vector store<br/>[chroma_service.py]")]
  node_ai_routes["AI question routes<br/>[ai.py]"]
  node_rag["Grounded retrieval and answers<br/>[rag_service.py]"]
  node_llm["Local language model<br/>[llm_service.py]"]
  node_voice["Voice transcription<br/>[voice.py]"]
end

subgraph group_operations["Administration and state"]
  node_admin_routes["Administrator operations<br/>[admin.py]"]
  node_audit["Audit logging<br/>[audit_service.py]"]
  node_db[("Relational database<br/>[db.py]")]
  node_models["User and domain records<br/>[user.py]"]
end

node_user(("User"))

node_user -->|"uses"| node_frontend
node_frontend -->|"renders"| node_routes
node_routes -->|"routes to"| node_signup
node_routes -->|"routes to"| node_edit_user
node_routes -->|"routes to"| node_chat_ui
node_chat_ui -->|"uses"| node_chat_context
node_chat_context -->|"calls"| node_api
node_frontend -->|"provides"| node_theme
node_frontend -->|"calls"| node_backend
node_backend -->|"registers"| node_auth_routes
node_backend -->|"registers"| node_document_routes
node_backend -->|"registers"| node_ai_routes
node_backend -->|"registers"| node_admin_routes
node_backend -->|"registers"| node_voice
node_auth_routes -->|"creates tokens"| node_jwt
node_auth_dependencies -->|"verifies tokens"| node_jwt
node_auth_dependencies -->|"queries users"| node_db
node_auth_routes -->|"persists accounts"| node_db
node_document_routes -->|"ingests uploads"| node_ingestion
node_document_routes -->|"stores document records"| node_db
node_ingestion -->|"extracts text"| node_extraction
node_ingestion -->|"delegates images"| node_image_ingestion
node_ingestion -->|"extracts OCR"| node_ocr
node_ingestion -->|"analyzes visuals"| node_vision
node_ingestion -->|"splits content"| node_splitter
node_image_ingestion -->|"extracts OCR"| node_ocr
node_image_ingestion -->|"analyzes visuals"| node_vision
node_image_ingestion -->|"splits content"| node_splitter
node_ingestion -->|"embeds chunks"| node_embedding
node_image_ingestion -->|"embeds chunks"| node_embedding
node_ingestion -->|"indexes chunks"| node_vector_store
node_image_ingestion -->|"indexes chunks"| node_vector_store
node_ai_routes -.->|"answers questions"| node_rag
node_rag -->|"embeds query"| node_embedding
node_rag -->|"retrieves chunks"| node_vector_store
node_rag -->|"generates answer"| node_llm
node_voice -.->|"returns transcription"| node_user
node_admin_routes -->|"manages records"| node_db
node_admin_routes -->|"records actions"| node_audit
node_admin_routes -->|"deletes document chunks"| node_vector_store
node_db -.->|"stores"| node_models
node_user -.->|"administers"| node_admin_ui
node_admin_ui -.->|"uses API"| node_api

click node_frontend "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/frontend/src/App.jsx"
click node_routes "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/frontend/src/routes/AppRoutes.jsx"
click node_chat_ui "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/tree/main/frontend/src/components/chat"
click node_chat_context "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/frontend/src/context/ChatContext.jsx"
click node_theme "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/frontend/src/context/ThemeContext.jsx"
click node_signup "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/frontend/src/pages/SignUp.jsx"
click node_edit_user "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/frontend/src/pages/EditUser.jsx"
click node_api "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/tree/main/frontend/src/api"
click node_backend "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/app/main.py"
click node_auth_routes "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/routes/auth.py"
click node_jwt "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/auth/jwt_handler.py"
click node_auth_dependencies "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/auth/dependencies.py"
click node_document_routes "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/routes/document.py"
click node_ingestion "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/document_ingestion_service.py"
click node_image_ingestion "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/image_ingestion_service.py"
click node_extraction "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/text_extractor.py"
click node_ocr "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/ocr_service.py"
click node_vision "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/vision_service.py"
click node_splitter "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/text_splitter.py"
click node_embedding "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/embedding_service.py"
click node_vector_store "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/chroma_service.py"
click node_ai_routes "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/routes/ai.py"
click node_rag "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/rag_service.py"
click node_llm "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/llm_service.py"
click node_voice "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/routes/voice.py"
click node_admin_routes "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/routes/admin.py"
click node_audit "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/audit_service.py"
click node_db "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/database/db.py"
click node_models "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/models/user.py"
click node_admin_ui "https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/tree/main/frontend/src/components/admin"

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_frontend,node_routes,node_chat_ui,node_chat_context,node_theme,node_signup,node_edit_user,node_api,node_admin_ui,node_user toneBlue
class node_backend,node_auth_routes,node_jwt,node_auth_dependencies toneAmber
class node_document_routes,node_ingestion,node_image_ingestion,node_extraction,node_ocr,node_vision,node_splitter,node_embedding,node_vector_store,node_ai_routes,node_rag,node_llm,node_voice toneMint
class node_admin_routes,node_audit,node_db,node_models toneRose
```

## Components

### Frontend

- [Web application](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Page routing](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/frontend/src/routes/AppRoutes.jsx): `frontend/src/routes/AppRoutes.jsx`
- [Chat experience](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/tree/main/frontend/src/components/chat): `frontend/src/components/chat`
- [Chat state](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/frontend/src/context/ChatContext.jsx): `frontend/src/context/ChatContext.jsx`
- [Theme settings](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/frontend/src/context/ThemeContext.jsx): `frontend/src/context/ThemeContext.jsx`
- [Account registration](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/frontend/src/pages/SignUp.jsx): `frontend/src/pages/SignUp.jsx`
- [User editing](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/frontend/src/pages/EditUser.jsx): `frontend/src/pages/EditUser.jsx`
- [HTTP API clients](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/tree/main/frontend/src/api): `frontend/src/api`
- [Admin dashboard](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/tree/main/frontend/src/components/admin): `frontend/src/components/admin`

### Identity and API

- [FastAPI application](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication routes](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/routes/auth.py): `backend/routes/auth.py`
- [JWT handling](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/auth/jwt_handler.py): `backend/auth/jwt_handler.py`
- [Auth and clearance](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/auth/dependencies.py): `backend/auth/dependencies.py`

### Document and AI

- [Document routes](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/routes/document.py): `backend/routes/document.py`
- [Document ingestion](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/document_ingestion_service.py): `backend/services/document_ingestion_service.py`
- [Image ingestion](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/image_ingestion_service.py): `backend/services/image_ingestion_service.py`
- [Text extraction](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/text_extractor.py): `backend/services/text_extractor.py`
- [OCR](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/ocr_service.py): `backend/services/ocr_service.py`
- [Visual analysis](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/vision_service.py): `backend/services/vision_service.py`
- [Text chunking](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/text_splitter.py): `backend/services/text_splitter.py`
- [Embeddings](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/embedding_service.py): `backend/services/embedding_service.py`
- [Chroma vector store](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/chroma_service.py): `backend/services/chroma_service.py`
- [AI question routes](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/routes/ai.py): `backend/routes/ai.py`
- [Grounded retrieval and answers](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/rag_service.py): `backend/services/rag_service.py`
- [Local language model](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/llm_service.py): `backend/services/llm_service.py`
- [Voice transcription](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/routes/voice.py): `backend/routes/voice.py`

### Administration and state

- [Administrator operations](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/routes/admin.py): `backend/routes/admin.py`
- [Audit logging](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/services/audit_service.py): `backend/services/audit_service.py`
- [Relational database](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/database/db.py): `backend/database/db.py`
- [User and domain records](https://github.com/shubham123-k/drdo-offline-ai-defence-knowledge-assistant/blob/main/backend/models/user.py): `backend/models/user.py`

### Other components

- **User**

## Connections

- User → Web application: uses (evidence: `README.md`)
- Web application → Page routing: renders (evidence: `frontend/src/App.jsx`)
- Page routing → Account registration: routes to (evidence: `frontend/src/routes/AppRoutes.jsx`)
- Page routing → User editing: routes to (evidence: `frontend/src/routes/AppRoutes.jsx`)
- Page routing → Chat experience: routes to (evidence: `frontend/src/routes/AppRoutes.jsx`)
- Chat experience → Chat state: uses
- Chat state → HTTP API clients: calls (evidence: `frontend/src/context/ChatContext.jsx`)
- Web application → Theme settings: provides (evidence: `frontend/src/main.jsx`)
- Web application → FastAPI application: calls (evidence: `README.md`)
- FastAPI application → Authentication routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → Document routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → AI question routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → Administrator operations: registers (evidence: `backend/app/main.py`)
- FastAPI application → Voice transcription: registers (evidence: `backend/app/main.py`)
- Authentication routes → JWT handling: creates tokens (evidence: `backend/routes/auth.py`)
- Auth and clearance → JWT handling: verifies tokens (evidence: `backend/auth/dependencies.py`)
- Auth and clearance → Relational database: queries users (evidence: `backend/auth/dependencies.py`)
- Authentication routes → Relational database: persists accounts (evidence: `backend/routes/auth.py`)
- Document routes → Document ingestion: ingests uploads (evidence: `backend/routes/document.py`)
- Document routes → Relational database: stores document records (evidence: `backend/routes/document.py`)
- Document ingestion → Text extraction: extracts text (evidence: `backend/services/document_ingestion_service.py`)
- Document ingestion → Image ingestion: delegates images (evidence: `backend/services/document_ingestion_service.py`)
- Document ingestion → OCR: extracts OCR (evidence: `backend/services/document_ingestion_service.py`)
- Document ingestion → Visual analysis: analyzes visuals (evidence: `backend/services/document_ingestion_service.py`)
- Document ingestion → Text chunking: splits content (evidence: `backend/services/document_ingestion_service.py`)
- Image ingestion → OCR: extracts OCR (evidence: `backend/services/image_ingestion_service.py`)
- Image ingestion → Visual analysis: analyzes visuals (evidence: `backend/services/image_ingestion_service.py`)
- Image ingestion → Text chunking: splits content (evidence: `backend/services/image_ingestion_service.py`)
- Document ingestion → Embeddings: embeds chunks (evidence: `backend/services/document_ingestion_service.py`)
- Image ingestion → Embeddings: embeds chunks (evidence: `backend/services/image_ingestion_service.py`)
- Document ingestion → Chroma vector store: indexes chunks (evidence: `backend/services/document_ingestion_service.py`)
- Image ingestion → Chroma vector store: indexes chunks (evidence: `backend/services/image_ingestion_service.py`)
- AI question routes → Grounded retrieval and answers: answers questions (evidence: `README.md`)
- Grounded retrieval and answers → Embeddings: embeds query
- Grounded retrieval and answers → Chroma vector store: retrieves chunks
- Grounded retrieval and answers → Local language model: generates answer (evidence: `backend/services/rag_service.py`)
- Voice transcription → User: returns transcription (evidence: `README.md`)
- Administrator operations → Relational database: manages records (evidence: `backend/routes/admin.py`)
- Administrator operations → Audit logging: records actions (evidence: `backend/routes/admin.py`)
- Administrator operations → Chroma vector store: deletes document chunks (evidence: `backend/routes/admin.py`)
- Relational database → User and domain records: stores (evidence: `README.md`)
- User → Admin dashboard: administers (evidence: `README.md`)
- Admin dashboard → HTTP API clients: uses API
