# akshat-singh-kshatriya/loco architecture

> Architecture diagram of the GitHub repository akshat-singh-kshatriya/loco, 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/akshat-singh-kshatriya/loco
- Repository: https://github.com/akshat-singh-kshatriya/loco

## Overview

Loco is a conversational map-discovery app: users ask for places or routes by text or voice, the backend interprets the request and runs map tools, ranks results using session/profile preferences, then returns a response and map commands for the frontend. The README documents multilingual support, route discovery, hazards, and personalization. Source excerpts show the API wiring and tool loop; several frontend component-to-hook/API connections and some service internals were not sampled, so those links are omitted rather than inferred.

Main entry points: [`backend/routers/chat.py`](https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/routers/chat.py) (Chat orchestration), [`frontend/src/pages/AppPage.tsx`](https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/pages/AppPage.tsx) (Chat and map page), [`backend/main.py`](https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/main.py) (FastAPI app), [`backend/routers/session.py`](https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/routers/session.py) (Session and feedback API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend experience"]
  node_app_shell["App shell<br/>[App.tsx]"]
  node_app_page["Chat and map page<br/>[AppPage.tsx]"]
  node_chat_panel["Chat panel<br/>[ChatPanel.tsx]"]
  node_map_panel["Map panel<br/>[MapPanel.tsx]"]
  node_place_card["Place cards<br/>[PlaceCard.tsx]"]
  node_weight_panel["Ranking controls<br/>[WeightPanel.tsx]"]
  node_hazard_summary["Hazard summary<br/>[HazardSummary.tsx]"]
  node_chat_hook["Chat state<br/>[use-chat.ts]"]
  node_voice_button["Voice controls<br/>[VoiceButton.tsx]"]
  node_voice_hook["Voice capture<br/>[use-voice-input.ts]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_conversation["Conversation API"]
  node_api_app["FastAPI app<br/>[main.py]"]
  node_chat_route["Chat orchestration<br/>[chat.py]"]
  node_schemas["API and session models<br/>[schemas.py]"]
  node_session_route["Session and feedback API<br/>[session.py]"]
end

subgraph group_intelligence["Map and personalization"]
  node_groq_loop["LLM tool loop<br/>[groq_service.py]"]
  node_tool_handlers["Map tool handlers<br/>[tools.py]"]
  node_mappls["Map and route APIs<br/>[mappls_api.py]"]
  node_ranking["Place ranking<br/>[ranking.py]"]
  node_profiles[("User profiles<br/>[profile_store.py]")]
  node_sessions[("Session state<br/>[session_store.py]")]
end

subgraph group_voice["Voice and language"]
  node_voice_route["Speech transcription API<br/>[voice.py]"]
  node_tts_route["Speech synthesis API<br/>[tts.py]"]
  node_sarvam["Sarvam speech service<br/>[sarvam_service.py]"]
  node_language["Language support"]
end

node_visitor(("Map explorer"))
node_groq_external{{"Groq LLM"}}
node_mappls_external{{"Mappls services"}}
node_sarvam_external{{"Sarvam AI"}}

node_visitor -->|"opens app"| node_app_shell
node_app_shell -->|"routes to"| node_app_page
node_visitor -.->|"asks places"| node_chat_panel
node_chat_panel -.->|"uses chat state"| node_chat_hook
node_chat_hook -.->|"sends requests"| node_api_client
node_api_client -.->|"posts chat"| node_chat_route
node_api_app -->|"registers route"| node_chat_route
node_api_app -->|"registers route"| node_session_route
node_api_app -->|"registers route"| node_voice_route
node_api_app -->|"registers route"| node_tts_route
node_chat_route -->|"runs conversation"| node_groq_loop
node_chat_route -->|"handles language"| node_language
node_chat_route -->|"ranks results"| node_ranking
node_chat_route -->|"reads preferences"| node_profiles
node_chat_route -->|"loads state"| node_sessions
node_groq_loop -->|"requests completions"| node_groq_external
node_groq_loop -->|"dispatches tools"| node_tool_handlers
node_tool_handlers -->|"calls map tools"| node_mappls
node_mappls -->|"queries maps"| node_mappls_external
node_chat_route -->|"uses request models"| node_schemas
node_session_route -->|"updates sessions"| node_sessions
node_session_route -->|"updates profiles"| node_profiles
node_session_route -->|"adjusts preferences"| node_ranking
node_voice_route -->|"transcribes audio"| node_sarvam
node_tts_route -->|"synthesizes speech"| node_sarvam
node_sarvam -->|"uses speech API"| node_sarvam_external
node_voice_button -.->|"captures speech"| node_voice_hook
node_voice_hook -.->|"submits audio"| node_api_client
node_app_page -.->|"presents map"| node_map_panel
node_app_page -.->|"presents chat"| node_chat_panel
node_app_page -.->|"shows results"| node_place_card
node_app_page -.->|"adjusts ranking"| node_weight_panel
node_app_page -.->|"shows hazards"| node_hazard_summary

click node_app_shell "https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/App.tsx"
click node_app_page "https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/pages/AppPage.tsx"
click node_chat_panel "https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/components/app/ChatPanel.tsx"
click node_map_panel "https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/components/app/MapPanel.tsx"
click node_place_card "https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/components/app/PlaceCard.tsx"
click node_weight_panel "https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/components/app/WeightPanel.tsx"
click node_hazard_summary "https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/components/app/HazardSummary.tsx"
click node_chat_hook "https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/hooks/use-chat.ts"
click node_voice_button "https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/components/app/VoiceButton.tsx"
click node_voice_hook "https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/hooks/use-voice-input.ts"
click node_api_client "https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/lib/api.ts"
click node_api_app "https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/main.py"
click node_chat_route "https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/routers/chat.py"
click node_schemas "https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/models/schemas.py"
click node_groq_loop "https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/services/groq_service.py"
click node_tool_handlers "https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/mcp_server/tools.py"
click node_mappls "https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/services/mappls_api.py"
click node_ranking "https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/services/ranking.py"
click node_profiles "https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/services/profile_store.py"
click node_sessions "https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/services/session_store.py"
click node_session_route "https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/routers/session.py"
click node_voice_route "https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/routers/voice.py"
click node_tts_route "https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/routers/tts.py"
click node_sarvam "https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/services/sarvam_service.py"
click node_language "https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/services/language_service.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_app_shell,node_app_page,node_chat_panel,node_map_panel,node_place_card,node_weight_panel,node_hazard_summary,node_chat_hook,node_voice_button,node_voice_hook,node_api_client toneBlue
class node_api_app,node_chat_route,node_schemas,node_session_route toneAmber
class node_groq_loop,node_tool_handlers,node_mappls,node_ranking,node_profiles,node_sessions toneMint
class node_voice_route,node_tts_route,node_sarvam,node_language toneRose
class node_visitor,node_groq_external,node_mappls_external,node_sarvam_external toneIndigo
```

## Components

### Frontend experience

- [App shell](https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Chat and map page](https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/pages/AppPage.tsx): `frontend/src/pages/AppPage.tsx`
- [Chat panel](https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/components/app/ChatPanel.tsx): `frontend/src/components/app/ChatPanel.tsx`
- [Map panel](https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/components/app/MapPanel.tsx): `frontend/src/components/app/MapPanel.tsx`
- [Place cards](https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/components/app/PlaceCard.tsx): `frontend/src/components/app/PlaceCard.tsx`
- [Ranking controls](https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/components/app/WeightPanel.tsx): `frontend/src/components/app/WeightPanel.tsx`
- [Hazard summary](https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/components/app/HazardSummary.tsx): `frontend/src/components/app/HazardSummary.tsx`
- [Chat state](https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/hooks/use-chat.ts): `frontend/src/hooks/use-chat.ts`
- [Voice controls](https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/components/app/VoiceButton.tsx): `frontend/src/components/app/VoiceButton.tsx`
- [Voice capture](https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/hooks/use-voice-input.ts): `frontend/src/hooks/use-voice-input.ts`
- [API client](https://github.com/akshat-singh-kshatriya/loco/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`

### Conversation API

- [FastAPI app](https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/main.py): `backend/main.py`
- [Chat orchestration](https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/routers/chat.py): `backend/routers/chat.py`
- [API and session models](https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/models/schemas.py): `backend/models/schemas.py`
- [Session and feedback API](https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/routers/session.py): `backend/routers/session.py`

### Map and personalization

- [LLM tool loop](https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/services/groq_service.py): `backend/services/groq_service.py`
- [Map tool handlers](https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/mcp_server/tools.py): `backend/mcp_server/tools.py`
- [Map and route APIs](https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/services/mappls_api.py): `backend/services/mappls_api.py`
- [Place ranking](https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/services/ranking.py): `backend/services/ranking.py`
- [User profiles](https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/services/profile_store.py): `backend/services/profile_store.py`
- [Session state](https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/services/session_store.py): `backend/services/session_store.py`

### Voice and language

- [Speech transcription API](https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/routers/voice.py): `backend/routers/voice.py`
- [Speech synthesis API](https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/routers/tts.py): `backend/routers/tts.py`
- [Sarvam speech service](https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/services/sarvam_service.py): `backend/services/sarvam_service.py`
- [Language support](https://github.com/akshat-singh-kshatriya/loco/blob/main/backend/services/language_service.py): `backend/services/language_service.py`

### Other components

- **Map explorer**
- **Groq LLM**
- **Mappls services**
- **Sarvam AI**

## Connections

- Map explorer → App shell: opens app (evidence: `README.md`)
- App shell → Chat and map page: routes to (evidence: `frontend/src/App.tsx`)
- Map explorer → Chat panel: asks places
- Chat panel → Chat state: uses chat state
- Chat state → API client: sends requests
- API client → Chat orchestration: posts chat
- FastAPI app → Chat orchestration: registers route (evidence: `backend/main.py`)
- FastAPI app → Session and feedback API: registers route (evidence: `backend/main.py`)
- FastAPI app → Speech transcription API: registers route (evidence: `backend/main.py`)
- FastAPI app → Speech synthesis API: registers route (evidence: `backend/main.py`)
- Chat orchestration → LLM tool loop: runs conversation (evidence: `backend/routers/chat.py`)
- Chat orchestration → Language support: handles language (evidence: `backend/routers/chat.py`)
- Chat orchestration → Place ranking: ranks results (evidence: `backend/routers/chat.py`)
- Chat orchestration → User profiles: reads preferences (evidence: `backend/routers/chat.py`)
- Chat orchestration → Session state: loads state (evidence: `backend/routers/chat.py`)
- LLM tool loop → Groq LLM: requests completions (evidence: `README.md`)
- LLM tool loop → Map tool handlers: dispatches tools (evidence: `backend/services/groq_service.py`)
- Map tool handlers → Map and route APIs: calls map tools (evidence: `backend/mcp_server/tools.py`)
- Map and route APIs → Mappls services: queries maps (evidence: `README.md`)
- Chat orchestration → API and session models: uses request models (evidence: `backend/routers/chat.py`)
- Session and feedback API → Session state: updates sessions (evidence: `backend/routers/session.py`)
- Session and feedback API → User profiles: updates profiles (evidence: `backend/routers/session.py`)
- Session and feedback API → Place ranking: adjusts preferences (evidence: `backend/routers/session.py`)
- Speech transcription API → Sarvam speech service: transcribes audio (evidence: `backend/routers/voice.py`)
- Speech synthesis API → Sarvam speech service: synthesizes speech (evidence: `backend/routers/tts.py`)
- Sarvam speech service → Sarvam AI: uses speech API (evidence: `README.md`)
- Voice controls → Voice capture: captures speech
- Voice capture → API client: submits audio
- Chat and map page → Map panel: presents map
- Chat and map page → Chat panel: presents chat
- Chat and map page → Place cards: shows results
- Chat and map page → Ranking controls: adjusts ranking
- Chat and map page → Hazard summary: shows hazards
