How vedant-303/globeroute-ai-trip-planner works
Project Type and Purpose
• GlobeRoute is a full-stack web application for AI-powered trip planning.
• Frontend: React.js SPA that handles user authentication, trip creation UI, trip listing/details, and PDF export.
• Backend: Node.js + Express API that manages users, trips, session cookies/JWT, MongoDB persistence, and integrates with external AI (Gemini) and image (Unsplash) services.
File Structure
• Top-level split into Backend/ and Frontend/.
• Backend
• server.js – Express app entry point.
• config/database.js – Mongoose connection setup.
• models/ – Mongoose schemas: user.js, trip.js.
• controllers/ – Business logic: authController.js (signup/login/logout), tripCreationController.js (create/view trips).
• routes/ – Route definitions: auth.js, tripCreation.js.
• middleware/authMiddleware.js – JWT/cookie validation.
• utils/gemini.js – Wrapper for Gemini AI API.
• Frontend
• index.html, main.jsx – Entry point.
• src/components/ – Reusable UI components (Navbar, Spinner, TripCard, forms, Hero, ExtraInfo, TripNav).
• src/pages/ – Route‐level pages: Landing, Authentication, Profile, AIGenTrip.
• src/utils/axios.js – Axios instance configured for backend API.
• src/utils/unsplash.js – Unsplash API wrapper.
• .env, vite.config.js – Build/configuration.
Extract Key Insights from README
• Auth flow uses cookies + JWT.
• Trip planning includes AI-driven itinerary, weather, cost, safety, lodging, transport, local language, plus dynamic Unsplash images.
• PDF download powered by html2pdf.js.
• Tech stack calls out React, Node/Express, MongoDB, Gemini API, Unsplash API.
Main Components
a. User’s Browser (Frontend SPA)
• Pages & Components (Landing, Auth, AIGenTrip, Profile)
• Axios layer for HTTP calls
• html2pdf.js for PDF export
b. Backend Service (Node.js + Express)
• Authentication subsystem (routes → controllers → models)
• Trip subsystem (routes → controllers → Gemini utils → models)
• JWT/Cookie middleware
• Database connector
c. Database
• MongoDB cluster (Users collection, Trips collection)
d. External Services
• Gemini AI API (trip generation, itinerary)
• Unsplash API (destination images)
Relationships & Data Flows
1. Browser → (POST /signup, /login) → AuthController → User model → MongoDB → Set JWT Cookie
2. Browser → (POST /trips) → TripController → uses gemini.js (Gemini API) + unsplash.js (Unsplash API) → Compose trip → Trip model → MongoDB → Return trip data
3. Browser ← (GET /trips, /trips/:id) ← TripController ← Trip model ← MongoDB
4. Browser → html2pdf.js to render and download PDF
5. Browser renders dynamic images via direct Unsplash fetch or via backend proxy
Architectural Patterns & Design Principles
• Layered Architecture: Presentation (React), API (Express), Persistence (MongoDB).
• MVC-like Separation in backend: Routes → Controllers → Models.
• Service/Utility Modules: gemini.js, unsplash.js encapsulate external-API logic.
• Stateless API with JWT authentication.
• Single-Page Application on frontend with clearly separated components and pages.