# jaylenyu/ai-planner architecture

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

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

## Overview

ai-planner is a full-stack AI itinerary planner. The main user journey sends a natural-language request from the planner UI to the backend, which builds a draft itinerary through documented interpretation, place-search, candidate-selection, routing, and scheduling stages; the user can then save it. The README also documents editing and sharing plans, workspaces, subscriptions, authentication, notifications, and administration. Some backend orchestration and frontend request wiring were not sampled, so those links are documented or marked unverified rather than inferred from module names.

Main entry points: [`backend/src/modules/auth/auth.service.ts`](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/auth/auth.service.ts) (Auth service), [`backend/src/prisma/prisma.service.ts`](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/prisma/prisma.service.ts) (PostgreSQL data), [`backend/src/modules/plan/plan.service.ts`](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/plan/plan.service.ts) (Plan service), [`backend/src/modules/payment/payment.service.ts`](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/payment/payment.service.ts) (Subscription payments)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_planui["Plan interface<br/>[page.tsx]"]
  node_apiclient["API client<br/>[api.ts]"]
  node_authui["Auth hook<br/>[useAuth.ts]"]
end

subgraph group_identity["Identity and access"]
  node_authcontroller["Auth endpoints<br/>[auth.controller.ts]"]
  node_authservice["Auth service<br/>[auth.service.ts]"]
  node_emailverify["Email verification"]
  node_oauthaccounts["OAuth accounts"]
  node_email["Email delivery<br/>[email.service.ts]"]
  node_guard["JWT access guard<br/>[auth.guard.ts]"]
end

subgraph group_itinerary["Itinerary planning"]
  node_plancontroller["Plan endpoints<br/>[plan.controller.ts]"]
  node_planservice["Plan service<br/>[plan.service.ts]"]
  node_parse["Parse request"]
  node_intent["Extract intent"]
  node_placesearch["Search places"]
  node_candidates["Select candidates"]
  node_route["Optimize route"]
  node_schedule["Generate schedule"]
  node_places["Place search service<br/>[places.service.ts]"]
  node_draft[("Preview draft<br/>[plan.service.ts]")]
end

subgraph group_engagement["Sharing and billing"]
  node_workspace["Workspace sharing"]
  node_notifications["In-app notifications"]
  node_payment["Subscription payments<br/>[payment.service.ts]"]
end

subgraph group_operations["Administration and platform"]
  node_database[("PostgreSQL data<br/>[prisma.service.ts]")]
  node_admin["Admin operations<br/>[admin.service.ts]"]
  node_budget["API usage budgets"]
  node_redis[("Redis cache<br/>[redis.service.ts]")]
end

node_visitor(("Planner user"))
node_toss["Toss Payments"]

node_visitor -->|"requests itinerary"| node_planui
node_planui -.->|"calls API"| node_apiclient
node_apiclient -->|"posts preview"| node_plancontroller
node_visitor -->|"signs in"| node_authui
node_authui -->|"uses client"| node_apiclient
node_authcontroller -->|"delegates auth"| node_authservice
node_authservice -->|"reads and writes"| node_database
node_authservice -->|"delegates verification"| node_emailverify
node_authservice -->|"completes signup"| node_oauthaccounts
node_authservice -->|"sends messages"| node_email
node_authservice -->|"checks login state"| node_redis
node_emailverify -->|"sends codes"| node_email
node_plancontroller -->|"delegates plans"| node_planservice
node_planservice -->|"holds preview"| node_draft
node_planservice -.->|"runs pipeline"| node_parse
node_parse -->|"passes parsed input"| node_intent
node_intent -->|"builds search intents"| node_placesearch
node_placesearch -->|"passes search results"| node_candidates
node_candidates -->|"passes candidates"| node_route
node_route -->|"passes ordered route"| node_schedule
node_placesearch -.->|"queries providers"| node_places
node_planservice -->|"saves plans"| node_database
node_workspace -.->|"persists sharing"| node_database
node_payment -->|"records payments"| node_database
node_payment -.->|"confirms payments"| node_toss
node_payment -->|"sends receipts"| node_email
node_admin -->|"queries operations"| node_database
node_admin -.->|"reports usage"| node_budget
node_budget -->|"tracks usage"| node_database
node_authcontroller -->|"protects routes"| node_guard
node_plancontroller -->|"protects routes"| node_guard

click node_planui "https://github.com/jaylenyu/ai-planner/blob/main/frontend/src/app/plan/page.tsx"
click node_apiclient "https://github.com/jaylenyu/ai-planner/blob/main/frontend/src/lib/api.ts"
click node_authui "https://github.com/jaylenyu/ai-planner/blob/main/frontend/src/hooks/useAuth.ts"
click node_authcontroller "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/auth/auth.controller.ts"
click node_authservice "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/auth/auth.service.ts"
click node_emailverify "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/auth/email-verification.service.ts"
click node_oauthaccounts "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/auth/oauth-account.service.ts"
click node_email "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/email/email.service.ts"
click node_plancontroller "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/plan/plan.controller.ts"
click node_planservice "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/plan/plan.service.ts"
click node_parse "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/ai/steps/parse-input.step.ts"
click node_intent "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/ai/steps/extract-intent.step.ts"
click node_placesearch "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/ai/steps/search-places.step.ts"
click node_candidates "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/ai/steps/select-candidates.step.ts"
click node_route "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/ai/steps/optimize-route.step.ts"
click node_schedule "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/ai/steps/generate-schedule.step.ts"
click node_places "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/places/places.service.ts"
click node_draft "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/plan/plan.service.ts"
click node_database "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/prisma/prisma.service.ts"
click node_workspace "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/workspace/workspace.service.ts"
click node_notifications "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/notification/notification.service.ts"
click node_payment "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/payment/payment.service.ts"
click node_admin "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/admin/admin.service.ts"
click node_budget "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/services/api-budget.service.ts"
click node_redis "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/shared/redis/redis.service.ts"
click node_guard "https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/auth/auth.guard.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_planui,node_apiclient,node_authui,node_visitor toneBlue
class node_authcontroller,node_authservice,node_emailverify,node_oauthaccounts,node_email,node_guard toneAmber
class node_plancontroller,node_planservice,node_parse,node_intent,node_placesearch,node_candidates,node_route,node_schedule,node_places,node_draft toneMint
class node_workspace,node_notifications,node_payment toneRose
class node_database,node_admin,node_budget,node_redis,node_toss toneIndigo
```

## Components

### Web application

- [Plan interface](https://github.com/jaylenyu/ai-planner/blob/main/frontend/src/app/plan/page.tsx): `frontend/src/app/plan/page.tsx`
- [API client](https://github.com/jaylenyu/ai-planner/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`
- [Auth hook](https://github.com/jaylenyu/ai-planner/blob/main/frontend/src/hooks/useAuth.ts): `frontend/src/hooks/useAuth.ts`

### Identity and access

- [Auth endpoints](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/auth/auth.controller.ts): `backend/src/modules/auth/auth.controller.ts`
- [Auth service](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/auth/auth.service.ts): `backend/src/modules/auth/auth.service.ts`
- [Email verification](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/auth/email-verification.service.ts): `backend/src/modules/auth/email-verification.service.ts`
- [OAuth accounts](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/auth/oauth-account.service.ts): `backend/src/modules/auth/oauth-account.service.ts`
- [Email delivery](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/email/email.service.ts): `backend/src/modules/email/email.service.ts`
- [JWT access guard](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/auth/auth.guard.ts): `backend/src/modules/auth/auth.guard.ts`

### Itinerary planning

- [Plan endpoints](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/plan/plan.controller.ts): `backend/src/modules/plan/plan.controller.ts`
- [Plan service](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/plan/plan.service.ts): `backend/src/modules/plan/plan.service.ts`
- [Parse request](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/ai/steps/parse-input.step.ts): `backend/src/modules/ai/steps/parse-input.step.ts`
- [Extract intent](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/ai/steps/extract-intent.step.ts): `backend/src/modules/ai/steps/extract-intent.step.ts`
- [Search places](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/ai/steps/search-places.step.ts): `backend/src/modules/ai/steps/search-places.step.ts`
- [Select candidates](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/ai/steps/select-candidates.step.ts): `backend/src/modules/ai/steps/select-candidates.step.ts`
- [Optimize route](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/ai/steps/optimize-route.step.ts): `backend/src/modules/ai/steps/optimize-route.step.ts`
- [Generate schedule](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/ai/steps/generate-schedule.step.ts): `backend/src/modules/ai/steps/generate-schedule.step.ts`
- [Place search service](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/places/places.service.ts): `backend/src/modules/places/places.service.ts`
- [Preview draft](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/plan/plan.service.ts): `backend/src/modules/plan/plan.service.ts`

### Sharing and billing

- [Workspace sharing](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/workspace/workspace.service.ts): `backend/src/modules/workspace/workspace.service.ts`
- [In-app notifications](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/notification/notification.service.ts): `backend/src/modules/notification/notification.service.ts`
- [Subscription payments](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/payment/payment.service.ts): `backend/src/modules/payment/payment.service.ts`

### Administration and platform

- [PostgreSQL data](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/prisma/prisma.service.ts): `backend/src/prisma/prisma.service.ts`
- [Admin operations](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/modules/admin/admin.service.ts): `backend/src/modules/admin/admin.service.ts`
- [API usage budgets](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/services/api-budget.service.ts): `backend/src/services/api-budget.service.ts`
- [Redis cache](https://github.com/jaylenyu/ai-planner/blob/main/backend/src/shared/redis/redis.service.ts): `backend/src/shared/redis/redis.service.ts`

### Other components

- **Planner user**
- **Toss Payments**

## Connections

- Planner user → Plan interface: requests itinerary
- Plan interface → API client: calls API
- API client → Plan endpoints: posts preview
- Planner user → Auth hook: signs in (evidence: `frontend/src/hooks/useAuth.ts`)
- Auth hook → API client: uses client (evidence: `frontend/src/hooks/useAuth.ts`)
- Auth endpoints → Auth service: delegates auth (evidence: `backend/src/modules/auth/auth.controller.ts`)
- Auth service → PostgreSQL data: reads and writes (evidence: `backend/src/modules/auth/auth.service.ts`)
- Auth service → Email verification: delegates verification (evidence: `backend/src/modules/auth/auth.service.ts`)
- Auth service → OAuth accounts: completes signup (evidence: `backend/src/modules/auth/auth.service.ts`)
- Auth service → Email delivery: sends messages (evidence: `backend/src/modules/auth/auth.service.ts`)
- Auth service → Redis cache: checks login state (evidence: `backend/src/modules/auth/auth.service.ts`)
- Email verification → Email delivery: sends codes (evidence: `backend/src/modules/auth/email-verification.service.ts`)
- Plan endpoints → Plan service: delegates plans (evidence: `backend/src/modules/plan/plan.controller.ts`)
- Plan service → Preview draft: holds preview
- Plan service → Parse request: runs pipeline
- Parse request → Extract intent: passes parsed input
- Extract intent → Search places: builds search intents
- Search places → Select candidates: passes search results
- Select candidates → Optimize route: passes candidates
- Optimize route → Generate schedule: passes ordered route
- Search places → Place search service: queries providers
- Plan service → PostgreSQL data: saves plans
- Workspace sharing → PostgreSQL data: persists sharing
- Subscription payments → PostgreSQL data: records payments (evidence: `backend/src/modules/payment/payment.service.ts`)
- Subscription payments → Toss Payments: confirms payments
- Subscription payments → Email delivery: sends receipts (evidence: `backend/src/modules/payment/payment.service.ts`)
- Admin operations → PostgreSQL data: queries operations (evidence: `backend/src/modules/admin/admin.service.ts`)
- Admin operations → API usage budgets: reports usage
- API usage budgets → PostgreSQL data: tracks usage (evidence: `backend/src/services/api-budget.service.ts`)
- Auth endpoints → JWT access guard: protects routes (evidence: `backend/src/modules/auth/auth.controller.ts`)
- Plan endpoints → JWT access guard: protects routes (evidence: `backend/src/modules/plan/plan.controller.ts`)
