# techwithtim/bdaiscraperagent architecture

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

- Interactive diagram: https://gitdiagram.com/techwithtim/bdaiscraperagent
- Repository: https://github.com/techwithtim/bdaiscraperagent

## Overview

##### Project type and purpose
- This is a full-stack AI travel planning application.
- Purpose: let users describe trips in natural language and receive flights, hotels, restaurant recommendations, and local insights in an interactive chat UI.

##### File structure
- Top‐level directories:
- frontend – the Streamlit UI, AI “assistant” modules, API client, local data and vector store
- backend  – a Python service (“app.py”) for flight/hotel scraping + shared config/schemas
- frontend/restaurant_db – local ChromaDB vector store for restaurant embeddings
- Patterns:
- Clear separation between UI (Streamlit) & business logic (AI modules) & data access
- Backend acts as a microservice exposing endpoints for real-time flight & hotel search
- Config & build:
- requirements.txt + sample.env for dependencies/env
- No Dockerfiles, so local run via `streamlit run` and `python app.py`

##### Insights from the README
- Frontend uses Streamlit; AI calls go to Ollama/Claude; vector store is ChromaDB; scraping via BrightData; text search via DuckDuckGo API.
- Mentions two primary AI assistants (Travel Assistant, Research Assistant) plus a restaurant DB search.
- Backend primarily handles Google Flights & Hotels scraping modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External User
    User((User)):::external

    %% Frontend Layer
    subgraph "Frontend"
        UI["Streamlit UI"]:::internal
        APIClient["API Client"]:::internal
        TravelAssistant["Travel Assistant Module"]:::internal
        ResearchAssistant["Research Assistant Module"]:::internal
        AIContext["AI Context Manager"]:::internal
        Models["AI Data Models"]:::internal
        Schemas["AI Schemas"]:::internal
        SummaryGen["Travel Summary Generator"]:::internal
        PrefHandler["User Preferences AI Handler"]:::internal
        Constants["Constants"]:::internal
        StaticData["Static Restaurant Data"]:::datastore
        VectorStore["ChromaDB Vector Store"]:::datastore
        BrightUtil["BrightData Downloader"]:::internal
    end

    %% Backend Layer
    subgraph "Backend"
        BackendService["Backend Service"]:::internal
        ConfigModels["Config Models"]:::internal
        ConfigSchemas["Config Schemas"]:::internal
        DebugTest["Debug Utilities"]:::internal
        FlightScraper["Google Flights Scraper Service"]:::internal
        HotelScraper["Hotel Scraper Service"]:::internal
        FlightUtil["Flight Scraper Utilities"]:::internal
    end

    %% External Services
    subgraph "External Services"
        LLM["Ollama/Claude"]:::external
        DDG["DuckDuckGo API"]:::external
        BrightData["BrightData"]:::external
        SearchEngines["Search Engines"]:::external
    end

    %% Connections
    User -->|uses| UI
    UI -->|selects travel| TravelAssistant
    UI -->|selects research| ResearchAssistant
    TravelAssistant -->|uses| AIContext
    ResearchAssistant -->|uses| AIContext
    AIContext -->|loads| Models
    AIContext -->|loads| Schemas
    TravelAssistant -->|generates summary| SummaryGen
    TravelAssistant -->|handles prefs| PrefHandler
    UI -->|calls| APIClient
    APIClient -->|requests| BackendService
    BackendService -->|scrapes flights| FlightScraper
    BackendService -->|scrapes hotels| HotelScraper
    FlightScraper -->|uses utils| FlightUtil
    HotelScraper -->|uses utils| FlightUtil
    BackendService -->|loads config| ConfigModels
    BackendService -->|loads schemas| ConfigSchemas
    BackendService -->|debugs via| DebugTest
    AIContext -->|invokes| LLM
    TravelAssistant -->|queries| VectorStore
    ResearchAssistant -->|searches| DDG
    BrightUtil -->|fetches data via| BrightData
    FlightScraper -->|proxies via| BrightData
    UI -->|reads| StaticData

    %% Click Events
    click UI "https://github.com/techwithtim/bdaiscraperagent/blob/main/frontend/frontend.py"
    click TravelAssistant "https://github.com/techwithtim/bdaiscraperagent/blob/main/frontend/ai/travel_assistant.py"
    click ResearchAssistant "https://github.com/techwithtim/bdaiscraperagent/blob/main/frontend/ai/research_assistant.py"
    click AIContext "https://github.com/techwithtim/bdaiscraperagent/blob/main/frontend/ai/context.py"
    click Models "https://github.com/techwithtim/bdaiscraperagent/blob/main/frontend/ai/models.py"
    click Schemas "https://github.com/techwithtim/bdaiscraperagent/blob/main/frontend/ai/schemas.py"
    click SummaryGen "https://github.com/techwithtim/bdaiscraperagent/blob/main/frontend/ai/travel_summary.py"
    click PrefHandler "https://github.com/techwithtim/bdaiscraperagent/blob/main/frontend/ai/user_preferences.py"
    click APIClient "https://github.com/techwithtim/bdaiscraperagent/blob/main/frontend/api/api_client.py"
    click Constants "https://github.com/techwithtim/bdaiscraperagent/blob/main/frontend/constants.py"
    click StaticData "https://github.com/techwithtim/bdaiscraperagent/blob/main/frontend/data/thailand_restaurants.json"
    click VectorStore "https://github.com/techwithtim/bdaiscraperagent/tree/main/frontend/restaurant_db/"
    click BrightUtil "https://github.com/techwithtim/bdaiscraperagent/blob/main/frontend/util/brightdata_downloader.py"
    click BackendService "https://github.com/techwithtim/bdaiscraperagent/blob/main/backend/app.py"
    click ConfigModels "https://github.com/techwithtim/bdaiscraperagent/blob/main/backend/config/models.py"
    click ConfigSchemas "https://github.com/techwithtim/bdaiscraperagent/blob/main/backend/config/schemas.py"
    click DebugTest "https://github.com/techwithtim/bdaiscraperagent/blob/main/backend/debug/test.py"
    click FlightScraper "https://github.com/techwithtim/bdaiscraperagent/blob/main/backend/flights/google_flight_scraper.py"
    click HotelScraper "https://github.com/techwithtim/bdaiscraperagent/blob/main/backend/flights/hotels.py"
    click FlightUtil "https://github.com/techwithtim/bdaiscraperagent/blob/main/backend/flights/util.py"

    %% Styles
    classDef internal fill:#BBDEFB,stroke:#1E88E5,color:#0D47A1
    classDef datastore fill:#FFF59D,stroke:#FBC02D,color:#F57F17
    classDef external fill:#CFD8DC,stroke:#90A4AE,color:#455A64
```
