# rohith3183/trip-buddy architecture

> Architecture diagram of the GitHub repository rohith3183/trip-buddy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rohith3183/trip-buddy
- Repository: https://github.com/rohith3183/trip-buddy

## Overview

#### Purpose and Entry Points
This is a Vite React travel-planning application, likely generated for Google AI Studio, that combines curated destination data with Gemini-backed itinerary/chat experiences. The browser starts at `src/main.tsx`, renders the application shell in `src/App.tsx`, and calls backend/API functionality through `src/services/api.ts`. A server entry point exists at `server.ts`, with an API handler at `api/index.ts`; deployment is configured for Vercel via `vercel.json`.

#### Application Shell and Feature Routing
`src/App.tsx` is the central UI orchestrator: it owns the active planning experience, composes navigation, and connects major feature views. `src/components/Navbar.tsx` provides top-level navigation, while `src/components/StartLandingHero.tsx` serves as the initial entry experience. Feature state and shared domain shapes are represented in `src/types.ts`.

#### AI Planning Boundary
The AI interaction surface is `src/components/AIChatArchitect.tsx`. Client requests are isolated behind `src/services/api.ts`, creating a boundary between browser UI and Gemini-enabled server execution. Backend handling is represented by `api/index.ts` and/or `server.ts`; the required external dependency is Gemini, configured through `GEMINI_API_KEY` in `.env.local`. This boundary should protect API credentials and normalize model request/response formats before they reach UI components.

#### Grounded Destination and Itinerary Engine
The application contains a substantial local travel knowledge layer rather than relying exclusively on model output. Destination catalogs are partitioned geographically in `src/data/destinationsWest.ts`, `src/data/destinationsNortheast.ts`, and `src/data/destinationsCentralEast.ts`, with broader/master datasets in `src/data/destinations30.ts` and `src/data/destinations30Master.ts`. Matching and geographic lookup are handled by `src/data/destinationMatcher.ts` and `src/data/geoDatabase.ts`.

Itinerary construction is separated into deterministic/grounded logic: `src/data/groundedItineraryEngine.ts`, `src/data/itineraryBuilder30.ts`, and `src/data/groundingData.ts`. The likely flow is user preferences or chat input → destination matching/lookup → grounded itinerary generation → UI presentation, with Gemini augmenting rather than replacing local planning data.

#### Planning and Exploration Experiences
`src/components/ItineraryViewer.tsx` is the primary itinerary rendering boundary. Supplemental planner functions are independently surfaced: `src/components/OffbeatExplorer.tsx` for discovery, `src/components/FTQuotaCalculator.tsx` for quota/calculation-oriented planning, and `src/components/WeatherTrafficWidget.tsx` for contextual travel conditions. These components consume app/domain state rather than directly owning core destination data.

#### Persistence, Sharing, and Output
User-facing trip management is encapsulated in `src/components/SavedLocations.tsx` and `src/components/ShareTripModal.tsx`. Export is isolated in `src/utils/pdfExport.ts`, separating document generation from itinerary rendering. This creates a flow from assembled itinerary data to saved/shared/exported artifacts without coupling those delivery mechanisms to the itinerary engine.

#### Runtime and Delivery
The frontend runs as a TypeScript React SPA through Vite (`vite.config.ts`) and is bootstrapped from `index.html`. Node.js is required locally; lockfiles indicate npm and Bun compatibility (`package-lock.json`, `bun.lock`). Serverless hosting is intended through Vercel (`vercel.json`), with `api/index.ts` acting as the deployable API boundary for Gemini-backed operations.

Main entry points: [`src/App.tsx`](https://github.com/rohith3183/trip-buddy/blob/main/src/App.tsx) (App shell), [`src/data/groundedItineraryEngine.ts`](https://github.com/rohith3183/trip-buddy/blob/main/src/data/groundedItineraryEngine.ts) (Grounded itinerary engine), [`src/components/ItineraryViewer.tsx`](https://github.com/rohith3183/trip-buddy/blob/main/src/components/ItineraryViewer.tsx) (Itinerary viewer), [`src/components/AIChatArchitect.tsx`](https://github.com/rohith3183/trip-buddy/blob/main/src/components/AIChatArchitect.tsx) (AI chat architect)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["React SPA"]
  node_html["HTML bootstrap<br/>Vite entry<br/>[index.html]"]
  node_main["React bootstrap<br/>client entry<br/>[main.tsx]"]
  node_app["App shell<br/>UI orchestrator<br/>[App.tsx]"]
  node_navbar["Navigation<br/>UI component<br/>[Navbar.tsx]"]
  node_landing["Start landing<br/>UI component"]
  node_chat["AI chat architect<br/>UI component"]
  node_itinerary_viewer["Itinerary viewer<br/>UI component"]
  node_exploration["Planner tools<br/>feature components"]
  node_types["Domain types<br/>shared types<br/>[types.ts]"]
  node_api_client["API client<br/>client service<br/>[api.ts]"]
end

subgraph group_planning["Grounded planning"]
  node_matcher["Destination matching<br/>lookup logic"]
  node_geo[("Geographic lookup<br/>geo data<br/>[geoDatabase.ts]")]
  node_catalogs[("Destination catalogs<br/>local travel data")]
  node_grounding[("Grounding data<br/>planning data<br/>[groundingData.ts]")]
  node_engine["Grounded itinerary engine<br/>deterministic planner"]
end

subgraph group_backend["AI API"]
  node_api_handler{{"Serverless API handler<br/>backend endpoint<br/>[index.ts]"}}
  node_gemini(("Gemini<br/>external AI service"))
  node_vercel["Vercel deployment<br/>serverless hosting<br/>[vercel.json]"]
end

subgraph group_delivery["Trip output"]
  node_trip_management["Saved and shared trips<br/>delivery UI"]
  node_pdf["PDF export<br/>export utility<br/>[pdfExport.ts]"]
end

node_html -->|"loads"| node_main
node_main -->|"renders"| node_app
node_app -->|"composes"| node_navbar
node_app -->|"starts with"| node_landing
node_app -->|"hosts"| node_chat
node_app -->|"renders plans"| node_itinerary_viewer
node_app -->|"surfaces"| node_exploration
node_app -.->|"uses"| node_types
node_chat -->|"requests AI"| node_api_client
node_api_client -->|"calls"| node_api_handler
node_api_handler -->|"invokes"| node_gemini
node_matcher -->|"searches"| node_catalogs
node_matcher -->|"resolves geography"| node_geo
node_engine -->|"matches destinations"| node_matcher
node_engine -->|"uses"| node_grounding
node_engine -->|"grounds with"| node_catalogs
node_chat -->|"grounds planning input"| node_engine
node_engine -->|"produces itinerary"| node_itinerary_viewer
node_itinerary_viewer -->|"saves or shares"| node_trip_management
node_itinerary_viewer -->|"exports"| node_pdf
node_vercel -->|"deploys"| node_api_handler

click node_html "https://github.com/rohith3183/trip-buddy/blob/main/index.html"
click node_main "https://github.com/rohith3183/trip-buddy/blob/main/src/main.tsx"
click node_app "https://github.com/rohith3183/trip-buddy/blob/main/src/App.tsx"
click node_navbar "https://github.com/rohith3183/trip-buddy/blob/main/src/components/Navbar.tsx"
click node_landing "https://github.com/rohith3183/trip-buddy/blob/main/src/components/StartLandingHero.tsx"
click node_chat "https://github.com/rohith3183/trip-buddy/blob/main/src/components/AIChatArchitect.tsx"
click node_itinerary_viewer "https://github.com/rohith3183/trip-buddy/blob/main/src/components/ItineraryViewer.tsx"
click node_types "https://github.com/rohith3183/trip-buddy/blob/main/src/types.ts"
click node_api_client "https://github.com/rohith3183/trip-buddy/blob/main/src/services/api.ts"
click node_matcher "https://github.com/rohith3183/trip-buddy/blob/main/src/data/destinationMatcher.ts"
click node_geo "https://github.com/rohith3183/trip-buddy/blob/main/src/data/geoDatabase.ts"
click node_catalogs "https://github.com/rohith3183/trip-buddy/blob/main/src/data/destinations30Master.ts"
click node_grounding "https://github.com/rohith3183/trip-buddy/blob/main/src/data/groundingData.ts"
click node_engine "https://github.com/rohith3183/trip-buddy/blob/main/src/data/groundedItineraryEngine.ts"
click node_api_handler "https://github.com/rohith3183/trip-buddy/blob/main/api/index.ts"
click node_pdf "https://github.com/rohith3183/trip-buddy/blob/main/src/utils/pdfExport.ts"
click node_vercel "https://github.com/rohith3183/trip-buddy/blob/main/vercel.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_html,node_main,node_app,node_navbar,node_landing,node_chat,node_itinerary_viewer,node_exploration,node_types,node_api_client toneBlue
class node_matcher,node_geo,node_catalogs,node_grounding,node_engine toneAmber
class node_api_handler,node_gemini,node_vercel toneMint
class node_trip_management,node_pdf toneRose
```

## Components

### React SPA

Browser planning and exploration experience.

- [HTML bootstrap](https://github.com/rohith3183/trip-buddy/blob/main/index.html): Vite entry · `index.html`
- [React bootstrap](https://github.com/rohith3183/trip-buddy/blob/main/src/main.tsx): client entry · `src/main.tsx`
- [App shell](https://github.com/rohith3183/trip-buddy/blob/main/src/App.tsx): UI orchestrator · Owns active planning experience and feature composition. · `src/App.tsx`
- [Navigation](https://github.com/rohith3183/trip-buddy/blob/main/src/components/Navbar.tsx): UI component · `src/components/Navbar.tsx`
- [Start landing](https://github.com/rohith3183/trip-buddy/blob/main/src/components/StartLandingHero.tsx): UI component · `src/components/StartLandingHero.tsx`
- [AI chat architect](https://github.com/rohith3183/trip-buddy/blob/main/src/components/AIChatArchitect.tsx): UI component · `src/components/AIChatArchitect.tsx`
- [Itinerary viewer](https://github.com/rohith3183/trip-buddy/blob/main/src/components/ItineraryViewer.tsx): UI component · `src/components/ItineraryViewer.tsx`
- **Planner tools**: feature components · Offbeat discovery, quota calculation, and weather/traffic context.
- [Domain types](https://github.com/rohith3183/trip-buddy/blob/main/src/types.ts): shared types · `src/types.ts`
- [API client](https://github.com/rohith3183/trip-buddy/blob/main/src/services/api.ts): client service · Normalizes browser requests to backend operations. · `src/services/api.ts`

### Grounded planning

Local destination matching and itinerary construction.

- [Destination matching](https://github.com/rohith3183/trip-buddy/blob/main/src/data/destinationMatcher.ts): lookup logic · `src/data/destinationMatcher.ts`
- [Geographic lookup](https://github.com/rohith3183/trip-buddy/blob/main/src/data/geoDatabase.ts): geo data · `src/data/geoDatabase.ts`
- [Destination catalogs](https://github.com/rohith3183/trip-buddy/blob/main/src/data/destinations30Master.ts): local travel data · Regional and master destination datasets. · `src/data/destinations30Master.ts`
- [Grounding data](https://github.com/rohith3183/trip-buddy/blob/main/src/data/groundingData.ts): planning data · `src/data/groundingData.ts`
- [Grounded itinerary engine](https://github.com/rohith3183/trip-buddy/blob/main/src/data/groundedItineraryEngine.ts): deterministic planner · Builds itineraries from matched local travel data. · `src/data/groundedItineraryEngine.ts`

### AI API

Credential-protected Gemini execution boundary.

- [Serverless API handler](https://github.com/rohith3183/trip-buddy/blob/main/api/index.ts): backend endpoint · Deployable Gemini-backed API boundary. · `api/index.ts`
- **Gemini**: external AI service · Uses GEMINI_API_KEY only on the server.
- [Vercel deployment](https://github.com/rohith3183/trip-buddy/blob/main/vercel.json): serverless hosting · `vercel.json`

### Trip output

Persistence, sharing, and document delivery.

- **Saved and shared trips**: delivery UI · SavedLocations and ShareTripModal manage user-facing trip artifacts.
- [PDF export](https://github.com/rohith3183/trip-buddy/blob/main/src/utils/pdfExport.ts): export utility · `src/utils/pdfExport.ts`

## Connections

- HTML bootstrap → React bootstrap: loads
- React bootstrap → App shell: renders
- App shell → Navigation: composes
- App shell → Start landing: starts with
- App shell → AI chat architect: hosts
- App shell → Itinerary viewer: renders plans
- App shell → Planner tools: surfaces
- App shell → Domain types: uses
- AI chat architect → API client: requests AI
- API client → Serverless API handler: calls
- Serverless API handler → Gemini: invokes
- Destination matching → Destination catalogs: searches
- Destination matching → Geographic lookup: resolves geography
- Grounded itinerary engine → Destination matching: matches destinations
- Grounded itinerary engine → Grounding data: uses
- Grounded itinerary engine → Destination catalogs: grounds with
- AI chat architect → Grounded itinerary engine: grounds planning input
- Grounded itinerary engine → Itinerary viewer: produces itinerary
- Itinerary viewer → Saved and shared trips: saves or shares
- Itinerary viewer → PDF export: exports
- Vercel deployment → Serverless API handler: deploys
