# cmwaseemyousef/foodiespot-reservation-ai architecture

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

- Interactive diagram: https://gitdiagram.com/cmwaseemyousef/foodiespot-reservation-ai
- Repository: https://github.com/cmwaseemyousef/foodiespot-reservation-ai

## Overview

##### Project type and purpose
- This is a full-stack demo application called “FoodieSpot AI Reservation Agent.”
- Frontend: Streamlit chat UI (app.py)
- Backend: FastAPI service exposing an `/agent` endpoint (backend.py)
- Purpose: Accept natural-language queries, extract intent (mocked rule-based LLM), query a static dataset (restaurants.json), and return booking or recommendation responses.

##### File structure
- Top-level files:
- app.py – Streamlit frontend
- backend.py – FastAPI backend
- restaurants.json – static data store
- requirements.txt – Python dependencies
- Supporting docs (prompts, assumptions, business strategy) are outside core runtime.
- No separate “src” or “lib” folders: all code is in the root.
- No containerization or infra scripts—deployment via Uvicorn and Streamlit CLI.

##### README for additional insights
- Frontend/back-end split is explicitly described.
- Architecture section calls out tool-calling approach and how to swap in a real LLM by replacing call_llm().
- Screenshots and user-journey images outline end-to-end flow.
- Future enhancements mention external LLM services, cancel/modify flows, notifications.

a. Main components
- User / Browser
- Streamlit UI (app.py)
- FastAPI Backend (backend.py)
- Intent-Extraction Module (call_llm rule-based stub or real LLM)
- Data Store (restaurants.json)
- (Optional) External LLM Service (OpenAI/HuggingFace)
b. Relationships & interactions
1. User interacts with Streamlit UI.
2. UI sends HTTP POST to the FastAPI `/agent` endpoint.
3. Backend receives chat history and user message.
4. Backend invokes `call_llm()` to parse intent into JSON.
– If swapped out, this becomes an API call to an external LLM service.
5. Backend processes intent: queries restaurants.json for matches.
6. Backend constructs a response and returns JSON to UI.
7. UI renders the assistant’s reply in the chat.
c. Architectural patterns & principles
- Separation of concerns: UI vs. API vs. data
- Tool-calling architecture: backend orchestrates LLM calls + domain logic
- Plug-and-play integration: intent extractor is encapsulated for easy swapping
d. Key technologies & frameworks
- Streamlit (Python) for frontend
- FastAPI + Uvicorn for backend
- Python standard libraries & JSON for data handling
- Optional: OpenAI/Hugging Face API for real LLM integration

##### Detail without over-engineering
- Every runtime artifact (app.py, backend.py, restaurants.json, call_llm stub).
- Mock vs. future real LLM flow.
- Do not include documentation files or business_strategy.md—focus on runtime/system elements.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Frontend"
        User["User"]:::external
        StreamlitUI["Streamlit Chat UI<br/>(app.py)"]:::frontend
    end

    subgraph "Backend"
        FastAPIEndpoint["FastAPI /agent Endpoint<br/>(backend.py)"]:::backend
        IntentExtractor["Intent Extraction Module<br/>(call_llm & prompts)"]:::backend
        DataAccess["Business Logic & Data Access"]:::backend
    end

    DataStore["restaurants.json"]:::datastore
    ExternalLLM["External LLM Service"]:::external
    Dependencies["requirements.txt"]:::infra

    User -->|"interacts with"| StreamlitUI
    StreamlitUI -->|"HTTP POST /agent"| FastAPIEndpoint
    FastAPIEndpoint -->|"parse intent"| IntentExtractor
    IntentExtractor -->|"(optional) API call"| ExternalLLM
    FastAPIEndpoint -->|"query dataset"| DataStore
    DataStore -->|"return data"| FastAPIEndpoint
    FastAPIEndpoint -->|"JSON response"| StreamlitUI
    FastAPIEndpoint -.->|"uses deps"| Dependencies

    click StreamlitUI "https://github.com/cmwaseemyousef/foodiespot-reservation-ai/blob/main/app.py"
    click FastAPIEndpoint "https://github.com/cmwaseemyousef/foodiespot-reservation-ai/blob/main/backend.py"
    click IntentExtractor "https://github.com/cmwaseemyousef/foodiespot-reservation-ai/blob/main/prompts.py"
    click DataStore "https://github.com/cmwaseemyousef/foodiespot-reservation-ai/blob/main/restaurants.json"
    click Dependencies "https://github.com/cmwaseemyousef/foodiespot-reservation-ai/blob/main/requirements.txt"

    classDef frontend fill:#a8d0e6,stroke:#000,stroke-width:1px
    classDef backend fill:#8fc1a9,stroke:#000,stroke-width:1px
    classDef external fill:#f4b261,stroke:#000,stroke-width:1px
    classDef datastore fill:#c08497,stroke:#000,stroke-width:1px
    classDef infra fill:#d3d3d3,stroke:#000,stroke-width:1px
```
