# ashwinssj/cafe-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/ashwinssj/cafe-chatbot
- Repository: https://github.com/ashwinssj/cafe-chatbot

## Overview

##### Main Components
- FastAPI Backend Server: Represent the central component implemented in chatbot_backend.py. This is the hub that receives requests, processes chat messages, and returns responses.
- CSV Data Sources: Include menuCafe.csv and MenuStore.csv as data sources for menu items and ingredient information. They serve as lightweight storage for the application.
- Frontend Interface: Show the static and template directories (templates/index.html, static/images, static/script.js, static/styles.css) which provide the UI and interactivity. Even though the primary focus is the API, frontend integration notes are provided and CORS is preconfigured.
- Deployment/Configuration: Include auxiliary files like render.yaml and runtime.txt to note deployment configurations and runtime settings. Represent these as part of the deployment infrastructure that hosts the application.

##### Relationships and Data Flows
- Frontend Integration: Represent that the Static and Template components provide the HTML, CSS, and JavaScript for the user interface. Indicate an interaction — for instance, a client view rendering the HTML and calling the API.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Emphasize that the architecture cleanly separates the API layer (FastAPI) from the static frontend assets and the external AI integration.
- Lightweight Data Storage: Note the use of CSV files as a simple, file-based data store for menu and ingredient information.

##### Technical Stack and Dependencies to Highlight
- Python FastAPI Framework: Central for API management.
- CSV Files: Utilized by the backend for data intake.
- Google Gemini AI: External service powering the chatbot responses.
- Frontend Technologies: HTML, CSS, JavaScript (from templates and static folders) allowing user interaction with the API.
- Deployment Tools: Files like render.yaml and runtime.txt hint at deployment configurations and environments.

##### Putting It All Together
- The other showing the client accessing static HTML/CSS/JS assets that provide the user interface, linking back to the server endpoints.
Annotations highlighting the use of the environment variables (specifically for storing the Gemini API key), dependency management via requirements.txt, and the deployment configuration provided by render.yaml and runtime.txt.

## Diagram (Mermaid)

```mermaid
graph TD
    Browser("Client/Browser"):::client
    Backend("FastAPI Server"):::api
    Gemini("Gemini AI Service"):::external
    Frontend("Frontend UI (HTML/CSS/JS)"):::frontend

    Browser -->|"RESTcalls"| Backend
    Browser -->|"LoadsUI"| Frontend
    Frontend -->|"APICalls"| Backend

    subgraph "CSV Data Sources"
        MenuCafe("menuCafe.csv"):::csv_store
        MenuStore("MenuStore.csv"):::csv_store
    end

    Backend -->|"ReadsCSV"| MenuCafe
    Backend -->|"ReadsCSV"| MenuStore
    Backend -->|"CallsAI"| Gemini

    subgraph "Deployment & Config"
        Render("render.yaml"):::deploy
        Runtime("runtime.txt"):::deploy
        Dependencies("requirements.txt"):::deploy
    end
    Backend -->|"DeployedWith"| Render
    Backend -->|"Uses"| Runtime
    Backend -->|"DependsOn"| Dependencies

    subgraph "Frontend Assets"
        Templates("templates/index.html"):::frontend_asset
        Static("static/"):::frontend_asset
    end
    Frontend -->|"ServedFrom"| Templates
    Frontend -->|"ServedFrom"| Static

    click Backend "https://github.com/ashwinssj/cafe-chatbot/blob/main/chatbot_backend.py"
    click MenuCafe "https://github.com/ashwinssj/cafe-chatbot/blob/main/menuCafe.csv"
    click MenuStore "https://github.com/ashwinssj/cafe-chatbot/blob/main/MenuStore.csv"
    click Templates "https://github.com/ashwinssj/cafe-chatbot/blob/main/templates/index.html"
    click Static "https://github.com/ashwinssj/cafe-chatbot/tree/main/static/"
    click Render "https://github.com/ashwinssj/cafe-chatbot/blob/main/render.yaml"
    click Runtime "https://github.com/ashwinssj/cafe-chatbot/blob/main/runtime.txt"
    click Dependencies "https://github.com/ashwinssj/cafe-chatbot/blob/main/requirements.txt"

classDef client fill:#ffeb3b,stroke:#000,stroke-width:2px;
classDef api fill:#90caf9,stroke:#000,stroke-width:2px;
classDef csv fill:#a5d6a7,stroke:#000,stroke-width:2px;
classDef csv_store fill:#a5d6a7,stroke:#000,stroke-width:2px;
classDef external fill:#e1bee7,stroke:#000,stroke-width:2px;
classDef frontend fill:#f8bbd0,stroke:#000,stroke-width:2px;
classDef frontend_asset fill:#f48fb1,stroke:#000,stroke-width:2px;
classDef deploy fill:#ffe082,stroke:#000,stroke-width:2px;
```
