# shailendra1703/kurma architecture

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

- Interactive diagram: https://gitdiagram.com/shailendra1703/kurma
- Repository: https://github.com/shailendra1703/kurma

## Overview

##### Main Components

a) PDF Processing Layer
- PDF Input Handler
- Document Chunking Component
- Text Extraction Service

b) Vector Database Layer
- Document Embeddings Storage
- Vector Index Management
- Similarity Search Engine

c) RAG Pipeline
- Query Processing Component
- Context Retrieval System
- Response Generation Module

d) User Interface Layer
- Web Interface (indicated by htmlTemplates.py)
- API Endpoints (handled in app.py)

**[User Interface Layer]**
- ↓↑
**[RAG Pipeline Layer]**
- ↓↑
**[Vector Database Layer]**
- ↓↑
**[PDF Processing Layer]**

##### Specific Component Details

For each major component, include these elements:

a) PDF Processing Layer:
- PDF input acceptance
- Document splitting process
- Text extraction flow
- Embedding generation

b) Vector Database Layer:
- Document vector storage
- Indexing mechanism
- Search functionality

c) RAG Pipeline:
- Query embedding process
- Retrieval mechanism
- LLM integration
- Response synthesis

d) User Interface:
- Web interface components
- API endpoints
- User interaction flow

##### Important Elements to Highlight

- Document the flow of data from PDF upload to response generation
- Interaction between the vector database and the RAG pipeline
- How the user interface connects to the backend services
- Query processing flow

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef processing fill:#2ecc71,stroke:#27ae60,color:white
    classDef storage fill:#f1c40f,stroke:#f39c12,color:black
    classDef critical fill:#e74c3c,stroke:#c0392b,color:white
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white

    %% User Interface Layer
    subgraph UI["User Interface Layer"]
        WebUI["Web Interface"]:::ui
        API["API Endpoints"]:::ui
    end

    %% RAG Pipeline Layer
    subgraph RAG["RAG Pipeline"]
        QueryProc["Query Processing"]:::processing
        ContextRet["Context Retrieval"]:::processing
        RespGen["Response Generation"]:::processing
        LLM["LLM Service"]:::external
    end

    %% Vector Database Layer
    subgraph VDB["Vector Database Layer"]
        DocEmbed["Document Embeddings"]:::storage
        VecIndex["Vector Index"]:::storage
        SimSearch["Similarity Search"]:::processing
    end

    %% PDF Processing Layer
    subgraph PDF["PDF Processing Layer"]
        PDFInput["PDF Input Handler"]:::processing
        DocChunk["Document Chunking"]:::processing
        TextExt["Text Extraction"]:::processing
    end

    %% Connections
    WebUI --> API
    API --> QueryProc
    QueryProc --> ContextRet
    ContextRet --> SimSearch
    SimSearch --> DocEmbed
    ContextRet --> RespGen
    RespGen --> LLM
    LLM --> API
    
    PDFInput --> DocChunk
    DocChunk --> TextExt
    TextExt --> DocEmbed
    DocEmbed --> VecIndex
    VecIndex --> SimSearch

    %% Click events
    click WebUI "https://github.com/shailendra1703/kurma/blob/master/htmlTemplates.py"
    click API "https://github.com/shailendra1703/kurma/blob/master/app.py"

    %% Legend
    subgraph Legend
        UI_L["User Interface"]:::ui
        PROC_L["Processing"]:::processing
        STORE_L["Storage"]:::storage
        CRIT_L["Critical Path"]:::critical
        EXT_L["External Services"]:::external
    end
```
