# pavan-ak1/hackrx-llm architecture

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

- Interactive diagram: https://gitdiagram.com/pavan-ak1/hackrx-llm
- Repository: https://github.com/pavan-ak1/hackrx-llm

## Overview

##### Project type and purpose
- From the file tree and README, this is a Python-based backend service (likely using FastAPI) named “HackRx-LLM.”
- It exposes HTTP endpoints under two domains: “documents” and “queries,” and implements Pydantic models, service logic, and routers.
- The purpose is to ingest and manage documents and to answer natural-language queries—presumably by calling out to an LLM or vector-store in the background.

##### File structure
- Top-level:
- README.md, requirements.txt, venv
- app/
- Under app/:
- main.py – entry point that creates and mounts the FastAPI app and routers
- routers/ – document_routes.py & query_routes.py define HTTP endpoints
- services/ – document_services.py & query_services.py contain business logic (e.g., store/retrieve docs, call LLM)
- models/ – document_models.py & query_models.py define request/response schemas (Pydantic)
- No explicit database folder or config—likely services talk to an external DB or vector store, and to an LLM API.

##### README for additional insights
- The README only gives the project name “HackRx-LLM.”

##### Elements
- Request flow from Client → API → Router → Service → External
- Response flow back
- API Layer (e.g., blue)
- Business Logic (e.g., green)
- Data/Models (e.g., orange)
- External Services (e.g., gray)

##### Detailed capture of essential elements
- That ‘document_models.py’ and ‘query_models.py’ are used by both routers and services for type validation.
- That ‘main.py’ wires everything together.

Putting it all together:
Client → FastAPI App → [Router → Service → External] → back to Client

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["Client"]:::client
    App["FastAPI App\n(main.py)"]:::api
    Client --> App

    App --> DocRouter
    App --> QryRouter

    DocRouter["DocumentRouter\n(/documents)"]:::api
    QryRouter["QueryRouter\n(/queries)"]:::api

    DocRouter --> DocService
    QryRouter --> QryService

    DocRouter --> DocModels
    QryRouter --> QryModels

    DocService["DocumentService"]:::service
    QryService["QueryService"]:::service

    DocService --> DB
    QryService --> DB
    DocService --> LLM
    QryService --> LLM

    subgraph "Pydantic Models"
        DocModels["DocumentModels"]:::model
        QryModels["QueryModels"]:::model
    end

    subgraph "External Systems"
        DB["Database/Vector Store"]:::external
        LLM["LLM API"]:::external
    end

    click App "https://github.com/pavan-ak1/hackrx-llm/blob/main/app/main.py"
    click DocRouter "https://github.com/pavan-ak1/hackrx-llm/blob/main/app/routers/document_routes.py"
    click QryRouter "https://github.com/pavan-ak1/hackrx-llm/blob/main/app/routers/query_routes.py"
    click DocService "https://github.com/pavan-ak1/hackrx-llm/blob/main/app/services/document_services.py"
    click QryService "https://github.com/pavan-ak1/hackrx-llm/blob/main/app/services/query_services.py"
    click DocModels "https://github.com/pavan-ak1/hackrx-llm/blob/main/app/models/document_models.py"
    click QryModels "https://github.com/pavan-ak1/hackrx-llm/blob/main/app/models/query_models.py"

    classDef client fill:#E0CEF2,stroke:#5B2C6F
    classDef api fill:#D6EAF8,stroke:#1B4F72
    classDef service fill:#D5F5E3,stroke:#145A32
    classDef model fill:#FCF3CF,stroke:#7D6608
    classDef external fill:#E5E7E9,stroke:#566573
```
