# senthilsk10/rag-project architecture

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

- Interactive diagram: https://gitdiagram.com/senthilsk10/rag-project
- Repository: https://github.com/senthilsk10/rag-project

## Overview

##### Main Components

A. Frontend Layer:
- Web Interface (Flask Templates)
- Voice Input Processing
- Translation Interface
- Text-to-Speech Component

B. Backend Layer:
- Flask Web Server
- PDF Processing Service
- RAG Engine
- Voice Processing Service

C. Data Layer:
- MongoDB Database
- PDF Storage
- Extracted Text Storage

**[User Interface Layer]**

**[Application Layer]**

**[Data Layer]**

##### Detailed Component Breakdown

A. User Interface Layer (Top):
- HTML templates (index.html, data.html)
- Voice input/output interfaces
- Translation component
- Text-to-speech component

B. Application Layer (Middle):
- RAG Processing Engine (rag_final.py)
- PDF Monitor Service
- Voice Processing Service
- Translation Service

C. Data Layer (Bottom):
- MongoDB Database
- PDF Storage System
- Extracted Text Repository

##### Voice Query Flow
- Browser → Voice Input → Flask Server → RAG Engine → MongoDB → Results

##### PDF Processing Flow
- PDF Monitor → RAG Engine → MongoDB Storage

##### Translation Flow
- Selected Text → Translation Service → Translated Output

##### Additional Elements

Specific features:
- MongoDB data management interfaces
- Voice command processing system
- Result limitation mechanism
- Text selection and translation workflow

##### External Services

Connections to:
- Speech-to-text API
- Translation API
- Text-to-speech service

##### Notes

Annotations for:
- Port numbers (5000 for Flask)
- File locations
- API endpoints
- Database connections

Remember to include the credentials.py component but represent it as a secure configuration source without exposing sensitive details.

This system design should clearly show how the voice queries flow through the system, how PDFs are processed and stored, and how the translation and text-to-speech features integrate with the main application.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI["User Interface Layer"]
        Browser["Web Browser"]
        Templates["/templates"]
        Index["index.html"]
        DataUI["data.html"]
        VoiceIn["Voice Input Interface"]
        VoiceOut["Voice Output Interface"]
        TransUI["Translation Interface"]
    end

    subgraph APP["Application Layer"]
        Flask["Flask Server"]
        RAG["RAG Engine"]
        PDFMon["PDF Monitor Service"]
        VoiceProc["Voice Processing Service"]
        TransServ["Translation Service"]
        Config["Credentials Config"]
    end

    subgraph DATA["Data Layer"]
        Mongo[(MongoDB)]
        PDFStore[("PDF Storage")]
        TextStore[("Extracted Text")]
        MongoConfig["MongoDB Config"]
    end

    %% UI Layer Connections
    Browser --> Templates
    Templates --> Index
    Templates --> DataUI
    Browser --> VoiceIn
    Browser --> VoiceOut
    Browser --> TransUI

    %% Application Layer Connections
    VoiceIn --> Flask
    Flask --> RAG
    PDFMon --> RAG
    Flask --> VoiceProc
    Flask --> TransServ
    Config --> Flask

    %% Data Layer Connections
    RAG --> Mongo
    RAG --> PDFStore
    RAG --> TextStore
    Mongo --> MongoConfig

    %% Cross-Layer Connections
    Flask --> Browser
    RAG --> VoiceOut
    TransServ --> TransUI

    %% Styling
    classDef ui fill:#a8d1ff
    classDef app fill:#98ff98
    classDef data fill:#ffeb99
    classDef config fill:#ff9999

    class Browser,Templates,Index,DataUI,VoiceIn,VoiceOut,TransUI ui
    class Flask,RAG,PDFMon,VoiceProc,TransServ app
    class Mongo,PDFStore,TextStore data
    class Config,MongoConfig config

    %% Click Events
    click Flask "https://github.com/Senthilsk10/Rag-Project/blob/main/Rag/app.py"
    click RAG "https://github.com/Senthilsk10/Rag-Project/blob/main/Rag/rag_final.py"
    click Templates "https://github.com/Senthilsk10/Rag-Project/tree/main/Rag/templates/"
    click Index "https://github.com/Senthilsk10/Rag-Project/blob/main/Rag/templates/index.html"
    click DataUI "https://github.com/Senthilsk10/Rag-Project/blob/main/Rag/templates/data.html"
    click MongoConfig "https://github.com/Senthilsk10/Rag-Project/blob/main/Rag/playground-1.mongodb.js"
    click Config "https://github.com/Senthilsk10/Rag-Project/blob/main/Rag/credentials.py"

    %% Legend
    subgraph Legend
        UI_L["UI Component"]:::ui
        APP_L["Application Component"]:::app
        DATA_L["Data Storage"]:::data
        CONFIG_L["Configuration"]:::config
    end
```
