# thinhinane-akriche/pa4iabd architecture

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

- Interactive diagram: https://gitdiagram.com/thinhinane-akriche/pa4iabd
- Repository: https://github.com/thinhinane-akriche/pa4iabd

## Overview

TravelBuddy is a full-stack conversational travel-planning assistant. Users register or sign in, then chat with a streaming LangGraph agent that can gather travel information, tailor results to a saved profile and generate itinerary PDFs; users can also manage profiles and saved voyages. The README documents the agent’s tool capabilities and PostgreSQL-backed session memory. The graph follows the documented product flow and sampled route/client references; unsampled route internals and some tool-to-provider details are not asserted.

Main entry points: [`backend/core/agent.py`](https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/core/agent.py) (LangGraph agent), [`frontend/src/app/lib/api.ts`](https://github.com/thinhinane-akriche/pa4iabd/blob/main/frontend/src/app/lib/api.ts) (API client), [`backend/main.py`](https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/main.py) (FastAPI application), [`backend/api/dependencies.py`](https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/api/dependencies.py) (Database access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_chat_ui["Chat interface<br/>[page.tsx]"]
  node_auth_ui["Sign-in and signup<br/>[page.tsx]"]
  node_profile_ui["Profile editor<br/>[page.tsx]"]
  node_voyages_ui["Saved voyages<br/>[page.tsx]"]
  node_sidebar["Conversation sidebar<br/>[Sidebar.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["API and identity"]
  node_fastapi["FastAPI application<br/>[main.py]"]
  node_auth_routes["Authentication routes<br/>[auth.py]"]
  node_chat_routes["Chat routes<br/>[chat.py]"]
  node_profile_routes["Profile routes<br/>[profile.py]"]
  node_voyage_routes["Voyage routes<br/>[voyages.py]"]
  node_db_access["Database access<br/>[dependencies.py]"]
end

subgraph group_agent["Travel agent"]
  node_agent_runtime["LangGraph agent<br/>[agent.py]"]
  node_llm["LLM provider factory<br/>[llm_factory.py]"]
  node_geo_context["Request location context<br/>[geo_context.py]"]
  node_travel_tools["Travel search and planning tools"]
  node_pdf["Itinerary PDF generator<br/>[pdf_generator.py]"]
  node_profile_tool["Travel profile tool<br/>[profile.py]"]
end

subgraph group_data["Travel data and state"]
  node_rag["Destination RAG<br/>[rag.py]"]
  node_wikivoyage["Wikivoyage loader"]
  node_postgres[("PostgreSQL")]
  node_chroma[("ChromaDB vector store")]
end

node_traveler(("Traveler"))
node_travel_services["Travel information providers"]

node_traveler -->|"plans trips"| node_chat_ui
node_traveler -->|"creates account"| node_auth_ui
node_traveler -->|"sets preferences"| node_profile_ui
node_traveler -->|"manages voyages"| node_voyages_ui
node_chat_ui -->|"streams chat"| node_api_client
node_auth_ui -->|"authenticates"| node_api_client
node_profile_ui -->|"updates profile"| node_api_client
node_voyages_ui -->|"loads voyages"| node_api_client
node_sidebar -->|"loads history"| node_api_client
node_api_client -->|"calls API"| node_fastapi
node_fastapi -->|"registers routes"| node_auth_routes
node_fastapi -->|"registers routes"| node_chat_routes
node_fastapi -->|"registers routes"| node_profile_routes
node_fastapi -->|"registers routes"| node_voyage_routes
node_auth_routes -->|"uses connections"| node_db_access
node_chat_routes -->|"uses dependencies"| node_db_access
node_profile_routes -->|"uses dependencies"| node_db_access
node_voyage_routes -->|"uses dependencies"| node_db_access
node_db_access -->|"reads and writes"| node_postgres
node_chat_routes -->|"sets location"| node_geo_context
node_chat_routes -.->|"dispatches chat"| node_agent_runtime
node_agent_runtime -->|"selects model"| node_llm
node_agent_runtime -->|"retrieves guidance"| node_rag
node_rag -->|"loads articles"| node_wikivoyage
node_rag -->|"indexes and searches"| node_chroma
node_agent_runtime -->|"calls tools"| node_travel_tools
node_agent_runtime -->|"generates itinerary PDF"| node_pdf
node_agent_runtime -->|"uses preferences"| node_profile_tool
node_agent_runtime -->|"persists session memory"| node_postgres
node_travel_tools -->|"fetches travel data"| node_travel_services

click node_chat_ui "https://github.com/thinhinane-akriche/pa4iabd/blob/main/frontend/src/app/chat/page.tsx"
click node_auth_ui "https://github.com/thinhinane-akriche/pa4iabd/blob/main/frontend/src/app/login/page.tsx"
click node_profile_ui "https://github.com/thinhinane-akriche/pa4iabd/blob/main/frontend/src/app/profile/page.tsx"
click node_voyages_ui "https://github.com/thinhinane-akriche/pa4iabd/blob/main/frontend/src/app/voyages/page.tsx"
click node_sidebar "https://github.com/thinhinane-akriche/pa4iabd/blob/main/frontend/src/app/components/Sidebar.tsx"
click node_api_client "https://github.com/thinhinane-akriche/pa4iabd/blob/main/frontend/src/app/lib/api.ts"
click node_fastapi "https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/main.py"
click node_auth_routes "https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/api/routes/auth.py"
click node_chat_routes "https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/api/routes/chat.py"
click node_profile_routes "https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/api/routes/profile.py"
click node_voyage_routes "https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/api/routes/voyages.py"
click node_db_access "https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/api/dependencies.py"
click node_agent_runtime "https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/core/agent.py"
click node_llm "https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/core/llm_factory.py"
click node_geo_context "https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/tools/geo_context.py"
click node_rag "https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/tools/rag.py"
click node_wikivoyage "https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/utils/wikivoyage_loader.py"
click node_travel_tools "https://github.com/thinhinane-akriche/pa4iabd/tree/main/backend/tools"
click node_pdf "https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/tools/pdf_generator.py"
click node_profile_tool "https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/tools/profile.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_chat_ui,node_auth_ui,node_profile_ui,node_voyages_ui,node_sidebar,node_api_client toneBlue
class node_fastapi,node_auth_routes,node_chat_routes,node_profile_routes,node_voyage_routes,node_db_access toneAmber
class node_agent_runtime,node_llm,node_geo_context,node_travel_tools,node_pdf,node_profile_tool toneMint
class node_rag,node_wikivoyage,node_postgres,node_chroma toneRose
class node_traveler,node_travel_services toneIndigo
```

## Components

### Web experience

- [Chat interface](https://github.com/thinhinane-akriche/pa4iabd/blob/main/frontend/src/app/chat/page.tsx): `frontend/src/app/chat/page.tsx`
- [Sign-in and signup](https://github.com/thinhinane-akriche/pa4iabd/blob/main/frontend/src/app/login/page.tsx): `frontend/src/app/login/page.tsx`
- [Profile editor](https://github.com/thinhinane-akriche/pa4iabd/blob/main/frontend/src/app/profile/page.tsx): `frontend/src/app/profile/page.tsx`
- [Saved voyages](https://github.com/thinhinane-akriche/pa4iabd/blob/main/frontend/src/app/voyages/page.tsx): `frontend/src/app/voyages/page.tsx`
- [Conversation sidebar](https://github.com/thinhinane-akriche/pa4iabd/blob/main/frontend/src/app/components/Sidebar.tsx): `frontend/src/app/components/Sidebar.tsx`
- [API client](https://github.com/thinhinane-akriche/pa4iabd/blob/main/frontend/src/app/lib/api.ts): `frontend/src/app/lib/api.ts`

### API and identity

- [FastAPI application](https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/main.py): `backend/main.py`
- [Authentication routes](https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/api/routes/auth.py): `backend/api/routes/auth.py`
- [Chat routes](https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/api/routes/chat.py): `backend/api/routes/chat.py`
- [Profile routes](https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/api/routes/profile.py): `backend/api/routes/profile.py`
- [Voyage routes](https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/api/routes/voyages.py): `backend/api/routes/voyages.py`
- [Database access](https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/api/dependencies.py): `backend/api/dependencies.py`

### Travel agent

- [LangGraph agent](https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/core/agent.py): `backend/core/agent.py`
- [LLM provider factory](https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/core/llm_factory.py): `backend/core/llm_factory.py`
- [Request location context](https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/tools/geo_context.py): `backend/tools/geo_context.py`
- [Travel search and planning tools](https://github.com/thinhinane-akriche/pa4iabd/tree/main/backend/tools): `backend/tools`
- [Itinerary PDF generator](https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/tools/pdf_generator.py): `backend/tools/pdf_generator.py`
- [Travel profile tool](https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/tools/profile.py): `backend/tools/profile.py`

### Travel data and state

- [Destination RAG](https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/tools/rag.py): `backend/tools/rag.py`
- [Wikivoyage loader](https://github.com/thinhinane-akriche/pa4iabd/blob/main/backend/utils/wikivoyage_loader.py): `backend/utils/wikivoyage_loader.py`
- **PostgreSQL**
- **ChromaDB vector store**

### Other components

- **Traveler**
- **Travel information providers**

## Connections

- Traveler → Chat interface: plans trips
- Traveler → Sign-in and signup: creates account
- Traveler → Profile editor: sets preferences
- Traveler → Saved voyages: manages voyages
- Chat interface → API client: streams chat (evidence: `frontend/src/app/chat/page.tsx`)
- Sign-in and signup → API client: authenticates (evidence: `frontend/src/app/login/page.tsx`)
- Profile editor → API client: updates profile (evidence: `frontend/src/app/profile/page.tsx`)
- Saved voyages → API client: loads voyages (evidence: `frontend/src/app/voyages/page.tsx`)
- Conversation sidebar → API client: loads history (evidence: `frontend/src/app/components/Sidebar.tsx`)
- API client → FastAPI application: calls API
- FastAPI application → Authentication routes: registers routes (evidence: `backend/main.py`)
- FastAPI application → Chat routes: registers routes (evidence: `backend/main.py`)
- FastAPI application → Profile routes: registers routes (evidence: `backend/main.py`)
- FastAPI application → Voyage routes: registers routes (evidence: `backend/main.py`)
- Authentication routes → Database access: uses connections (evidence: `backend/api/routes/auth.py`)
- Chat routes → Database access: uses dependencies (evidence: `backend/api/routes/chat.py`)
- Profile routes → Database access: uses dependencies (evidence: `backend/api/routes/profile.py`)
- Voyage routes → Database access: uses dependencies (evidence: `backend/api/routes/voyages.py`)
- Database access → PostgreSQL: reads and writes
- Chat routes → Request location context: sets location (evidence: `backend/tools/geo_context.py`)
- Chat routes → LangGraph agent: dispatches chat
- LangGraph agent → LLM provider factory: selects model (evidence: `backend/core/agent.py`)
- LangGraph agent → Destination RAG: retrieves guidance (evidence: `backend/core/agent.py`)
- Destination RAG → Wikivoyage loader: loads articles (evidence: `backend/tools/rag.py`)
- Destination RAG → ChromaDB vector store: indexes and searches
- LangGraph agent → Travel search and planning tools: calls tools (evidence: `backend/core/agent.py`)
- LangGraph agent → Itinerary PDF generator: generates itinerary PDF (evidence: `backend/core/agent.py`)
- LangGraph agent → Travel profile tool: uses preferences (evidence: `backend/core/agent.py`)
- LangGraph agent → PostgreSQL: persists session memory
- Travel search and planning tools → Travel information providers: fetches travel data
