# harman21754/wanderchat architecture

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

- Interactive diagram: https://gitdiagram.com/harman21754/wanderchat
- Repository: https://github.com/harman21754/wanderchat

## Overview

##### Project Type & Purpose
- This is a full-stack web application (“WanderChat”) whose goal is to generate personalized travel itineraries.
- Frontend: React SPA (user inputs → UI rendering).
- Backend: FastAPI service (business logic, external API orchestration).
- External APIs: Gemini (Google Generative AI) & RapidAPI GeoDB Cities.

##### File Structure
- Top-level files: .gitignore, README.md, LICENSE, package.json (Node scripts & deps), package-lock.json
- backend/
- main.py – FastAPI app & HTTP endpoints
- requirements.txt – Python dependencies
- public/
- index.html – React entry HTML
- src/
- index.js – React bootstrap
- App.js – Main SPA + router + form
- components/ – Itinerary.js, TripOutputPage.jsx + CSS
- No database or caching—pure compute layer + external services.

##### Key README Insights
- React ecosystem: React Router, React Bootstrap
- Python ecosystem: FastAPI, Uvicorn, Pydantic, python-dotenv
- External service SDKs: google-generativeai, httpx
- Config files (.env) for REACT_APP_BACKEND_URL, GEMINI_API_KEY, RAPIDAPI_KEY.

- End User / Web Browser
- Static Asset Host (Node dev server or CDN)
- React SPA
- Form Component (dest, days, style, budget)
- TripOutputPage & Itinerary Components
- FastAPI Service
- REST Endpoints (/generate-itinerary, /suggest-city)
- Business Logic & Fallback Path
- External APIs
- Gemini API (via google-generativeai SDK)
- GeoDB Cities API (via httpx)
- Configuration Store (.env files)

1. Browser → Static Host: GET /index.html, /bundle.js
2. React SPA → FastAPI: POST /generate-itinerary (payload: destination, days, style, budget)
3. FastAPI → Gemini API: HTTPS call (itinerary generation)
4. FastAPI → GeoDB API: HTTPS call (city suggestions)
5. Gemini & GeoDB → FastAPI: JSON responses
6. FastAPI → React SPA: aggregated JSON response (itinerary + tips/fallback)
7. React SPA → Browser DOM: render results

c. Architectural Patterns & Principles
- Single-Page Application (SPA) + RESTful API separation
- Layered architecture: Presentation → API → External Services
- Config-driven endpoints & secrets (dotenv)
- Monolithic back-end (one service) with third-party integrations

d. Technologies & Frameworks
- React (JSX, hooks, Router)
- React Bootstrap
- FastAPI + Uvicorn
- google-generativeai SDK, httpx, python-dotenv, Pydantic

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        Browser["End User / Web Browser"]:::external
        Static["Static Asset Host<br>(Node dev server or CDN)"]:::frontend
        Package["package.json<br>(Deps & Scripts)"]:::frontend

        Browser -->|GET /index.html,/bundle.js| Static
        Static -->|serves assets| SPA

        SPA["React SPA"]:::frontend

        Static --> SPA
        Package --> SPA

        subgraph "SPA Components"
            App["App.js<br>Main SPA & Router"]:::frontend
            Form["Form Component<br>(dest, days, style, budget)"]:::frontend
            Output["TripOutputPage"]:::frontend
            CSS["TripOutputPage.css"]:::frontend
            Itin["Itinerary Component"]:::frontend

            SPA --> App
            App --> Form
            App --> Output
            Output --> Itin
            Output --> CSS
        end

        SPA -->|renders DOM| Browser
    end

    %% Backend Layer
    subgraph "Backend Layer"
        API["FastAPI Service"]:::backend
        Req["requirements.txt<br>(Python Deps)"]:::config
        Config["Config Store<br>(.env)"]:::config

        SPA -->|POST /generate-itinerary| API
        API --> Req
        API --> Config
    end

    %% External Services
    subgraph "External Services"
        Gemini["Gemini API"]:::external
        GeoDB["GeoDB Cities API"]:::external
    end

    %% Data Flows
    API -->|HTTPS call to generate-itinerary| Gemini
    API -->|HTTPS call to suggest-city| GeoDB
    Gemini -->|JSON response| API
    GeoDB -->|JSON response| API
    API -->|aggregated JSON response| SPA

    %% Click Events
    click SPA "https://github.com/harman21754/wanderchat/blob/master/src/index.js"
    click App "https://github.com/harman21754/wanderchat/blob/master/src/App.js"
    click Output "https://github.com/harman21754/wanderchat/blob/master/src/TripOutputPage.jsx"
    click CSS "https://github.com/harman21754/wanderchat/blob/master/src/TripOutputPage.css"
    click Itin "https://github.com/harman21754/wanderchat/blob/master/src/components/Itinerary.js"
    click Static "https://github.com/harman21754/wanderchat/blob/master/public/index.html"
    click Package "https://github.com/harman21754/wanderchat/blob/master/package.json"
    click API "https://github.com/harman21754/wanderchat/blob/master/backend/main.py"
    click Req "https://github.com/harman21754/wanderchat/blob/master/backend/requirements.txt"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#90EE90,stroke:#333,stroke-width:1px
    classDef config fill:#D3D3D3,stroke:#333,stroke-width:1px
```
