# ayush-r-018/docu-converse-api architecture

> Architecture diagram of the GitHub repository ayush-r-018/docu-converse-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ayush-r-018/docu-converse-api
- Repository: https://github.com/ayush-r-018/docu-converse-api

## Overview

DocuConverse is a FastAPI API for document-grounded chat and interview booking. Upload requests are validated, extracted, chunked, embedded locally, and stored as Qdrant vectors with SQLite metadata. Chat requests load Redis session state, use Gemini to classify booking intent, then either gather and validate booking details for SQLite or retrieve document context and generate a grounded answer; chat history is saved back to Redis. The README documents these major flows; source excerpts show the main orchestration and backend calls, while some upload and booking internals are supported by the source index rather than inspected excerpts.

Main entry points: [`app/services/document_service.py`](https://github.com/ayush-r-018/docu-converse-api/blob/main/app/services/document_service.py) (Document processing), [`app/services/chat_service.py`](https://github.com/ayush-r-018/docu-converse-api/blob/main/app/services/chat_service.py) (Chat orchestration), [`app/services/rag_service.py`](https://github.com/ayush-r-018/docu-converse-api/blob/main/app/services/rag_service.py) (Grounded answers), [`app/main.py`](https://github.com/ayush-r-018/docu-converse-api/blob/main/app/main.py) (FastAPI app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and configuration"]
  node_app["FastAPI app<br/>[main.py]"]
  node_upload_route["Upload endpoint<br/>[documents.py]"]
  node_chat_route["Chat endpoint<br/>[chat.py]"]
  node_settings["Settings<br/>[config.py]"]
end

subgraph group_documents["Document ingestion"]
  node_document_service["Document processing"]
  node_extractor["PDF and text extraction<br/>[pdf_extractor.py]"]
  node_chunker["Text chunking<br/>[chunking.py]"]
  node_embedding["Local embeddings"]
  node_embedding_model{{"Embedding model"}}
end

subgraph group_conversation["Chat and booking"]
  node_chat_service["Chat orchestration<br/>[chat_service.py]"]
  node_booking_intent["Booking intent extraction<br/>[gemini_service.py]"]
  node_booking_service["Booking validation<br/>[booking_service.py]"]
  node_booking_schema["Booking schemas<br/>[booking.py]"]
  node_rag_service["Grounded answers<br/>[rag_service.py]"]
  node_gemini{{"Gemini API"}}
end

subgraph group_backends["Storage and models"]
  node_qdrant_access["Vector access<br/>[qdrant.py]"]
  node_qdrant[("Qdrant")]
  node_redis_access["Session store access<br/>[redis.py]"]
  node_redis[("Redis")]
  node_sql["SQL database access<br/>[sql.py]"]
  node_document_model["Document record<br/>[document.py]"]
  node_booking_model["Booking record<br/>[booking.py]"]
  node_sqlite[("SQLite")]
end

node_user(("API client"))

node_user -->|"sends requests"| node_app
node_app -->|"routes uploads"| node_upload_route
node_app -->|"routes chat"| node_chat_route
node_upload_route -->|"reads limits"| node_settings
node_upload_route -->|"processes upload"| node_document_service
node_document_service -->|"extracts text"| node_extractor
node_document_service -->|"chunks text"| node_chunker
node_document_service -->|"creates vectors"| node_embedding
node_document_service -->|"stores chunks"| node_qdrant_access
node_document_service -->|"records metadata"| node_document_model
node_embedding -->|"encodes text"| node_embedding_model
node_chat_route -->|"dispatches chat"| node_chat_service
node_chat_service -->|"reads and saves state"| node_redis_access
node_chat_service -->|"detects booking"| node_booking_intent
node_chat_service -->|"validates and commits"| node_booking_service
node_chat_service -->|"requests answer"| node_rag_service
node_booking_intent -->|"validates extraction"| node_booking_schema
node_booking_intent -->|"requests extraction"| node_gemini
node_booking_service -->|"validates details"| node_booking_schema
node_booking_service -->|"persists booking"| node_booking_model
node_rag_service -->|"reads retrieval limit"| node_settings
node_rag_service -->|"embeds question"| node_embedding
node_rag_service -->|"searches chunks"| node_qdrant_access
node_rag_service -->|"generates answer"| node_gemini
node_qdrant_access -->|"stores and searches"| node_qdrant
node_redis_access -->|"stores session state"| node_redis
node_sql -->|"connects and queries"| node_sqlite
node_document_model -->|"registers table"| node_sql
node_booking_model -->|"registers table"| node_sql

click node_app "https://github.com/ayush-r-018/docu-converse-api/blob/main/app/main.py"
click node_upload_route "https://github.com/ayush-r-018/docu-converse-api/blob/main/app/api/routes/documents.py"
click node_chat_route "https://github.com/ayush-r-018/docu-converse-api/blob/main/app/api/routes/chat.py"
click node_settings "https://github.com/ayush-r-018/docu-converse-api/blob/main/app/core/config.py"
click node_document_service "https://github.com/ayush-r-018/docu-converse-api/blob/main/app/services/document_service.py"
click node_extractor "https://github.com/ayush-r-018/docu-converse-api/blob/main/app/utils/pdf_extractor.py"
click node_chunker "https://github.com/ayush-r-018/docu-converse-api/blob/main/app/utils/chunking.py"
click node_embedding "https://github.com/ayush-r-018/docu-converse-api/blob/main/app/services/embedding_service.py"
click node_chat_service "https://github.com/ayush-r-018/docu-converse-api/blob/main/app/services/chat_service.py"
click node_booking_intent "https://github.com/ayush-r-018/docu-converse-api/blob/main/app/services/gemini_service.py"
click node_booking_service "https://github.com/ayush-r-018/docu-converse-api/blob/main/app/services/booking_service.py"
click node_booking_schema "https://github.com/ayush-r-018/docu-converse-api/blob/main/app/schemas/booking.py"
click node_rag_service "https://github.com/ayush-r-018/docu-converse-api/blob/main/app/services/rag_service.py"
click node_qdrant_access "https://github.com/ayush-r-018/docu-converse-api/blob/main/app/database/qdrant.py"
click node_redis_access "https://github.com/ayush-r-018/docu-converse-api/blob/main/app/database/redis.py"
click node_sql "https://github.com/ayush-r-018/docu-converse-api/blob/main/app/database/sql.py"
click node_document_model "https://github.com/ayush-r-018/docu-converse-api/blob/main/app/models/document.py"
click node_booking_model "https://github.com/ayush-r-018/docu-converse-api/blob/main/app/models/booking.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_upload_route,node_chat_route,node_settings,node_user toneBlue
class node_document_service,node_extractor,node_chunker,node_embedding,node_embedding_model toneAmber
class node_chat_service,node_booking_intent,node_booking_service,node_booking_schema,node_rag_service,node_gemini toneMint
class node_qdrant_access,node_qdrant,node_redis_access,node_redis,node_sql,node_document_model,node_booking_model,node_sqlite toneRose
```

## Components

### API and configuration

- [FastAPI app](https://github.com/ayush-r-018/docu-converse-api/blob/main/app/main.py): `app/main.py`
- [Upload endpoint](https://github.com/ayush-r-018/docu-converse-api/blob/main/app/api/routes/documents.py): `app/api/routes/documents.py`
- [Chat endpoint](https://github.com/ayush-r-018/docu-converse-api/blob/main/app/api/routes/chat.py): `app/api/routes/chat.py`
- [Settings](https://github.com/ayush-r-018/docu-converse-api/blob/main/app/core/config.py): `app/core/config.py`

### Document ingestion

- [Document processing](https://github.com/ayush-r-018/docu-converse-api/blob/main/app/services/document_service.py): `app/services/document_service.py`
- [PDF and text extraction](https://github.com/ayush-r-018/docu-converse-api/blob/main/app/utils/pdf_extractor.py): `app/utils/pdf_extractor.py`
- [Text chunking](https://github.com/ayush-r-018/docu-converse-api/blob/main/app/utils/chunking.py): `app/utils/chunking.py`
- [Local embeddings](https://github.com/ayush-r-018/docu-converse-api/blob/main/app/services/embedding_service.py): `app/services/embedding_service.py`
- **Embedding model**

### Chat and booking

- [Chat orchestration](https://github.com/ayush-r-018/docu-converse-api/blob/main/app/services/chat_service.py): `app/services/chat_service.py`
- [Booking intent extraction](https://github.com/ayush-r-018/docu-converse-api/blob/main/app/services/gemini_service.py): `app/services/gemini_service.py`
- [Booking validation](https://github.com/ayush-r-018/docu-converse-api/blob/main/app/services/booking_service.py): `app/services/booking_service.py`
- [Booking schemas](https://github.com/ayush-r-018/docu-converse-api/blob/main/app/schemas/booking.py): `app/schemas/booking.py`
- [Grounded answers](https://github.com/ayush-r-018/docu-converse-api/blob/main/app/services/rag_service.py): `app/services/rag_service.py`
- **Gemini API**

### Storage and models

- [Vector access](https://github.com/ayush-r-018/docu-converse-api/blob/main/app/database/qdrant.py): `app/database/qdrant.py`
- **Qdrant**
- [Session store access](https://github.com/ayush-r-018/docu-converse-api/blob/main/app/database/redis.py): `app/database/redis.py`
- **Redis**
- [SQL database access](https://github.com/ayush-r-018/docu-converse-api/blob/main/app/database/sql.py): `app/database/sql.py`
- [Document record](https://github.com/ayush-r-018/docu-converse-api/blob/main/app/models/document.py): `app/models/document.py`
- [Booking record](https://github.com/ayush-r-018/docu-converse-api/blob/main/app/models/booking.py): `app/models/booking.py`
- **SQLite**

### Other components

- **API client**

## Connections

- API client → FastAPI app: sends requests (evidence: `README.md`)
- FastAPI app → Upload endpoint: routes uploads (evidence: `app/main.py`)
- FastAPI app → Chat endpoint: routes chat (evidence: `app/main.py`)
- Upload endpoint → Settings: reads limits (evidence: `app/api/routes/documents.py`)
- Upload endpoint → Document processing: processes upload (evidence: `app/api/routes/documents.py`)
- Document processing → PDF and text extraction: extracts text (evidence: `app/services/document_service.py`)
- Document processing → Text chunking: chunks text (evidence: `app/services/document_service.py`)
- Document processing → Local embeddings: creates vectors (evidence: `app/services/document_service.py`)
- Document processing → Vector access: stores chunks (evidence: `app/services/document_service.py`)
- Document processing → Document record: records metadata (evidence: `app/services/document_service.py`)
- Local embeddings → Embedding model: encodes text (evidence: `app/services/embedding_service.py`)
- Chat endpoint → Chat orchestration: dispatches chat (evidence: `app/api/routes/chat.py`)
- Chat orchestration → Session store access: reads and saves state (evidence: `app/services/chat_service.py`)
- Chat orchestration → Booking intent extraction: detects booking (evidence: `app/services/chat_service.py`)
- Chat orchestration → Booking validation: validates and commits (evidence: `app/services/chat_service.py`)
- Chat orchestration → Grounded answers: requests answer (evidence: `app/services/chat_service.py`)
- Booking intent extraction → Booking schemas: validates extraction (evidence: `app/services/gemini_service.py`)
- Booking intent extraction → Gemini API: requests extraction (evidence: `app/services/gemini_service.py`)
- Booking validation → Booking schemas: validates details (evidence: `app/services/booking_service.py`)
- Booking validation → Booking record: persists booking (evidence: `app/services/booking_service.py`)
- Grounded answers → Settings: reads retrieval limit (evidence: `app/services/rag_service.py`)
- Grounded answers → Local embeddings: embeds question (evidence: `app/services/rag_service.py`)
- Grounded answers → Vector access: searches chunks (evidence: `app/services/rag_service.py`)
- Grounded answers → Gemini API: generates answer (evidence: `app/services/rag_service.py`)
- Vector access → Qdrant: stores and searches (evidence: `app/database/qdrant.py`)
- Session store access → Redis: stores session state (evidence: `app/database/redis.py`)
- SQL database access → SQLite: connects and queries (evidence: `app/database/sql.py`)
- Document record → SQL database access: registers table (evidence: `app/models/document.py`)
- Booking record → SQL database access: registers table (evidence: `app/models/booking.py`)
