# siddhant-pawar/streamlit-ticketassist-rag-llm-helpdesk architecture

> Architecture diagram of the GitHub repository siddhant-pawar/streamlit-ticketassist-rag-llm-helpdesk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/siddhant-pawar/streamlit-ticketassist-rag-llm-helpdesk
- Repository: https://github.com/siddhant-pawar/streamlit-ticketassist-rag-llm-helpdesk

## Overview

##### Project Type and Purpose
- This is a full-stack, multi-page Streamlit application for ticket management (Help Desk) with an integrated Retrieval-Augmented Generation (RAG) chatbot.
- The system handles user/admin authentication, CRUD operations on tickets (MySQL), PDF ingestion & vector search (LangChain + FAISS), AI chat, and video upload/streaming.

##### High-Level Architecture Components
A. User Interface (Streamlit Multipage)
- chatboy.py: entry point, renders login/register sidebar, routes to pages.
- backend/main.py: initializes Streamlit session, user/admin menus.
- Other pages: home.py, dashboard.py, cuad.py, intergationopration.py, llmper.py, video.py, listalldata.py, account_details.py, useroparation.py, useraccountdetail.py, register.py, upload pages.

B. Business Logic / Backend Modules
- Ticket CRUD (backend/cuad.py): create, update, delete, fetch ticket records + email notifications via SMTP.
- Dashboard & Analytics (backend/dashboard.py): data retrieval, Pandas & Plotly charts.
- Generic CRUD (backend/intergationopration.py): Streamlit wrapper for read, update, delete.
- User Operations (backend/useroparation.py & useraccountdetail.py): same as above but scoped to individual user.
- Registration (backend/register.py): new user signup.

C. Data Storage
- MySQL Database: ticketdb, users table, tdatabase table.
- .env for sensitive config (OPENAI_API_KEY, DB credentials).

D. RAG Chatbot Subsystem
- PDF Processing (backend/llmper.py): file upload → PyPDF2 parsing → text splitter → FAISS vector store.
- Vector Search & LLM (OpenAI via LangChain): ChatChain for question answering.

E. File Storage
- PDFs: /pdfs upload folder + faiss_db.
- Videos: /backend/uploaded_videos directory.

F. External Services
- OpenAI API for LLM queries.
- SMTP mail server (smtp.gmail.com) for ticket emails.

##### Interactions and Data Flow
1. User/Admin logs in via Streamlit UI → main.py authenticates against MySQL.
2. Depending on role, UI routes to pages:
- Ticket pages call CRUD modules → MySQL connection (database.py) → returns results → UI updates.
- Dashboard page reads from MySQL, uses Pandas/Plotly to render analytics.
- PDF Upload page writes to /pdfs, llmper.py builds FAISS index.
- Chat page loads vector store, sends user question to OpenAI, returns answer.
- Video page uploads files to /uploaded_videos → UI lists and streams mp4/avi.
3. Email notifications triggered on ticket creation via SMTP.

##### Architectural Patterns & Principles
- Layered Architecture:
- Presentation: Streamlit front-end
- Application Logic: backend/*.py modules
- Data Access: database.py + MySQL connector
- Infrastructure: file system, OpenAI, SMTP
- Single Responsibility: each backend script has one domain focus (CRUD, analytics, chat, video).
- Session State: Streamlit session for user state and chat history.
- RAG Pattern: hybrid of vector store retrieval + LLM.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        Chatboy["chatboy.py"]:::ui
        MainNav["backend/main.py"]:::ui
        Home["home.py"]:::ui
        DashboardUI["dashboard.py"]:::ui
        CRUDUI["cuad.py"]:::ui
        GenericCRUDUI["intergationopration.py"]:::ui
        UserOpsUI["useroparation.py"]:::ui
        UserAccountUI["useraccountdetail.py"]:::ui
        RegisterUI["register.py"]:::ui
        VideoUI["video.py"]:::ui
        ListAllUI["listalldata.py"]:::ui
        AccountDetailsUI["account_details.py"]:::ui
    end

    %% Application Logic Layer
    subgraph "Application Logic"
        DBAccess["database.py"]:::backend
        PDFProcessor["llmper.py"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        MySQL[(MySQL DB)]:::data
        PDFStorage[/"pdfs"/]:::data
        FaissIndex[/"faiss_db"/]:::data
        VideoStorage[/"backend/uploaded_videos"/]:::data
    end

    %% External Services
    subgraph "External Services"
        OpenAI[(OpenAI API)]:::external
        SMTP[(SMTP Mail Server)]:::external
    end

    %% Navigation & Flow
    Chatboy --> MainNav
    MainNav --> Home
    MainNav --> DashboardUI
    MainNav --> CRUDUI
    MainNav --> GenericCRUDUI
    MainNav --> UserOpsUI
    MainNav --> UserAccountUI
    MainNav --> RegisterUI
    MainNav --> PDFProcessor
    MainNav --> VideoUI
    MainNav --> ListAllUI
    MainNav --> AccountDetailsUI

    %% UI to Data Access
    CRUDUI -->|sync| DBAccess
    DashboardUI -->|sync| DBAccess
    GenericCRUDUI -->|sync| DBAccess
    UserOpsUI -->|sync| DBAccess
    UserAccountUI -->|sync| DBAccess
    RegisterUI -->|sync| DBAccess
    ListAllUI -->|sync| DBAccess
    AccountDetailsUI -->|sync| DBAccess

    %% Data Access to DB
    DBAccess -->|queries| MySQL

    %% PDF Processing Flow
    PDFProcessor -->|stores PDFs| PDFStorage
    PDFProcessor -->|builds index| FaissIndex
    PDFProcessor -->|retrieves vectors| FaissIndex
    PDFProcessor -->|calls LLM| OpenAI
    OpenAI -->|response| PDFProcessor
    PDFProcessor -->|answers| Chatboy

    %% Video Upload/Streaming
    VideoUI -->|writes| VideoStorage

    %% Email Notification
    CRUDUI -.->|async email| SMTP

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085,color:#004085
    classDef backend fill:#d4edda,stroke:#155724,color:#155724
    classDef data fill:#fff3cd,stroke:#856404,color:#856404
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#6c757d

    %% Click Events
    click Chatboy "https://github.com/siddhant-pawar/streamlit-ticketassist-rag-llm-helpdesk/blob/main/chatboy.py"
    click MainNav "https://github.com/siddhant-pawar/streamlit-ticketassist-rag-llm-helpdesk/blob/main/backend/main.py"
    click Home "https://github.com/siddhant-pawar/streamlit-ticketassist-rag-llm-helpdesk/blob/main/backend/home.py"
    click DashboardUI "https://github.com/siddhant-pawar/streamlit-ticketassist-rag-llm-helpdesk/blob/main/backend/dashoard.py"
    click CRUDUI "https://github.com/siddhant-pawar/streamlit-ticketassist-rag-llm-helpdesk/blob/main/backend/cuad.py"
    click GenericCRUDUI "https://github.com/siddhant-pawar/streamlit-ticketassist-rag-llm-helpdesk/blob/main/backend/intergationopration.py"
    click UserOpsUI "https://github.com/siddhant-pawar/streamlit-ticketassist-rag-llm-helpdesk/blob/main/backend/useroparation.py"
    click UserAccountUI "https://github.com/siddhant-pawar/streamlit-ticketassist-rag-llm-helpdesk/blob/main/backend/useraccountdetail.py"
    click RegisterUI "https://github.com/siddhant-pawar/streamlit-ticketassist-rag-llm-helpdesk/blob/main/backend/register.py"
    click PDFProcessor "https://github.com/siddhant-pawar/streamlit-ticketassist-rag-llm-helpdesk/blob/main/backend/llmper.py"
    click VideoUI "https://github.com/siddhant-pawar/streamlit-ticketassist-rag-llm-helpdesk/blob/main/backend/video.py"
    click ListAllUI "https://github.com/siddhant-pawar/streamlit-ticketassist-rag-llm-helpdesk/blob/main/backend/listalldata.py"
    click AccountDetailsUI "https://github.com/siddhant-pawar/streamlit-ticketassist-rag-llm-helpdesk/blob/main/backend/account_details.py"
    click DBAccess "https://github.com/siddhant-pawar/streamlit-ticketassist-rag-llm-helpdesk/blob/main/backend/database.py"
    click PDFStorage "https://github.com/siddhant-pawar/streamlit-ticketassist-rag-llm-helpdesk/tree/main//pdfs"
    click FaissIndex "https://github.com/siddhant-pawar/streamlit-ticketassist-rag-llm-helpdesk/tree/main//faiss_db"
    click VideoStorage "https://github.com/siddhant-pawar/streamlit-ticketassist-rag-llm-helpdesk/tree/main/backend/uploaded_videos/"
```
