# zinia94/querydesk_ai_semantic_search architecture

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

- Interactive diagram: https://gitdiagram.com/zinia94/querydesk_ai_semantic_search
- Repository: https://github.com/zinia94/querydesk_ai_semantic_search

## Overview

QueryDesk AI lets employees upload internal text or PDF/DOCX documents, search them semantically with department filtering, open full documents, and delete them. The principal workflow runs from the React Home screen through FastAPI endpoints to document extraction/chunking, embedding, and Elasticsearch; search embeds the query and retrieves ranked chunks. Startup creates the index and can seed sample documents. The graph preserves the documented upload, retrieval, deletion, and UI capabilities. Source excerpts show the main calls; unsampled frontend and backend details are not inferred.

Main entry points: [`backend/app/api/search.py`](https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/api/search.py) (Document API), [`frontend/src/pages/Home.tsx`](https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/frontend/src/pages/Home.tsx) (Search and manage), [`backend/app/main.py`](https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/main.py) (FastAPI startup), [`backend/app/services/utils.py`](https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/services/utils.py) (Chunk and index)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Employee interface"]
  node_app_shell["App navigation<br/>[App.tsx]"]
  node_home["Search and manage<br/>[Home.tsx]"]
  node_about["About page<br/>[About.tsx]"]
end

subgraph group_api["HTTP application"]
  node_server["FastAPI startup<br/>[main.py]"]
  node_settings["Runtime settings<br/>[config.py]"]
  node_routes["Document API<br/>[search.py]"]
  node_contracts["Request and result models<br/>[models.py]"]
end

subgraph group_ingestion["Document ingestion"]
  node_file_extract["File extraction<br/>[utils.py]"]
  node_chunk_index["Chunk and index<br/>[utils.py]"]
  node_seed_docs["Seed documents<br/>[seed_data.py]"]
end

subgraph group_search["Semantic search"]
  node_embedding["Text embeddings<br/>[embedding.py]"]
  node_search_ops["Vector search<br/>[elastic.py]"]
end

subgraph group_storage["Document storage"]
  node_document_ops["Document retrieval and deletion<br/>[elastic.py]"]
  node_index_ops["Index management<br/>[elastic.py]"]
end

node_employee(("Employee"))
node_elasticsearch[("Elasticsearch")]

node_employee -->|"uses"| node_home
node_app_shell -->|"routes to"| node_home
node_app_shell -->|"routes to"| node_about
node_home -->|"calls search and upload"| node_routes
node_home -->|"requests full document"| node_routes
node_home -->|"requests deletion"| node_routes
node_server -->|"registers router"| node_routes
node_server -->|"reads settings"| node_settings
node_server -->|"checks and creates index"| node_index_ops
node_server -->|"optionally seeds"| node_seed_docs
node_routes -->|"uses request models"| node_contracts
node_routes -->|"extracts uploaded files"| node_file_extract
node_routes -->|"processes uploaded text"| node_chunk_index
node_routes -->|"embeds query"| node_embedding
node_routes -->|"searches documents"| node_search_ops
node_routes -->|"retrieves or deletes"| node_document_ops
node_seed_docs -->|"processes seed text"| node_chunk_index
node_chunk_index -->|"embeds chunks"| node_embedding
node_chunk_index -->|"indexes chunks"| node_index_ops
node_embedding -->|"selects model"| node_settings
node_search_ops -->|"queries index"| node_elasticsearch
node_document_ops -->|"reads and deletes"| node_elasticsearch
node_index_ops -->|"manages index"| node_elasticsearch
node_search_ops -->|"uses index config"| node_settings

click node_app_shell "https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/frontend/src/App.tsx"
click node_home "https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/frontend/src/pages/Home.tsx"
click node_about "https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/frontend/src/pages/About.tsx"
click node_server "https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/main.py"
click node_settings "https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/config.py"
click node_routes "https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/api/search.py"
click node_contracts "https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/models.py"
click node_file_extract "https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/services/utils.py"
click node_chunk_index "https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/services/utils.py"
click node_seed_docs "https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/seed_data.py"
click node_embedding "https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/services/embedding.py"
click node_search_ops "https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/services/elastic.py"
click node_document_ops "https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/services/elastic.py"
click node_index_ops "https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/services/elastic.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_shell,node_home,node_about toneBlue
class node_server,node_settings,node_routes,node_contracts,node_elasticsearch toneAmber
class node_file_extract,node_chunk_index,node_seed_docs toneMint
class node_embedding,node_search_ops toneRose
class node_document_ops,node_index_ops,node_employee toneIndigo
```

## Components

### Employee interface

- [App navigation](https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Search and manage](https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/frontend/src/pages/Home.tsx): `frontend/src/pages/Home.tsx`
- [About page](https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/frontend/src/pages/About.tsx): `frontend/src/pages/About.tsx`

### HTTP application

- [FastAPI startup](https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/main.py): `backend/app/main.py`
- [Runtime settings](https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/config.py): `backend/app/config.py`
- [Document API](https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/api/search.py): `backend/app/api/search.py`
- [Request and result models](https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/models.py): `backend/app/models.py`

### Document ingestion

- [File extraction](https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/services/utils.py): `backend/app/services/utils.py`
- [Chunk and index](https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/services/utils.py): `backend/app/services/utils.py`
- [Seed documents](https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/seed_data.py): `backend/app/seed_data.py`

### Semantic search

- [Text embeddings](https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/services/embedding.py): `backend/app/services/embedding.py`
- [Vector search](https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/services/elastic.py): `backend/app/services/elastic.py`

### Document storage

- [Document retrieval and deletion](https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/services/elastic.py): `backend/app/services/elastic.py`
- [Index management](https://github.com/zinia94/querydesk_ai_semantic_search/blob/main/backend/app/services/elastic.py): `backend/app/services/elastic.py`

### Other components

- **Employee**
- **Elasticsearch**

## Connections

- Employee → Search and manage: uses (evidence: `README.md`)
- App navigation → Search and manage: routes to (evidence: `frontend/src/App.tsx`)
- App navigation → About page: routes to (evidence: `frontend/src/App.tsx`)
- Search and manage → Document API: calls search and upload (evidence: `frontend/src/pages/Home.tsx`)
- Search and manage → Document API: requests full document (evidence: `frontend/src/pages/Home.tsx`)
- Search and manage → Document API: requests deletion (evidence: `frontend/src/pages/Home.tsx`)
- FastAPI startup → Document API: registers router (evidence: `backend/app/main.py`)
- FastAPI startup → Runtime settings: reads settings (evidence: `backend/app/main.py`)
- FastAPI startup → Index management: checks and creates index (evidence: `backend/app/main.py`)
- FastAPI startup → Seed documents: optionally seeds (evidence: `backend/app/main.py`)
- Document API → Request and result models: uses request models (evidence: `backend/app/api/search.py`)
- Document API → File extraction: extracts uploaded files (evidence: `backend/app/api/search.py`)
- Document API → Chunk and index: processes uploaded text (evidence: `backend/app/api/search.py`)
- Document API → Text embeddings: embeds query (evidence: `backend/app/api/search.py`)
- Document API → Vector search: searches documents (evidence: `backend/app/api/search.py`)
- Document API → Document retrieval and deletion: retrieves or deletes (evidence: `backend/app/api/search.py`)
- Seed documents → Chunk and index: processes seed text (evidence: `backend/app/seed_data.py`)
- Chunk and index → Text embeddings: embeds chunks (evidence: `backend/app/services/utils.py`)
- Chunk and index → Index management: indexes chunks (evidence: `backend/app/services/utils.py`)
- Text embeddings → Runtime settings: selects model (evidence: `backend/app/services/embedding.py`)
- Vector search → Elasticsearch: queries index (evidence: `backend/app/services/elastic.py`)
- Document retrieval and deletion → Elasticsearch: reads and deletes (evidence: `backend/app/services/elastic.py`)
- Index management → Elasticsearch: manages index (evidence: `backend/app/services/elastic.py`)
- Vector search → Runtime settings: uses index config (evidence: `backend/app/services/elastic.py`)
