# priyanshsaxena01/booking-bot architecture

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

- Interactive diagram: https://gitdiagram.com/priyanshsaxena01/booking-bot
- Repository: https://github.com/priyanshsaxena01/booking-bot

## Overview

##### Project Type and Purpose
- This is a full-stack Flask web application (“Cityscope – AI Powered Trip Planner Chatbot”) that combines:
- A frontend chat interface (HTML/CSS/JS)
- A Flask backend (app.py)
- An external LLM service (Together AI)
- A dynamic booking summary page

##### File Structure
- Top-level files:
- app.py – the Flask server entry point, defines routes and session logic
- requirements.txt – Python dependencies (Flask, together-python, python-dotenv, etc.)
- .devcontainer/ – Codespaces container config
- Frontend resources:
- static/style.css – styling for both chat and summary pages
- templates/chat.html – main chat UI with JS to POST messages
- templates/booking.html – trip summary page with pre-filled form fields via URL params

##### Key Architecture Insights from README
- Conversational flow powered by LLM via Together AI API
- Server-side session storage for state management
- AJAX calls from the chat page to backend endpoints
- Redirect to booking page with URL query parameters

##### Main Components & Their Relationships
a. Components
1. Client Browser
2. Chat UI (JS, HTML/CSS)
3. Flask App
4. Session Store (Flask built-in session)
5. Together AI LLM Service (external API)
6. Booking Summary Page (Jinja2 template)
b. Interactions
1. Browser loads `/chat` → Flask serves chat.html + style.css
2. User types message → JS sends POST `/api/chat` to Flask
3. Flask retrieves session state, forwards message to Together AI API
4. Together AI returns response JSON → Flask updates session state
5. Flask sends chatbot reply back to JS → UI updates chat window
6. When all booking data gathered → Flask builds redirect URL with query params
7. Browser navigates to `/booking?...` → Flask renders booking.html using Jinja2
c. Architectural Patterns
- MVC-style separation:
– View: HTML templates & static assets
– Controller: Flask routes & business logic
– Model (light): session data representing conversation state
- Client-server API calls (AJAX)
- External service integration for AI inference
d. Key Technologies
- Flask (HTTP routing, sessions)
- Jinja2 (templating)
- Vanilla JavaScript (fetch/AJAX)
- Together-python SDK for LLM
- CSS3 & Google Fonts (UI styling)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Zone
    subgraph "Frontend" 
        direction TB
        Browser["Client Browser"]:::frontend
        ChatHTML["templates/chat.html"]:::frontend
        StyleCSS["static/style.css"]:::frontend
        BookingPage["templates/booking.html"]:::frontend
    end

    %% Backend Zone
    subgraph "Backend"
        direction TB
        App["Flask App (app.py)"]:::backend
        API["Controller & Routes\n('/', '/api/chat', '/booking')"]:::backend
        Session["Session Store"]:::db
    end

    %% External Zone
    subgraph "External"
        direction TB
        LLM["Together AI LLM Service"]:::external
    end

    %% Project Files
    subgraph "Project Files"
        direction TB
        Req["requirements.txt"]:::backend
        Dev[".devcontainer/devcontainer.json"]:::backend
        Docs["README.md"]:::backend
    end

    %% Connections
    Browser -->|"HTTP GET /chat"| App
    App -->|"serves chat.html"| ChatHTML
    App -->|"serves style.css"| StyleCSS
    ChatHTML -->|"AJAX POST /api/chat"| API
    API -->|"retrieve/update session"| Session
    API -->|"LLM inference request"| LLM
    LLM -->|"response JSON"| API
    API -->|"reply JSON"| ChatHTML
    API -->|"Redirect with query params"| BookingPage
    Browser -->|"HTTP GET /booking?... "| BookingPage

    %% Click Events
    click ChatHTML "https://github.com/priyanshsaxena01/booking-bot/blob/main/templates/chat.html"
    click StyleCSS "https://github.com/priyanshsaxena01/booking-bot/blob/main/static/style.css"
    click BookingPage "https://github.com/priyanshsaxena01/booking-bot/blob/main/templates/booking.html"
    click App "https://github.com/priyanshsaxena01/booking-bot/blob/main/app.py"
    click Req "https://github.com/priyanshsaxena01/booking-bot/blob/main/requirements.txt"
    click Dev "https://github.com/priyanshsaxena01/booking-bot/blob/main/.devcontainer/devcontainer.json"
    click Docs "https://github.com/priyanshsaxena01/booking-bot/blob/main/README.md"

    %% Styles
    classDef frontend fill:#D6EAF8,stroke:#1B4F72,color:#1B2631
    classDef backend fill:#D5F5E3,stroke:#196F3D,color:#0B5345
    classDef external fill:#FADBD8,stroke:#922B21,color:#641E16
    classDef db fill:#FCF3CF,stroke:#7D6608,color:#513A14
```
