# pheuangvichith/nextpath01 architecture

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

- Interactive diagram: https://gitdiagram.com/pheuangvichith/nextpath01
- Repository: https://github.com/pheuangvichith/nextpath01

## Overview

PATHAI is a Lao-first self-reflection and career-exploration application, not an automated career-decision system. Its main journey takes a young person from session setup through a versioned questionnaire, answer persistence and completion, then report generation and reflection. The backend supports distinct v4 profile-correlation scoring and a legacy Signal Engine, plus feedback and report export. The graph uses sampled frontend and service excerpts and README capabilities; unsampled router wiring is shown only where documented or marked unverified.

Main entry points: [`backend/app/routers`](https://github.com/pheuangvichith/nextpath01/tree/main/backend/app/routers) (API routers), [`app/assessment/page.tsx`](https://github.com/pheuangvichith/nextpath01/blob/main/app/assessment/page.tsx) (Questionnaire), [`backend/app/services/session_service.py`](https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/services/session_service.py) (Session lifecycle), [`backend/app/services/report_service.py`](https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/services/report_service.py) (Report orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_journey["Reflection journey"]
  node_landing["Start experience<br/>[page.tsx]"]
  node_introduction["Introduction<br/>[page.tsx]"]
  node_assessment["Questionnaire<br/>[page.tsx]"]
  node_processing["Processing status<br/>[page.tsx]"]
  node_report_ui["Reflection report<br/>[page.tsx]"]
  node_feedback_ui["Feedback<br/>[page.tsx]"]
end

subgraph group_frontend["Web client"]
  node_session_api["Session client<br/>[session.ts]"]
  node_report_api["Report client<br/>[report.ts]"]
  node_feedback_api["Feedback client<br/>[feedback.ts]"]
  node_drafts["Local drafts<br/>[draft.ts]"]
  node_session_state["Session state<br/>[useSession.ts]"]
end

subgraph group_backend["API and sessions"]
  node_fastapi["FastAPI application<br/>[main.py]"]
  node_routers["API routers"]
  node_session_service["Session lifecycle<br/>[session_service.py]"]
  node_answer_service["Answer handling<br/>[answer_service.py]"]
  node_feedback_service["Feedback handling"]
end

subgraph group_insights["Scoring and reports"]
  node_report_service["Report orchestration<br/>[report_service.py]"]
  node_v4_report["V4 report adapter"]
  node_v4_scoring["V4 profile scoring<br/>[scoring.py]"]
  node_legacy_engine["Legacy Signal Engine<br/>[signal_engine.py]"]
  node_ds_engine["Reflection DS engine<br/>[engine.py]"]
end

subgraph group_storage["Persistence"]
  node_database[("SQL database<br/>[database.py]")]
  node_answer_model["Answer records<br/>[answer.py]"]
  node_session_model["Session records<br/>[session.py]"]
end

node_youth(("Youth"))

node_youth -->|"starts"| node_landing
node_landing -.->|"guides to"| node_introduction
node_youth -->|"answers"| node_assessment
node_assessment -->|"saves locally"| node_drafts
node_assessment -->|"sends answers"| node_session_api
node_assessment -->|"navigates to"| node_processing
node_processing -.->|"checks status"| node_session_api
node_session_api -->|"calls session API"| node_routers
node_report_ui -->|"requests report"| node_report_api
node_report_api -.->|"calls report API"| node_routers
node_feedback_ui -.->|"submits feedback"| node_feedback_api
node_feedback_api -.->|"calls feedback API"| node_routers
node_fastapi -->|"registers routes"| node_routers
node_routers -.->|"dispatches session work"| node_session_service
node_routers -.->|"dispatches answer work"| node_answer_service
node_routers -.->|"dispatches feedback work"| node_feedback_service
node_routers -.->|"dispatches report work"| node_report_service
node_session_service -->|"reads and updates"| node_session_model
node_session_service -->|"loads answers"| node_answer_model
node_session_service -->|"uses database session"| node_database
node_report_service -->|"uses v4 adapter"| node_v4_report
node_report_service -->|"uses legacy evaluation"| node_ds_engine
node_v4_report -.->|"adapts scoring"| node_v4_scoring
node_ds_engine -.->|"evaluates signals"| node_legacy_engine
node_report_service -->|"reads answers"| node_answer_model
node_session_state -.->|"provides session state"| node_assessment
node_report_ui -->|"presents reflection"| node_youth
node_feedback_ui -.->|"collects feedback"| node_youth

click node_landing "https://github.com/pheuangvichith/nextpath01/blob/main/app/page.tsx"
click node_introduction "https://github.com/pheuangvichith/nextpath01/blob/main/app/introduction/page.tsx"
click node_assessment "https://github.com/pheuangvichith/nextpath01/blob/main/app/assessment/page.tsx"
click node_processing "https://github.com/pheuangvichith/nextpath01/blob/main/app/processing/page.tsx"
click node_report_ui "https://github.com/pheuangvichith/nextpath01/blob/main/app/report/page.tsx"
click node_feedback_ui "https://github.com/pheuangvichith/nextpath01/blob/main/app/feedback/page.tsx"
click node_session_api "https://github.com/pheuangvichith/nextpath01/blob/main/api/session.ts"
click node_report_api "https://github.com/pheuangvichith/nextpath01/blob/main/api/report.ts"
click node_feedback_api "https://github.com/pheuangvichith/nextpath01/blob/main/api/feedback.ts"
click node_drafts "https://github.com/pheuangvichith/nextpath01/blob/main/utils/draft.ts"
click node_session_state "https://github.com/pheuangvichith/nextpath01/blob/main/hooks/useSession.ts"
click node_fastapi "https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/main.py"
click node_routers "https://github.com/pheuangvichith/nextpath01/tree/main/backend/app/routers"
click node_session_service "https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/services/session_service.py"
click node_answer_service "https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/services/answer_service.py"
click node_feedback_service "https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/services/feedback_service.py"
click node_report_service "https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/services/report_service.py"
click node_v4_report "https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/services/v4_report_service.py"
click node_v4_scoring "https://github.com/pheuangvichith/nextpath01/blob/main/backend/v4.0/scoring.py"
click node_legacy_engine "https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/ds/signal_engine.py"
click node_ds_engine "https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/ds/engine.py"
click node_database "https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/database.py"
click node_answer_model "https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/models/answer.py"
click node_session_model "https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/models/session.py"

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_landing,node_introduction,node_assessment,node_processing,node_report_ui,node_feedback_ui toneBlue
class node_session_api,node_report_api,node_feedback_api,node_drafts,node_session_state toneAmber
class node_fastapi,node_routers,node_session_service,node_answer_service,node_feedback_service toneMint
class node_report_service,node_v4_report,node_v4_scoring,node_legacy_engine,node_ds_engine toneRose
class node_database,node_answer_model,node_session_model,node_youth toneIndigo
```

## Components

### Reflection journey

- [Start experience](https://github.com/pheuangvichith/nextpath01/blob/main/app/page.tsx): `app/page.tsx`
- [Introduction](https://github.com/pheuangvichith/nextpath01/blob/main/app/introduction/page.tsx): `app/introduction/page.tsx`
- [Questionnaire](https://github.com/pheuangvichith/nextpath01/blob/main/app/assessment/page.tsx): `app/assessment/page.tsx`
- [Processing status](https://github.com/pheuangvichith/nextpath01/blob/main/app/processing/page.tsx): `app/processing/page.tsx`
- [Reflection report](https://github.com/pheuangvichith/nextpath01/blob/main/app/report/page.tsx): `app/report/page.tsx`
- [Feedback](https://github.com/pheuangvichith/nextpath01/blob/main/app/feedback/page.tsx): `app/feedback/page.tsx`

### Web client

- [Session client](https://github.com/pheuangvichith/nextpath01/blob/main/api/session.ts): `api/session.ts`
- [Report client](https://github.com/pheuangvichith/nextpath01/blob/main/api/report.ts): `api/report.ts`
- [Feedback client](https://github.com/pheuangvichith/nextpath01/blob/main/api/feedback.ts): `api/feedback.ts`
- [Local drafts](https://github.com/pheuangvichith/nextpath01/blob/main/utils/draft.ts): `utils/draft.ts`
- [Session state](https://github.com/pheuangvichith/nextpath01/blob/main/hooks/useSession.ts): `hooks/useSession.ts`

### API and sessions

- [FastAPI application](https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/main.py): `backend/app/main.py`
- [API routers](https://github.com/pheuangvichith/nextpath01/tree/main/backend/app/routers): `backend/app/routers`
- [Session lifecycle](https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/services/session_service.py): `backend/app/services/session_service.py`
- [Answer handling](https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/services/answer_service.py): `backend/app/services/answer_service.py`
- [Feedback handling](https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/services/feedback_service.py): `backend/app/services/feedback_service.py`

### Scoring and reports

- [Report orchestration](https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/services/report_service.py): `backend/app/services/report_service.py`
- [V4 report adapter](https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/services/v4_report_service.py): `backend/app/services/v4_report_service.py`
- [V4 profile scoring](https://github.com/pheuangvichith/nextpath01/blob/main/backend/v4.0/scoring.py): `backend/v4.0/scoring.py`
- [Legacy Signal Engine](https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/ds/signal_engine.py): `backend/app/ds/signal_engine.py`
- [Reflection DS engine](https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/ds/engine.py): `backend/app/ds/engine.py`

### Persistence

- [SQL database](https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/database.py): `backend/app/database.py`
- [Answer records](https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/models/answer.py): `backend/app/models/answer.py`
- [Session records](https://github.com/pheuangvichith/nextpath01/blob/main/backend/app/models/session.py): `backend/app/models/session.py`

### Other components

- **Youth**

## Connections

- Youth → Start experience: starts (evidence: `README.md`)
- Start experience → Introduction: guides to
- Youth → Questionnaire: answers (evidence: `app/assessment/page.tsx`)
- Questionnaire → Local drafts: saves locally (evidence: `app/assessment/page.tsx`)
- Questionnaire → Session client: sends answers (evidence: `app/assessment/page.tsx`)
- Questionnaire → Processing status: navigates to (evidence: `app/assessment/page.tsx`)
- Processing status → Session client: checks status (evidence: `app/processing/page.tsx`)
- Session client → API routers: calls session API (evidence: `api/session.ts`)
- Reflection report → Report client: requests report (evidence: `app/report/page.tsx`)
- Report client → API routers: calls report API
- Feedback → Feedback client: submits feedback (evidence: `app/feedback/page.tsx`)
- Feedback client → API routers: calls feedback API
- FastAPI application → API routers: registers routes (evidence: `backend/app/main.py`)
- API routers → Session lifecycle: dispatches session work
- API routers → Answer handling: dispatches answer work
- API routers → Feedback handling: dispatches feedback work
- API routers → Report orchestration: dispatches report work
- Session lifecycle → Session records: reads and updates (evidence: `backend/app/services/session_service.py`)
- Session lifecycle → Answer records: loads answers (evidence: `backend/app/services/session_service.py`)
- Session lifecycle → SQL database: uses database session (evidence: `backend/app/database.py`)
- Report orchestration → V4 report adapter: uses v4 adapter (evidence: `backend/app/services/report_service.py`)
- Report orchestration → Reflection DS engine: uses legacy evaluation (evidence: `backend/app/services/report_service.py`)
- V4 report adapter → V4 profile scoring: adapts scoring
- Reflection DS engine → Legacy Signal Engine: evaluates signals
- Report orchestration → Answer records: reads answers (evidence: `backend/app/services/report_service.py`)
- Session state → Questionnaire: provides session state (evidence: `app/assessment/page.tsx`)
- Reflection report → Youth: presents reflection (evidence: `README.md`)
- Feedback → Youth: collects feedback
