How barika001/ai-trip-planner works
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