# v-v-sumanth-kumar/ai-knowledge-inbox architecture

> Architecture diagram of the GitHub repository v-v-sumanth-kumar/ai-knowledge-inbox, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/v-v-sumanth-kumar/ai-knowledge-inbox
- Repository: https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox

## Overview

AI Knowledge Inbox lets a user save notes or URLs, then ask questions answered from saved content with cited snippets. The documented backend flow validates and optionally scrapes content, chunks and embeds it, and stores chunks with the knowledge records; querying embeds the question, searches for similar chunks, hydrates source details, and generates an answer. The frontend exposes dashboard, knowledge-management, and streaming Ask views. Some route and UI internals are unsampled, so their links are limited to index references or README statements.

Main entry points: [`backend/app/main.py`](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/main.py) (Application setup), [`backend/app/services/ingestion_service.py`](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/services/ingestion_service.py) (Ingestion service), [`backend/app/services/rag_service.py`](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/services/rag_service.py) (RAG service), [`frontend/src/App.tsx`](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/frontend/src/App.tsx) (App routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Frontend"]
  node_app["App routes<br/>[App.tsx]"]
  node_dashboard["Dashboard<br/>[DashboardPage.tsx]"]
  node_knowledge["Knowledge manager<br/>[KnowledgePage.tsx]"]
  node_ask["Ask page<br/>[AskPage.tsx]"]
  node_knowledge_hook["Knowledge queries<br/>[useKnowledge.ts]"]
  node_ask_hook["Answer stream<br/>[useAskStream.ts]"]
  node_knowledge_api["Knowledge API<br/>[knowledge.ts]"]
  node_stream_api["SSE client<br/>[stream.ts]"]
  node_http_client["HTTP client<br/>[client.ts]"]
  node_answer_panel["Cited answers<br/>[AnswerPanel.tsx]"]
end

subgraph group_routes["API"]
  node_ingest_route["Ingest route<br/>[ingest.py]"]
  node_items_route["Items and stats<br/>[items.py]"]
  node_query_route["Query route<br/>[query.py]"]
  node_main["Application setup<br/>[main.py]"]
  node_schemas["API schemas<br/>[schemas.py]"]
end

subgraph group_ingest["Ingestion"]
  node_ingestion["Ingestion service"]
  node_scraper["URL scraper<br/>[scraper_service.py]"]
  node_chunking["Text chunking<br/>[chunking.py]"]
  node_validators["Input validation<br/>[validators.py]"]
end

subgraph group_rag["Retrieval and storage"]
  node_rag["RAG service<br/>[rag_service.py]"]
  node_embedding["Embedding service"]
  node_local_embedding["Local embeddings"]
  node_vector["Vector search<br/>[vector_service.py]"]
  node_repository["Knowledge repository"]
  node_database[("SQLite database<br/>[database.py]")]
  node_models["Knowledge records<br/>[models.py]"]
  node_llm["Chat model client<br/>[llm_client.py]"]
end

subgraph group_platform["Backend support"]
  node_config["Configuration<br/>[config.py]"]
  node_exceptions["App exceptions<br/>[exceptions.py]"]
  node_logging["Structured logging<br/>[logging.py]"]
end

node_user(("User"))
node_external_llm{{"Groq / compatible API"}}

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_knowledge
node_app -->|"routes to"| node_ask
node_dashboard -->|"loads counts"| node_knowledge_hook
node_knowledge -->|"manages items"| node_knowledge_hook
node_ask -->|"requests answers"| node_ask_hook
node_ask -->|"renders"| node_answer_panel
node_knowledge_hook -->|"calls"| node_knowledge_api
node_ask_hook -->|"streams via"| node_stream_api
node_knowledge_api -.->|"uses"| node_http_client
node_stream_api -->|"uses"| node_http_client
node_http_client -.->|"sends API request"| node_ingest_route
node_http_client -.->|"sends API request"| node_query_route
node_main -->|"registers"| node_ingest_route
node_main -->|"registers"| node_items_route
node_main -->|"registers"| node_query_route
node_ingest_route -->|"invokes"| node_ingestion
node_query_route -->|"invokes"| node_rag
node_ingestion -->|"fetches URL"| node_scraper
node_ingestion -->|"splits text"| node_chunking
node_ingestion -->|"validates input"| node_validators
node_ingestion -->|"embeds chunks"| node_embedding
node_ingestion -->|"stores chunks"| node_repository
node_rag -->|"embeds question"| node_embedding
node_rag -->|"searches vectors"| node_vector
node_rag -->|"loads sources"| node_repository
node_rag -->|"creates client"| node_llm
node_llm -.->|"calls"| node_external_llm
node_embedding -->|"selects local"| node_local_embedding
node_embedding -.->|"requests vectors"| node_external_llm
node_repository -->|"reads and writes"| node_models
node_database -->|"maps records"| node_models
node_vector -.->|"searches stored vectors"| node_models
node_main -->|"initializes"| node_database
node_main -.->|"uses responses"| node_schemas
node_main -->|"loads settings"| node_config
node_main -->|"configures"| node_logging
node_main -.->|"registers handlers"| node_exceptions
node_ingest_route -->|"accepts DTOs"| node_schemas
node_query_route -->|"returns DTOs"| node_schemas

click node_app "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/frontend/src/App.tsx"
click node_dashboard "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/frontend/src/pages/DashboardPage.tsx"
click node_knowledge "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/frontend/src/pages/KnowledgePage.tsx"
click node_ask "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/frontend/src/pages/AskPage.tsx"
click node_knowledge_hook "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/frontend/src/hooks/useKnowledge.ts"
click node_ask_hook "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/frontend/src/hooks/useAskStream.ts"
click node_knowledge_api "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/frontend/src/api/knowledge.ts"
click node_stream_api "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/frontend/src/api/stream.ts"
click node_http_client "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/frontend/src/api/client.ts"
click node_answer_panel "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/frontend/src/components/AnswerPanel.tsx"
click node_ingest_route "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/api/ingest.py"
click node_items_route "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/api/items.py"
click node_query_route "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/api/query.py"
click node_main "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/main.py"
click node_ingestion "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/services/ingestion_service.py"
click node_scraper "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/services/scraper_service.py"
click node_chunking "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/utils/chunking.py"
click node_validators "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/utils/validators.py"
click node_rag "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/services/rag_service.py"
click node_embedding "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/services/embedding_service.py"
click node_local_embedding "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/services/local_embedding_service.py"
click node_vector "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/services/vector_service.py"
click node_repository "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/repositories/knowledge_repository.py"
click node_database "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/database/database.py"
click node_models "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/database/models.py"
click node_schemas "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/database/schemas.py"
click node_llm "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/services/llm_client.py"
click node_config "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/core/config.py"
click node_exceptions "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/core/exceptions.py"
click node_logging "https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/core/logging.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,node_dashboard,node_knowledge,node_ask,node_knowledge_hook,node_ask_hook,node_knowledge_api,node_stream_api,node_http_client,node_answer_panel,node_user toneBlue
class node_ingest_route,node_items_route,node_query_route,node_main,node_schemas toneAmber
class node_ingestion,node_scraper,node_chunking,node_validators,node_external_llm toneMint
class node_rag,node_embedding,node_local_embedding,node_vector,node_repository,node_database,node_models,node_llm toneRose
class node_config,node_exceptions,node_logging toneIndigo
```

## Components

### Frontend

- [App routes](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Dashboard](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/frontend/src/pages/DashboardPage.tsx): `frontend/src/pages/DashboardPage.tsx`
- [Knowledge manager](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/frontend/src/pages/KnowledgePage.tsx): `frontend/src/pages/KnowledgePage.tsx`
- [Ask page](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/frontend/src/pages/AskPage.tsx): `frontend/src/pages/AskPage.tsx`
- [Knowledge queries](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/frontend/src/hooks/useKnowledge.ts): `frontend/src/hooks/useKnowledge.ts`
- [Answer stream](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/frontend/src/hooks/useAskStream.ts): `frontend/src/hooks/useAskStream.ts`
- [Knowledge API](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/frontend/src/api/knowledge.ts): `frontend/src/api/knowledge.ts`
- [SSE client](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/frontend/src/api/stream.ts): `frontend/src/api/stream.ts`
- [HTTP client](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [Cited answers](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/frontend/src/components/AnswerPanel.tsx): `frontend/src/components/AnswerPanel.tsx`

### API

- [Ingest route](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/api/ingest.py): `backend/app/api/ingest.py`
- [Items and stats](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/api/items.py): `backend/app/api/items.py`
- [Query route](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/api/query.py): `backend/app/api/query.py`
- [Application setup](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/main.py): `backend/app/main.py`
- [API schemas](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/database/schemas.py): `backend/app/database/schemas.py`

### Ingestion

- [Ingestion service](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/services/ingestion_service.py): `backend/app/services/ingestion_service.py`
- [URL scraper](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/services/scraper_service.py): `backend/app/services/scraper_service.py`
- [Text chunking](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/utils/chunking.py): `backend/app/utils/chunking.py`
- [Input validation](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/utils/validators.py): `backend/app/utils/validators.py`

### Retrieval and storage

- [RAG service](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/services/rag_service.py): `backend/app/services/rag_service.py`
- [Embedding service](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/services/embedding_service.py): `backend/app/services/embedding_service.py`
- [Local embeddings](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/services/local_embedding_service.py): `backend/app/services/local_embedding_service.py`
- [Vector search](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/services/vector_service.py): `backend/app/services/vector_service.py`
- [Knowledge repository](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/repositories/knowledge_repository.py): `backend/app/repositories/knowledge_repository.py`
- [SQLite database](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/database/database.py): `backend/app/database/database.py`
- [Knowledge records](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/database/models.py): `backend/app/database/models.py`
- [Chat model client](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/services/llm_client.py): `backend/app/services/llm_client.py`

### Backend support

- [Configuration](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/core/config.py): `backend/app/core/config.py`
- [App exceptions](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/core/exceptions.py): `backend/app/core/exceptions.py`
- [Structured logging](https://github.com/v-v-sumanth-kumar/ai-knowledge-inbox/blob/main/backend/app/core/logging.py): `backend/app/core/logging.py`

### Other components

- **User**
- **Groq / compatible API**

## Connections

- User → App routes: uses
- App routes → Dashboard: routes to (evidence: `frontend/src/App.tsx`)
- App routes → Knowledge manager: routes to (evidence: `frontend/src/App.tsx`)
- App routes → Ask page: routes to (evidence: `frontend/src/App.tsx`)
- Dashboard → Knowledge queries: loads counts (evidence: `frontend/src/pages/DashboardPage.tsx`)
- Knowledge manager → Knowledge queries: manages items (evidence: `frontend/src/pages/KnowledgePage.tsx`)
- Ask page → Answer stream: requests answers (evidence: `frontend/src/pages/AskPage.tsx`)
- Ask page → Cited answers: renders (evidence: `frontend/src/pages/AskPage.tsx`)
- Knowledge queries → Knowledge API: calls (evidence: `frontend/src/hooks/useKnowledge.ts`)
- Answer stream → SSE client: streams via (evidence: `frontend/src/hooks/useAskStream.ts`)
- Knowledge API → HTTP client: uses
- SSE client → HTTP client: uses (evidence: `frontend/src/api/stream.ts`)
- HTTP client → Ingest route: sends API request
- HTTP client → Query route: sends API request
- Application setup → Ingest route: registers (evidence: `backend/app/main.py`)
- Application setup → Items and stats: registers (evidence: `backend/app/main.py`)
- Application setup → Query route: registers (evidence: `backend/app/main.py`)
- Ingest route → Ingestion service: invokes (evidence: `backend/app/api/ingest.py`)
- Query route → RAG service: invokes (evidence: `backend/app/api/query.py`)
- Ingestion service → URL scraper: fetches URL (evidence: `backend/app/services/ingestion_service.py`)
- Ingestion service → Text chunking: splits text (evidence: `backend/app/services/ingestion_service.py`)
- Ingestion service → Input validation: validates input (evidence: `backend/app/services/ingestion_service.py`)
- Ingestion service → Embedding service: embeds chunks (evidence: `backend/app/services/ingestion_service.py`)
- Ingestion service → Knowledge repository: stores chunks (evidence: `backend/app/services/ingestion_service.py`)
- RAG service → Embedding service: embeds question (evidence: `backend/app/services/rag_service.py`)
- RAG service → Vector search: searches vectors (evidence: `backend/app/services/rag_service.py`)
- RAG service → Knowledge repository: loads sources (evidence: `backend/app/services/rag_service.py`)
- RAG service → Chat model client: creates client (evidence: `backend/app/services/rag_service.py`)
- Chat model client → Groq / compatible API: calls
- Embedding service → Local embeddings: selects local (evidence: `backend/app/services/embedding_service.py`)
- Embedding service → Groq / compatible API: requests vectors
- Knowledge repository → Knowledge records: reads and writes (evidence: `backend/app/repositories/knowledge_repository.py`)
- SQLite database → Knowledge records: maps records (evidence: `backend/app/database/database.py`)
- Vector search → Knowledge records: searches stored vectors (evidence: `backend/app/services/vector_service.py`)
- Application setup → SQLite database: initializes (evidence: `backend/app/main.py`)
- Application setup → API schemas: uses responses (evidence: `backend/app/main.py`)
- Application setup → Configuration: loads settings (evidence: `backend/app/main.py`)
- Application setup → Structured logging: configures (evidence: `backend/app/main.py`)
- Application setup → App exceptions: registers handlers
- Ingest route → API schemas: accepts DTOs (evidence: `backend/app/api/ingest.py`)
- Query route → API schemas: returns DTOs (evidence: `backend/app/api/query.py`)
