# tonbunheng/ai_chat_assistant architecture

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

- Interactive diagram: https://gitdiagram.com/tonbunheng/ai_chat_assistant
- Repository: https://github.com/tonbunheng/ai_chat_assistant

## Overview

Angkor Verse AI is a Cambodia-focused tourism assistant with a Vue chat interface and FastAPI backend. A visitor submits a question in the chat; the client calls the backend, which classifies the request, gathers tourism knowledge or intent-specific information, selects an AI execution mode, and returns a response rendered with structured cards. Separate documented capabilities include itinerary planning, recommendations, weather, currency, events, and place lookup. The principal chat-route wiring and several integrations were not sampled, so uncertain links are dashed; README-described capabilities are retained without asserting unseen implementation details.

Main entry points: [`backend/app/api/routes/tourism_routes.py`](https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/api/routes/tourism_routes.py) (Tourism routes), [`backend/app/services/rag_service.py`](https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/rag_service.py) (RAG orchestrator), [`frontend/src/services/chatService.js`](https://github.com/tonbunheng/ai_chat_assistant/blob/main/frontend/src/services/chatService.js) (Chat service), [`backend/app/services/recommendation_engine.py`](https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/recommendation_engine.py) (Recommendations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_chat_page["Chat page<br/>[ChatPage.vue]"]
  node_chat_service["Chat service<br/>[chatService.js]"]
  node_chat_views["Chat views<br/>[ChatMessage.vue]"]
end

subgraph group_api["API layer"]
  node_chat_api["Chat API<br/>[chat.py]"]
  node_tourism_routes["Tourism routes<br/>[tourism_routes.py]"]
end

subgraph group_assistant["Chat processing"]
  node_rag["RAG orchestrator<br/>[rag_service.py]"]
  node_intent["Intent detection<br/>[intent_service.py]"]
  node_language["Language handling"]
  node_memory[("Conversation memory<br/>[memory_service.py]")]
  node_knowledge["Offline knowledge"]
end

subgraph group_tourism["Tourism capabilities"]
  node_tourism_data[("Tourism catalogue<br/>[tourism_service.py]")]
  node_matching["Semantic matching"]
  node_embedding["Embedding service"]
  node_itinerary["Itinerary planner"]
  node_recommendations["Recommendations"]
  node_weather["Weather service<br/>[weather_service.py]"]
  node_currency["Currency service"]
  node_events["Events service<br/>[events_service.py]"]
  node_places["Places service<br/>[places_service.py]"]
end

subgraph group_providers["AI and data providers"]
  node_ai_router["AI routing<br/>[ai_router.py]"]
  node_online_ai["Gemini provider<br/>[gemini_service.py]"]
  node_offline_ai["Ollama provider<br/>[ollama_service.py]"]
  node_live_services["Live data providers"]
end

node_visitor(("Visitor"))

node_visitor -->|"asks"| node_chat_page
node_chat_page -->|"submits message"| node_chat_service
node_chat_service -.->|"sends HTTP request"| node_chat_api
node_chat_api -.->|"processes chat"| node_rag
node_rag -->|"classifies request"| node_intent
node_rag -->|"handles language"| node_language
node_rag -->|"reads and updates"| node_memory
node_rag -.->|"selects provider"| node_ai_router
node_ai_router -.->|"dispatches online"| node_online_ai
node_ai_router -.->|"dispatches offline"| node_offline_ai
node_rag -.->|"uses fallback"| node_knowledge
node_rag -.->|"retrieves knowledge"| node_tourism_data
node_rag -->|"matches tourism"| node_matching
node_matching -->|"encodes queries"| node_embedding
node_chat_views -->|"renders answer"| node_visitor
node_chat_service -.->|"requests tourism APIs"| node_tourism_routes
node_tourism_routes -->|"generates itinerary"| node_itinerary
node_itinerary -->|"gets exchange rate"| node_currency
node_tourism_routes -->|"gets forecast"| node_weather
node_tourism_routes -->|"gets conversion rate"| node_currency
node_tourism_routes -->|"retrieves events"| node_events
node_tourism_routes -->|"retrieves places"| node_places
node_tourism_routes -->|"ranks attractions"| node_recommendations
node_recommendations -->|"reads catalogue"| node_tourism_data
node_recommendations -->|"considers weather"| node_weather
node_tourism_routes -.->|"uses live integrations"| node_live_services

click node_chat_page "https://github.com/tonbunheng/ai_chat_assistant/blob/main/frontend/src/pages/ChatPage.vue"
click node_chat_service "https://github.com/tonbunheng/ai_chat_assistant/blob/main/frontend/src/services/chatService.js"
click node_chat_views "https://github.com/tonbunheng/ai_chat_assistant/blob/main/frontend/src/components/chat/ChatMessage.vue"
click node_chat_api "https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/api/routes/chat.py"
click node_tourism_routes "https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/api/routes/tourism_routes.py"
click node_rag "https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/rag_service.py"
click node_intent "https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/intent_service.py"
click node_language "https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/language_service.py"
click node_memory "https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/memory_service.py"
click node_ai_router "https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/ai_router.py"
click node_online_ai "https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/online/gemini_service.py"
click node_offline_ai "https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/offline/ollama_service.py"
click node_knowledge "https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/offline/offline_knowledge_service.py"
click node_tourism_data "https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/tourism_service.py"
click node_matching "https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/matching_service.py"
click node_embedding "https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/embedding_service.py"
click node_itinerary "https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/itinerary_engine.py"
click node_recommendations "https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/recommendation_engine.py"
click node_weather "https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/weather_service.py"
click node_currency "https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/currency_service.py"
click node_events "https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/events_service.py"
click node_places "https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/places_service.py"
click node_live_services "https://github.com/tonbunheng/ai_chat_assistant/tree/main/backend/app/services/online"

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_page,node_chat_service,node_chat_views toneBlue
class node_chat_api,node_tourism_routes toneAmber
class node_rag,node_intent,node_language,node_memory,node_knowledge toneMint
class node_tourism_data,node_matching,node_embedding,node_itinerary,node_recommendations,node_weather,node_currency,node_events,node_places toneRose
class node_ai_router,node_online_ai,node_offline_ai,node_live_services,node_visitor toneIndigo
```

## Components

### Web client

- [Chat page](https://github.com/tonbunheng/ai_chat_assistant/blob/main/frontend/src/pages/ChatPage.vue): `frontend/src/pages/ChatPage.vue`
- [Chat service](https://github.com/tonbunheng/ai_chat_assistant/blob/main/frontend/src/services/chatService.js): `frontend/src/services/chatService.js`
- [Chat views](https://github.com/tonbunheng/ai_chat_assistant/blob/main/frontend/src/components/chat/ChatMessage.vue): `frontend/src/components/chat/ChatMessage.vue`

### API layer

- [Chat API](https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/api/routes/chat.py): `backend/app/api/routes/chat.py`
- [Tourism routes](https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/api/routes/tourism_routes.py): `backend/app/api/routes/tourism_routes.py`

### Chat processing

- [RAG orchestrator](https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/rag_service.py): `backend/app/services/rag_service.py`
- [Intent detection](https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/intent_service.py): `backend/app/services/intent_service.py`
- [Language handling](https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/language_service.py): `backend/app/services/language_service.py`
- [Conversation memory](https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/memory_service.py): `backend/app/services/memory_service.py`
- [Offline knowledge](https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/offline/offline_knowledge_service.py): `backend/app/services/offline/offline_knowledge_service.py`

### Tourism capabilities

- [Tourism catalogue](https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/tourism_service.py): `backend/app/services/tourism_service.py`
- [Semantic matching](https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/matching_service.py): `backend/app/services/matching_service.py`
- [Embedding service](https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/embedding_service.py): `backend/app/services/embedding_service.py`
- [Itinerary planner](https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/itinerary_engine.py): `backend/app/services/itinerary_engine.py`
- [Recommendations](https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/recommendation_engine.py): `backend/app/services/recommendation_engine.py`
- [Weather service](https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/weather_service.py): `backend/app/services/weather_service.py`
- [Currency service](https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/currency_service.py): `backend/app/services/currency_service.py`
- [Events service](https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/events_service.py): `backend/app/services/events_service.py`
- [Places service](https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/places_service.py): `backend/app/services/places_service.py`

### AI and data providers

- [AI routing](https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/ai_router.py): `backend/app/services/ai_router.py`
- [Gemini provider](https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/online/gemini_service.py): `backend/app/services/online/gemini_service.py`
- [Ollama provider](https://github.com/tonbunheng/ai_chat_assistant/blob/main/backend/app/services/offline/ollama_service.py): `backend/app/services/offline/ollama_service.py`
- [Live data providers](https://github.com/tonbunheng/ai_chat_assistant/tree/main/backend/app/services/online): `backend/app/services/online`

### Other components

- **Visitor**

## Connections

- Visitor → Chat page: asks (evidence: `README.md`)
- Chat page → Chat service: submits message (evidence: `frontend/src/pages/ChatPage.vue`)
- Chat service → Chat API: sends HTTP request
- Chat API → RAG orchestrator: processes chat
- RAG orchestrator → Intent detection: classifies request (evidence: `backend/app/services/rag_service.py`)
- RAG orchestrator → Language handling: handles language (evidence: `backend/app/services/rag_service.py`)
- RAG orchestrator → Conversation memory: reads and updates (evidence: `backend/app/services/rag_service.py`)
- RAG orchestrator → AI routing: selects provider
- AI routing → Gemini provider: dispatches online
- AI routing → Ollama provider: dispatches offline
- RAG orchestrator → Offline knowledge: uses fallback
- RAG orchestrator → Tourism catalogue: retrieves knowledge
- RAG orchestrator → Semantic matching: matches tourism (evidence: `backend/app/services/rag_service.py`)
- Semantic matching → Embedding service: encodes queries (evidence: `backend/app/services/matching_service.py`)
- Chat views → Visitor: renders answer (evidence: `frontend/src/components/chat/ChatMessage.vue`)
- Chat service → Tourism routes: requests tourism APIs
- Tourism routes → Itinerary planner: generates itinerary (evidence: `backend/app/api/routes/tourism_routes.py`)
- Itinerary planner → Currency service: gets exchange rate (evidence: `backend/app/services/itinerary_engine.py`)
- Tourism routes → Weather service: gets forecast (evidence: `backend/app/api/routes/tourism_routes.py`)
- Tourism routes → Currency service: gets conversion rate (evidence: `backend/app/api/routes/tourism_routes.py`)
- Tourism routes → Events service: retrieves events (evidence: `backend/app/api/routes/tourism_routes.py`)
- Tourism routes → Places service: retrieves places (evidence: `backend/app/api/routes/tourism_routes.py`)
- Tourism routes → Recommendations: ranks attractions (evidence: `backend/app/api/routes/tourism_routes.py`)
- Recommendations → Tourism catalogue: reads catalogue (evidence: `backend/app/services/recommendation_engine.py`)
- Recommendations → Weather service: considers weather (evidence: `backend/app/services/recommendation_engine.py`)
- Tourism routes → Live data providers: uses live integrations
