# abhishekchauhan15/docuchat architecture

> Architecture diagram of the GitHub repository abhishekchauhan15/docuchat, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abhishekchauhan15/docuchat
- Repository: https://github.com/abhishekchauhan15/docuchat

## Overview

##### Main Components
- Flask API Server – Represent this as the front-facing component that accepts document uploads and query requests.
- Redis – Include this component as the central message broker and backend store that supports Celery task management.
- Weaviate – Illustrate this component as the vector database responsible for storing document embeddings and performing similarity searches.
- Ollama – Represent this as the component that generates embeddings from documents on demand.
- Supporting Infrastructure – Optionally, include Docker (via the Dockerfile and docker-compose.yml), configuration management (.env and config.py), and utility scripts (tasks.py, worker.py, utils.py) to show deployment and orchestration details.

##### Component Relationships and Interactions
- A user uploads a document via an HTTP POST request to the Flask API.
- The Flask API forwards the document task to Celery Workers using Redis as a broker.
- Asynchronous Processing:
- The Celery Workers receive the task, which then interacts with Ollama to generate embeddings.
- Once the embeddings are generated, they are stored in Weaviate.
- Query Process Flow:
- When a query is submitted, the Flask API communicates with Weaviate to retrieve the most relevant text chunks based on semantic similarity.
- Results are then returned via the Flask API back to the client.
- Additionally, track processing status (viewable by a task ID) and manage task status updates through Redis.

- Asynchronous Processing Pattern – Emphasize how Celery decouples long-running tasks from the synchronous request/response cycle, improving throughput and responsiveness.
- Microservices/Modular Components – Although contained within a single repository, the use of multiple specialized services (API, workers, vector database, LLM) reflects a modular approach.

##### Technology and Frameworks
- Flask (Python web framework) for the API.
- Celery (Python library) for background job processing.
- Redis for messaging and caching.
- Weaviate for vector search and storage.
- Ollama for local LLM-based embedding generation.
- Docker for containerization.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "RAG System"
        Client["Client"]:::client
        API["Flask API Server"]:::api
        RedisNode["Redis (Message Broker & Results Backend)"]:::broker
        Celery["Celery Worker (Async Processing)"]:::worker
        Ollama["Ollama (Local LLM for Embeddings)"]:::llm
        Weaviate["Weaviate (Vector Database)"]:::database
    end

    subgraph "Supporting Infrastructure"
        Deployment["Deployment (Docker)"]:::deploy
        Utilities["Utilities & Config"]:::util
    end

    Client -->|"HTTPPOST(/ingest,/query)"| API
    API -->|"SubmitTask"| RedisNode
    RedisNode -->|"DistributeTask"| Celery
    Celery -->|"GenerateEmbeddings"| Ollama
    Celery -->|"StoreEmbeddings"| Weaviate
    API -->|"QueryVectors"| Weaviate
    Weaviate -->|"ReturnResults"| API
    API -->|"HTTPResponse"| Client

    %% Dotted connections indicating support from infrastructure
    Deployment --- API
    Deployment --- Celery
    Deployment --- RedisNode
    Deployment --- Ollama
    Deployment --- Weaviate

    Utilities --- API
    Utilities --- Celery
    Utilities --- RedisNode
    Utilities --- Ollama
    Utilities --- Weaviate

    %% Click Events for Component Mapping
    click API "https://github.com/abhishekchauhan15/docuchat/blob/main/app.py"
    click Celery "https://github.com/abhishekchauhan15/docuchat/blob/main/worker.py"
    click Celery "https://github.com/abhishekchauhan15/docuchat/blob/main/tasks.py"
    click RedisNode "https://github.com/abhishekchauhan15/docuchat/blob/main/docker-compose.yml"
    click RedisNode "https://github.com/abhishekchauhan15/docuchat/blob/main/.env.example"
    click Weaviate "https://github.com/abhishekchauhan15/docuchat/blob/main/docker-compose.yml"
    click Ollama "https://github.com/abhishekchauhan15/docuchat/blob/main/config.py"
    click Utilities "https://github.com/abhishekchauhan15/docuchat/blob/main/utils.py"
    click Utilities "https://github.com/abhishekchauhan15/docuchat/blob/main/config.py"
    click Deployment "https://github.com/abhishekchauhan15/docuchat/tree/main/Dockerfile"
    click Deployment "https://github.com/abhishekchauhan15/docuchat/blob/main/docker-compose.yml"

    %% Style Classes
    classDef client fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef api fill:#d1e7dd,stroke:#0f5132,stroke-width:2px;
    classDef worker fill:#fff3cd,stroke:#664d03,stroke-width:2px;
    classDef broker fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef database fill:#e2e3e5,stroke:#41464b,stroke-width:2px;
    classDef llm fill:#ffe5d9,stroke:#d35400,stroke-width:2px;
    classDef deploy fill:#d6d8d9,stroke:#343a40,stroke-width:2px;
    classDef util fill:#cfe2ff,stroke:#084298,stroke-width:2px;
```
