# siddhant1721/-llm-powered-booking-analytics-qa-system- architecture

> Architecture diagram of the GitHub repository siddhant1721/-llm-powered-booking-analytics-qa-system-, 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/siddhant1721/-llm-powered-booking-analytics-qa-system-
- Repository: https://github.com/siddhant1721/-llm-powered-booking-analytics-qa-system-

## Overview

##### Main components
- Data Storage & Sources:
- CSV files (hotel_bookings.csv & hotel_bookings_sample.csv) that serve as the raw data source.
- ChromaDB (inside the chroma_db directory with its SQLite database) used for efficient vector retrieval.
- Data Processing & Analytics:
- Jupyter Notebook (Data_preprocessing_and_analysis.ipynb) for data cleaning, preprocessing, and exploratory analytics.
- Pre-computed analytics (like revenue trends, cancellation rates, etc.) that are later served through the Analytics API.
- API Services:
- Booking_analytics_api.py – a FastAPI service that exposes endpoints to fetch various analytical reports.
- Booking_query_api.py – another FastAPI service providing a natural language query interface for retrieving booking insights.
- Interactive User Interface:
- App.py – a Streamlit-based interactive application, powered by an LLM (with RAG architecture) to provide an interactive booking query chatbot.

##### Relationships and interactions
- The CSV files are ingested and processed (with the help of the Jupyter Notebook) to clean data and compute necessary analytics.
- The pre-processed data feeds both the booking analytics and query API endpoints.
- The Booking_analytics_api processes scheduled analytics computations and returns structured reports (such as revenue trends, cancellation rates, etc.).
- The Booking_query_api interprets natural language queries, possibly performs lookup operations (and even invokes retrieval using the ChromaDB vector search), and sends structured answers.
- The Streamlit application (App.py) acts as a front-end, allowing users to interact with the LLM-powered chatbot that internally might coordinate with the vector database and the API endpoints to produce responses.
- Communication between components follows a RESTful API interaction pattern with JSON payloads along with internal direct file and database access.

##### Architectural patterns and design principles
- Microservices-like design: Even though everything resides in one repo, Booking_analytics_api and Booking_query_api are independent FastAPI services, each handling distinct responsibilities.
- Hybrid retrieval (RAG) architecture in the Streamlit app is a key element; it integrates dense and sparse retrieval strategies utilizing the ChromaDB.
- Data transformation and analytics are run independently (via a Jupyter Notebook) then consumed as a service.

##### Relevant technologies and frameworks
- Python 3.10+ as the primary language.
- Streamlit for the interactive LLM-powered chat interface.
- FastAPI for both the Query and Analytics APIs.
- ChromaDB (SQLite based) for vector-based retrieval.
- Jupyter Notebook for data preprocessing and analysis.
- External dependencies managed via requirements.txt.
- Deployment tools such as uvicorn (ASGI server) for running FastAPI services.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Storage & Sources
    subgraph "Data Storage & Sources"
        CSV1["CSV: hotel_bookings.csv"]:::data
        CSV2["CSV: hotel_bookings_sample.csv"]:::data
        Chroma["ChromaDB (SQLite)"]:::database
    end

    %% Data Processing & Analytics
    subgraph "Data Processing & Analytics"
        Notebook["Jupyter Notebook: Data Preprocessing (Data_preprocessing_and_analysis.ipynb)"]:::processing
    end

    %% API Services
    subgraph "API Services"
        AnalyticsAPI["FastAPI: Booking Analytics API (Booking_analytics_api.py)"]:::api
        QueryAPI["FastAPI: Booking Query API (Booking_query_api.py)"]:::api
    end

    %% Interactive User Interface
    subgraph "Interactive UI"
        UI["Streamlit App: LLM Chat Interface (app.py)"]:::ui
    end

    %% Connections
    CSV1 -->|"ingests"| Notebook
    CSV2 -->|"ingests"| Notebook
    Notebook -->|"feeds analytics"| AnalyticsAPI
    Notebook -->|"feeds analytics"| QueryAPI
    UI -->|"requests data"| AnalyticsAPI
    UI -->|"requests data"| QueryAPI
    Chroma -->|"retrieval for RAG"| UI

    %% Click Events
    click CSV1 "https://github.com/siddhant1721/-llm-powered-booking-analytics-qa-system-/blob/main/hotel_bookings.csv"
    click CSV2 "https://github.com/siddhant1721/-llm-powered-booking-analytics-qa-system-/blob/main/hotel_bookings_sample.csv"
    click Chroma "https://github.com/siddhant1721/-llm-powered-booking-analytics-qa-system-/blob/main/chroma_db/chroma.sqlite3"
    click Notebook "https://github.com/siddhant1721/-llm-powered-booking-analytics-qa-system-/blob/main/Data_preprocessing_and_analysis.ipynb"
    click AnalyticsAPI "https://github.com/siddhant1721/-llm-powered-booking-analytics-qa-system-/blob/main/Booking_analytics_api.py"
    click QueryAPI "https://github.com/siddhant1721/-llm-powered-booking-analytics-qa-system-/blob/main/Booking_query_api.py"
    click UI "https://github.com/siddhant1721/-llm-powered-booking-analytics-qa-system-/blob/main/app.py"

    %% Styles
    classDef data fill:#f9e79f,stroke:#000,stroke-width:2px;
    classDef database fill:#aed6f1,stroke:#000,stroke-width:2px;
    classDef processing fill:#d5f5e3,stroke:#000,stroke-width:2px;
    classDef api fill:#f5b7b1,stroke:#000,stroke-width:2px;
    classDef ui fill:#d2b4de,stroke:#000,stroke-width:2px;
```
