# ethan071104/jalanjalan architecture

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

- Interactive diagram: https://gitdiagram.com/ethan071104/jalanjalan
- Repository: https://github.com/ethan071104/jalanjalan

## Overview

JalanJalan is a collaborative group travel planner. Travellers join a private trip, record Travel DNA and setup constraints, vote on real places, then receive a feasible shared itinerary that can be mapped, edited, and adapted in Live Mode. The graph preserves those user-facing stages and the key planning, persistence, routing, and realtime layers. Some feature links rely on the README because their implementation was not sampled; those edges are cited as documented rather than implying source inspection.

Main entry points: [`app/api/trips/[id]/candidate-places/route.ts`](https://github.com/ethan071104/jalanjalan/blob/main/app/api/trips/%5Bid%5D/candidate-places/route.ts) (Candidate API), [`lib/malaysia-places/planning-orchestration-core.ts`](https://github.com/ethan071104/jalanjalan/blob/main/lib/malaysia-places/planning-orchestration-core.ts) (Planning orchestration), [`app/trip/[id]/trip-room.tsx`](https://github.com/ethan071104/jalanjalan/blob/main/app/trip/%5Bid%5D/trip-room.tsx) (Trip room), [`components/itinerary/itinerary-planner.tsx`](https://github.com/ethan071104/jalanjalan/blob/main/components/itinerary/itinerary-planner.tsx) (Itinerary planner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Trip experience"]
  node_trip_room["Trip room<br/>[trip-room.tsx]"]
  node_questionnaire["Travel DNA"]
  node_preference_model["Preference model<br/>[model.ts]"]
  node_setup["Trip setup<br/>[setup-core.ts]"]
  node_live_ui["Live Mode<br/>[live-trip.tsx]"]
end

subgraph group_consensus["Group consensus"]
  node_candidate_ui["Place voting"]
  node_candidate_api["Candidate API<br/>[route.ts]"]
  node_grounded_pool["Grounded candidates"]
  node_group_ranking["Group ranking<br/>[group-ranking.ts]"]
end

subgraph group_planning["Itinerary planning"]
  node_planning_orchestration["Planning orchestration"]
  node_day_clustering["Day clustering"]
  node_deterministic_schedule["Deterministic schedule"]
  node_itinerary_bridge["Itinerary bridge"]
  node_itinerary_api["Itinerary API<br/>[route.ts]"]
  node_itinerary_ui["Itinerary planner"]
  node_map_ui["Interactive map<br/>[map-planner.tsx]"]
  node_ai_edit["AI itinerary edits<br/>[ai-edit.ts]"]
end

subgraph group_services["Trip services"]
  node_storage[("Trip persistence<br/>[storage.ts]")]
  node_finalization["Planning lock<br/>[finalization.ts]"]
  node_route_service["Route service"]
  node_route_points["Route points"]
end

subgraph group_integrations["External integrations"]
  node_weather["Weather forecasts<br/>[open-meteo.ts]"]
  node_supabase[("Supabase")]
  node_google_places["Google Places<br/>[google-places.ts]"]
  node_openrouter["OpenRouter<br/>[openrouter.ts]"]
  node_openrouteservice["OpenRouteService"]
end

node_travellers(("Travellers"))

node_travellers -->|"join and plan"| node_trip_room
node_trip_room -->|"collects preferences"| node_questionnaire
node_questionnaire -.->|"records Travel DNA"| node_preference_model
node_trip_room -->|"sets trip constraints"| node_setup
node_travellers -->|"vote on places"| node_candidate_ui
node_candidate_ui -.->|"updates selections"| node_candidate_api
node_candidate_api -->|"loads candidates"| node_grounded_pool
node_candidate_api -->|"ranks candidates"| node_group_ranking
node_candidate_api -->|"requests planning plan"| node_planning_orchestration
node_planning_orchestration -->|"clusters selected places"| node_day_clustering
node_planning_orchestration -->|"drafts schedule"| node_deterministic_schedule
node_planning_orchestration -->|"normalizes itinerary"| node_itinerary_bridge
node_candidate_api -->|"loads and saves"| node_storage
node_candidate_api -->|"checks planning lock"| node_finalization
node_travellers -->|"review itinerary"| node_itinerary_ui
node_itinerary_ui -.->|"requests itinerary"| node_itinerary_api
node_itinerary_api -->|"loads itinerary"| node_storage
node_itinerary_ui -.->|"views plan on map"| node_map_ui
node_map_ui -->|"requests route"| node_route_service
node_route_service -->|"builds route points"| node_route_points
node_route_service -->|"fetches driving directions"| node_openrouteservice
node_travellers -->|"request constrained edits"| node_ai_edit
node_ai_edit -.->|"requests AI edits"| node_openrouter
node_travellers -->|"adapt plans"| node_live_ui
node_live_ui -.->|"shows forecast context"| node_weather
node_storage -.->|"reads and writes"| node_supabase
node_grounded_pool -.->|"uses real place data"| node_google_places

click node_trip_room "https://github.com/ethan071104/jalanjalan/blob/main/app/trip/%5Bid%5D/trip-room.tsx"
click node_questionnaire "https://github.com/ethan071104/jalanjalan/blob/main/components/travel-dna/questionnaire-wizard.tsx"
click node_preference_model "https://github.com/ethan071104/jalanjalan/blob/main/lib/preferences/model.ts"
click node_setup "https://github.com/ethan071104/jalanjalan/blob/main/lib/trips/setup-core.ts"
click node_candidate_ui "https://github.com/ethan071104/jalanjalan/blob/main/components/candidate-places/candidate-places.tsx"
click node_candidate_api "https://github.com/ethan071104/jalanjalan/blob/main/app/api/trips/%5Bid%5D/candidate-places/route.ts"
click node_grounded_pool "https://github.com/ethan071104/jalanjalan/blob/main/lib/malaysia-places/grounded-candidate-pool.ts"
click node_group_ranking "https://github.com/ethan071104/jalanjalan/blob/main/lib/malaysia-places/group-ranking.ts"
click node_planning_orchestration "https://github.com/ethan071104/jalanjalan/blob/main/lib/malaysia-places/planning-orchestration-core.ts"
click node_day_clustering "https://github.com/ethan071104/jalanjalan/blob/main/lib/malaysia-places/day-clustering-core.ts"
click node_deterministic_schedule "https://github.com/ethan071104/jalanjalan/blob/main/lib/malaysia-places/deterministic-scheduling-core.ts"
click node_itinerary_bridge "https://github.com/ethan071104/jalanjalan/blob/main/lib/malaysia-places/itinerary-bridge-core.ts"
click node_itinerary_api "https://github.com/ethan071104/jalanjalan/blob/main/app/api/trips/%5Bid%5D/itinerary/route.ts"
click node_itinerary_ui "https://github.com/ethan071104/jalanjalan/blob/main/components/itinerary/itinerary-planner.tsx"
click node_map_ui "https://github.com/ethan071104/jalanjalan/blob/main/components/map/map-planner.tsx"
click node_ai_edit "https://github.com/ethan071104/jalanjalan/blob/main/lib/planner/ai-edit.ts"
click node_storage "https://github.com/ethan071104/jalanjalan/blob/main/lib/phase2/storage.ts"
click node_finalization "https://github.com/ethan071104/jalanjalan/blob/main/lib/trips/finalization.ts"
click node_route_service "https://github.com/ethan071104/jalanjalan/blob/main/lib/routing/openrouteservice.ts"
click node_route_points "https://github.com/ethan071104/jalanjalan/blob/main/lib/routing/route-points-core.ts"
click node_live_ui "https://github.com/ethan071104/jalanjalan/blob/main/components/live/live-trip.tsx"
click node_weather "https://github.com/ethan071104/jalanjalan/blob/main/lib/weather/open-meteo.ts"
click node_google_places "https://github.com/ethan071104/jalanjalan/blob/main/lib/phase2/google-places.ts"
click node_openrouter "https://github.com/ethan071104/jalanjalan/blob/main/lib/phase2/openrouter.ts"

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_trip_room,node_questionnaire,node_preference_model,node_setup,node_live_ui toneBlue
class node_candidate_ui,node_candidate_api,node_grounded_pool,node_group_ranking toneAmber
class node_planning_orchestration,node_day_clustering,node_deterministic_schedule,node_itinerary_bridge,node_itinerary_api,node_itinerary_ui,node_map_ui,node_ai_edit toneMint
class node_storage,node_finalization,node_route_service,node_route_points toneRose
class node_weather,node_supabase,node_google_places,node_openrouter,node_openrouteservice,node_travellers toneIndigo
```

## Components

### Trip experience

- [Trip room](https://github.com/ethan071104/jalanjalan/blob/main/app/trip/%5Bid%5D/trip-room.tsx): `app/trip/[id]/trip-room.tsx`
- [Travel DNA](https://github.com/ethan071104/jalanjalan/blob/main/components/travel-dna/questionnaire-wizard.tsx): `components/travel-dna/questionnaire-wizard.tsx`
- [Preference model](https://github.com/ethan071104/jalanjalan/blob/main/lib/preferences/model.ts): `lib/preferences/model.ts`
- [Trip setup](https://github.com/ethan071104/jalanjalan/blob/main/lib/trips/setup-core.ts): `lib/trips/setup-core.ts`
- [Live Mode](https://github.com/ethan071104/jalanjalan/blob/main/components/live/live-trip.tsx): `components/live/live-trip.tsx`

### Group consensus

- [Place voting](https://github.com/ethan071104/jalanjalan/blob/main/components/candidate-places/candidate-places.tsx): `components/candidate-places/candidate-places.tsx`
- [Candidate API](https://github.com/ethan071104/jalanjalan/blob/main/app/api/trips/%5Bid%5D/candidate-places/route.ts): `app/api/trips/[id]/candidate-places/route.ts`
- [Grounded candidates](https://github.com/ethan071104/jalanjalan/blob/main/lib/malaysia-places/grounded-candidate-pool.ts): `lib/malaysia-places/grounded-candidate-pool.ts`
- [Group ranking](https://github.com/ethan071104/jalanjalan/blob/main/lib/malaysia-places/group-ranking.ts): `lib/malaysia-places/group-ranking.ts`

### Itinerary planning

- [Planning orchestration](https://github.com/ethan071104/jalanjalan/blob/main/lib/malaysia-places/planning-orchestration-core.ts): `lib/malaysia-places/planning-orchestration-core.ts`
- [Day clustering](https://github.com/ethan071104/jalanjalan/blob/main/lib/malaysia-places/day-clustering-core.ts): `lib/malaysia-places/day-clustering-core.ts`
- [Deterministic schedule](https://github.com/ethan071104/jalanjalan/blob/main/lib/malaysia-places/deterministic-scheduling-core.ts): `lib/malaysia-places/deterministic-scheduling-core.ts`
- [Itinerary bridge](https://github.com/ethan071104/jalanjalan/blob/main/lib/malaysia-places/itinerary-bridge-core.ts): `lib/malaysia-places/itinerary-bridge-core.ts`
- [Itinerary API](https://github.com/ethan071104/jalanjalan/blob/main/app/api/trips/%5Bid%5D/itinerary/route.ts): `app/api/trips/[id]/itinerary/route.ts`
- [Itinerary planner](https://github.com/ethan071104/jalanjalan/blob/main/components/itinerary/itinerary-planner.tsx): `components/itinerary/itinerary-planner.tsx`
- [Interactive map](https://github.com/ethan071104/jalanjalan/blob/main/components/map/map-planner.tsx): `components/map/map-planner.tsx`
- [AI itinerary edits](https://github.com/ethan071104/jalanjalan/blob/main/lib/planner/ai-edit.ts): `lib/planner/ai-edit.ts`

### Trip services

- [Trip persistence](https://github.com/ethan071104/jalanjalan/blob/main/lib/phase2/storage.ts): `lib/phase2/storage.ts`
- [Planning lock](https://github.com/ethan071104/jalanjalan/blob/main/lib/trips/finalization.ts): `lib/trips/finalization.ts`
- [Route service](https://github.com/ethan071104/jalanjalan/blob/main/lib/routing/openrouteservice.ts): `lib/routing/openrouteservice.ts`
- [Route points](https://github.com/ethan071104/jalanjalan/blob/main/lib/routing/route-points-core.ts): `lib/routing/route-points-core.ts`

### External integrations

- [Weather forecasts](https://github.com/ethan071104/jalanjalan/blob/main/lib/weather/open-meteo.ts): `lib/weather/open-meteo.ts`
- **Supabase**
- [Google Places](https://github.com/ethan071104/jalanjalan/blob/main/lib/phase2/google-places.ts): `lib/phase2/google-places.ts`
- [OpenRouter](https://github.com/ethan071104/jalanjalan/blob/main/lib/phase2/openrouter.ts): `lib/phase2/openrouter.ts`
- **OpenRouteService**

### Other components

- **Travellers**

## Connections

- Travellers → Trip room: join and plan (evidence: `README.md`)
- Trip room → Travel DNA: collects preferences (evidence: `README.md`)
- Travel DNA → Preference model: records Travel DNA
- Trip room → Trip setup: sets trip constraints (evidence: `README.md`)
- Travellers → Place voting: vote on places (evidence: `README.md`)
- Place voting → Candidate API: updates selections
- Candidate API → Grounded candidates: loads candidates (evidence: `app/api/trips/[id]/candidate-places/route.ts`)
- Candidate API → Group ranking: ranks candidates (evidence: `app/api/trips/[id]/candidate-places/route.ts`)
- Candidate API → Planning orchestration: requests planning plan (evidence: `app/api/trips/[id]/candidate-places/route.ts`)
- Planning orchestration → Day clustering: clusters selected places (evidence: `lib/malaysia-places/planning-orchestration-core.ts`)
- Planning orchestration → Deterministic schedule: drafts schedule (evidence: `lib/malaysia-places/planning-orchestration-core.ts`)
- Planning orchestration → Itinerary bridge: normalizes itinerary (evidence: `lib/malaysia-places/planning-orchestration-core.ts`)
- Candidate API → Trip persistence: loads and saves (evidence: `app/api/trips/[id]/candidate-places/route.ts`)
- Candidate API → Planning lock: checks planning lock (evidence: `app/api/trips/[id]/candidate-places/route.ts`)
- Travellers → Itinerary planner: review itinerary (evidence: `README.md`)
- Itinerary planner → Itinerary API: requests itinerary
- Itinerary API → Trip persistence: loads itinerary (evidence: `app/api/trips/[id]/itinerary/route.ts`)
- Itinerary planner → Interactive map: views plan on map
- Interactive map → Route service: requests route (evidence: `components/map/map-planner.tsx`)
- Route service → Route points: builds route points (evidence: `lib/routing/openrouteservice.ts`)
- Route service → OpenRouteService: fetches driving directions (evidence: `lib/routing/openrouteservice.ts`)
- Travellers → AI itinerary edits: request constrained edits (evidence: `README.md`)
- AI itinerary edits → OpenRouter: requests AI edits
- Travellers → Live Mode: adapt plans (evidence: `README.md`)
- Live Mode → Weather forecasts: shows forecast context
- Trip persistence → Supabase: reads and writes
- Grounded candidates → Google Places: uses real place data
