# barika001/ai-trip-planner architecture

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

- Interactive diagram: https://gitdiagram.com/barika001/ai-trip-planner
- Repository: https://github.com/barika001/ai-trip-planner

## Overview

##### Project type and purpose
- This is a full-stack, single-page trip-planning web application built in React (via Vite).
- Purpose: allow users to authenticate via Google OAuth, generate AI-driven travel itineraries, fetch place/hotel details from Google Places, and persist user trips in Firebase Firestore.

##### File structure
- Top-level config files (.eslintrc, tailwind.config.js, vite.config.js, vercel.json) signal a frontend-oriented, Vite-powered build and deployment on Vercel.
- The src/ directory contains:
- components/ (UI and custom React components)
- create-trip, view-trip, my-trips subfolders (route-specific pages)
- service/ (abstractions for Firebase, Google Generative AI, Google Places, and global API helpers)
- lib/utils.js and constants/options.jsx (shared utilities)
- No dedicated backend directory—backend logic resides in the service layer calling external APIs and Firebase.

##### Insights from the README
- Frontend stack: React, TailwindCSS, Axios
- Backend & services: Google Generative AI API, Google Places API, Firebase Auth & Firestore
- No custom server—relies on serverless/external-API architecture.

##### Main components & interactions
a. Components
1. Client (User’s browser running React SPA)
2. UI Layer
- Route containers: Home, Create-Trip, View-Trip ([tripId]), My-Trips
- Reusable components: Header, Hero, Buttons, Dialogs, Cards, Forms
3. Service Layer (src/service)
- FirebaseAuth (Google OAuth)
- Firestore (CRUD operations for trips)
- AIModel (Google Generative AI calls)
- GlobalApi (wrapping Axios requests)
4. External Services
- Google Generative AI API
- Google Places API
5. Hosting/Deployment
- Vercel (static site hosting)
b. Relationships & data flow
1. User → React UI: navigates, triggers form submissions
2. UI → Service Layer:
- Auth → FirebaseAuth signs user in/out
- Create Trip → AIModel generates itinerary
- /Hotel → GlobalApi fetches Google Places data
- Save/Retrieve Trips → Firestore via Firebase SDK
3. Service Layer ↔ External APIs (Google)
4. Service Layer ↔ Firebase (Auth & Firestore)
c. Architectural patterns & principles
- SPA (client-side routing)
- Service abstraction (logical separation of API calls)
- Serverless/external-first architecture
- Component-based UI (React + Tailwind)
d. Key technologies & libraries
- React, React Router (via React’s file-based routing in create-trip/view-trip/my-trips)
- TailwindCSS for styling
- Axios for HTTP requests
- Firebase SDK for Auth & Firestore
- Google Generative AI and Places APIs

- Use clear labels for each component (e.g., “React SPA”, “Firebase Auth”, “Firestore”)
- UI → Service Layer → External APIs
- UI → Service Layer → Firestore
- Blue for client/UI components
- Green for service layer modules
- Orange for external services
- Purple for database

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side - React SPA
    subgraph "Client - React SPA"
        direction TB
        Entry["main.jsx"]:::frontend
        App["App.jsx"]:::frontend

        subgraph "Route Containers"
            direction TB
            CreateTrip["Create-Trip (index.jsx)"]:::frontend
            ViewTrip["View-Trip ([tripId]/index.jsx)"]:::frontend
            MyTrips["My-Trips (index.jsx)"]:::frontend
        end

        subgraph "UI Components"
            direction TB
            Header["Header"]:::frontend
            Hero["Hero"]:::frontend
            Button["Button"]:::frontend
            Dialog["Dialog"]:::frontend
            Input["Input"]:::frontend
            Popover["Popover"]:::frontend
            Sonner["Notification (Sonner)"]:::frontend
            UserTripCard["UserTripCardItem"]:::frontend
            PlaceCard["PlaceCardItem"]:::frontend
            HotelCard["HotelCardItem"]:::frontend
            PlacesSection["PlacesToVisit"]:::frontend
            HotelsSection["Hotels"]:::frontend
            InfoSection["InfoSection"]:::frontend
            Footer["Footer"]:::frontend
        end

        Entry --> App
        App --> CreateTrip
        App --> ViewTrip
        App --> MyTrips

        CreateTrip --> Header
        CreateTrip --> Hero
        CreateTrip --> Button
        CreateTrip --> Dialog
        CreateTrip --> Input
        CreateTrip --> Popover
        CreateTrip --> Sonner

        ViewTrip --> Header
        ViewTrip --> PlaceCard
        ViewTrip --> HotelCard
        ViewTrip --> PlacesSection
        ViewTrip --> HotelsSection
        ViewTrip --> InfoSection
        ViewTrip --> Footer

        MyTrips --> Header
        MyTrips --> UserTripCard
    end

    %% Service Layer
    subgraph "Service Layer" 
        direction TB
        FirebaseConfig["FirebaseConfig"]:::service
        AIModel["AIModel"]:::service
        GlobalApi["GlobalApi"]:::service
    end

    %% External Services & Database
    subgraph "External Services"
        direction TB
        GenAI["Google Generative AI API"]:::external
        PlacesAPI["Google Places API"]:::external
    end

    FirestoreDB["Firestore Database"]:::db
    FirebaseAuth["Firebase Auth"]:::service

    %% Hosting
    Vercel["Vercel Hosting"]:::external

    %% Data Flows
    CreateTrip -->|generate itinerary| AIModel
    ViewTrip -->|fetch places/hotels| GlobalApi
    MyTrips -->|fetch trips| FirebaseConfig
    CreateTrip -->|save trip| FirebaseConfig
    ViewTrip -->|user auth| FirebaseConfig
    FirebaseConfig -->|auth & data| FirebaseAuth
    FirebaseConfig -->|read/write| FirestoreDB
    AIModel -->|HTTP requests| GenAI
    GlobalApi -->|HTTP requests| PlacesAPI

    Entry -->|deployed on| Vercel

    %% Click Events
    click Entry "https://github.com/barika001/ai-trip-planner/blob/main/src/main.jsx"
    click App "https://github.com/barika001/ai-trip-planner/blob/main/src/App.jsx"
    click CreateTrip "https://github.com/barika001/ai-trip-planner/blob/main/src/create-trip/index.jsx"
    click ViewTrip "https://github.com/barika001/ai-trip-planner/blob/main/src/view-trip/[tripId]/index.jsx"
    click MyTrips "https://github.com/barika001/ai-trip-planner/blob/main/src/my-trips/index.jsx"
    click Header "https://github.com/barika001/ai-trip-planner/blob/main/src/components/custom/Header.jsx"
    click Hero "https://github.com/barika001/ai-trip-planner/blob/main/src/components/custom/Hero.jsx"
    click Button "https://github.com/barika001/ai-trip-planner/blob/main/src/components/ui/button.jsx"
    click Dialog "https://github.com/barika001/ai-trip-planner/blob/main/src/components/ui/dialog.jsx"
    click Input "https://github.com/barika001/ai-trip-planner/blob/main/src/components/ui/input.jsx"
    click Popover "https://github.com/barika001/ai-trip-planner/blob/main/src/components/ui/popover.jsx"
    click Sonner "https://github.com/barika001/ai-trip-planner/blob/main/src/components/ui/sonner.jsx"
    click UserTripCard "https://github.com/barika001/ai-trip-planner/blob/main/src/my-trips/components/UserTripCardItem.jsx"
    click PlaceCard "https://github.com/barika001/ai-trip-planner/blob/main/src/view-trip/components/PlaceCardItem.jsx"
    click HotelCard "https://github.com/barika001/ai-trip-planner/blob/main/src/view-trip/components/HotelCardItem.jsx"
    click PlacesSection "https://github.com/barika001/ai-trip-planner/blob/main/src/view-trip/components/PlacesToVisit.jsx"
    click HotelsSection "https://github.com/barika001/ai-trip-planner/blob/main/src/view-trip/components/Hotels.jsx"
    click InfoSection "https://github.com/barika001/ai-trip-planner/blob/main/src/view-trip/components/InfoSection.jsx"
    click Footer "https://github.com/barika001/ai-trip-planner/blob/main/src/view-trip/components/Footer.jsx"
    click FirebaseConfig "https://github.com/barika001/ai-trip-planner/blob/main/src/service/firebaseConfig.jsx"
    click AIModel "https://github.com/barika001/ai-trip-planner/blob/main/src/service/AIModel.jsx"
    click GlobalApi "https://github.com/barika001/ai-trip-planner/blob/main/src/service/GlobalApi.jsx"
    click Vercel "https://github.com/barika001/ai-trip-planner/blob/main/vercel.json"
    click Tailwind "https://github.com/barika001/ai-trip-planner/blob/main/tailwind.config.js"
    click ViteConfig "https://github.com/barika001/ai-trip-planner/blob/main/vite.config.js"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef service fill:#E0F8E0,stroke:#2E8B57,color:#2E8B57;
    classDef external fill:#FFE8D0,stroke:#FF8C00,color:#FF8C00;
    classDef db fill:#E8D0FF,stroke:#8A2BE2,color:#8A2BE2;
```
