# cneuralnetwork/safar-autonomous-travel architecture

> Architecture diagram of the GitHub repository cneuralnetwork/safar-autonomous-travel, 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/cneuralnetwork/safar-autonomous-travel
- Repository: https://github.com/cneuralnetwork/safar-autonomous-travel

## Overview

Safar is a mobile-first conversational travel planner. A traveller signs in, describes a trip, resolves missing details in chat, and chooses outbound, return, and stay options before the backend validates constraints and produces an itinerary. The plan can be exported as a calendar file; Safar does not book travel. The README documents realtime updates and persisted, resumable runs. Source excerpts support the backend’s main wiring, but do not expose every mobile or orchestration call, so some documented links use the README as evidence.

Main entry points: [`backend/app/main.py`](https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/main.py) (FastAPI routes), [`mobile/src/screens/AppShell.tsx`](https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/mobile/src/screens/AppShell.tsx) (Mobile app), [`backend/app/orchestrator.py`](https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/orchestrator.py) (Run orchestrator), [`backend/app/store.py`](https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/store.py) (Run and user store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Mobile experience"]
  node_mobile_app["Mobile app<br/>[AppShell.tsx]"]
  node_chat_ui["Conversation UI"]
  node_map_ui["Route maps<br/>[ItineraryMap.tsx]"]
  node_mobile_api["API client<br/>[api.ts]"]
  node_mobile_auth["Sign-in UI<br/>[AuthProvider.tsx]"]
  node_calendar_export["Calendar file export<br/>[calendarExport.ts]"]
end

subgraph group_api["API and identity"]
  node_fastapi["FastAPI routes<br/>[main.py]"]
  node_auth_bridge["Google auth bridge<br/>[auth.py]"]
end

subgraph group_agent["Planning agent"]
  node_orchestrator["Run orchestrator<br/>[orchestrator.py]"]
  node_interpreter["Request interpreter<br/>[interpreter.py]"]
  node_sarvam_agent["Sarvam agent<br/>[agent_model.py]"]
  node_task_models["Travel and run models<br/>[models.py]"]
end

subgraph group_travel["Travel planning"]
  node_travel_registry["Travel tool registry<br/>[travel_tools.py]"]
  node_constraint_solver["Constraint solver<br/>[solver.py]"]
  node_itinerary["Itinerary composer<br/>[itinerary.py]"]
end

subgraph group_state["Persistence and export"]
  node_store[("Run and user store<br/>[store.py]")]
  node_calendar_service["Calendar integration"]
end

node_traveller(("Traveller"))
node_google["Google identity"]
node_supabase_auth["Supabase Auth"]
node_travel_providers["Travel data providers"]
node_postgres[("Supabase Postgres")]
node_google_calendar["Google Calendar"]

node_traveller -->|"plans a trip"| node_mobile_app
node_mobile_app -->|"signs in"| node_mobile_auth
node_mobile_app -.->|"converses through"| node_chat_ui
node_mobile_app -->|"sends requests"| node_mobile_api
node_mobile_api -->|"calls over HTTPS"| node_fastapi
node_mobile_app -.->|"views routes"| node_map_ui
node_mobile_app -.->|"exports plan"| node_calendar_export
node_mobile_auth -->|"starts sign-in"| node_fastapi
node_fastapi -->|"routes OAuth"| node_auth_bridge
node_auth_bridge -->|"exchanges identity"| node_google
node_auth_bridge -->|"creates session"| node_supabase_auth
node_fastapi -->|"dispatches runs"| node_orchestrator
node_fastapi -->|"reads run events"| node_store
node_fastapi -->|"configures tools"| node_travel_registry
node_fastapi -->|"configures interpreter"| node_interpreter
node_orchestrator -->|"interprets turns"| node_interpreter
node_interpreter -->|"requests interpretation"| node_sarvam_agent
node_orchestrator -->|"plans and replans"| node_sarvam_agent
node_orchestrator -->|"uses run schemas"| node_task_models
node_orchestrator -->|"dispatches searches"| node_travel_registry
node_travel_registry -->|"queries providers"| node_travel_providers
node_orchestrator -->|"checks constraints"| node_constraint_solver
node_orchestrator -->|"composes itinerary"| node_itinerary
node_orchestrator -->|"persists run state"| node_store
node_store -->|"reads and writes"| node_postgres
node_mobile_app -->|"subscribes to updates"| node_postgres
node_mobile_app -->|"catches up events"| node_fastapi
node_fastapi -.->|"routes calendar actions"| node_calendar_service
node_calendar_service -->|"stores connection tokens"| node_store
node_calendar_service -->|"writes itinerary events"| node_google_calendar

click node_mobile_app "https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/mobile/src/screens/AppShell.tsx"
click node_chat_ui "https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/mobile/src/components/MessageRenderer.tsx"
click node_map_ui "https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/mobile/src/components/ItineraryMap.tsx"
click node_mobile_api "https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/mobile/src/lib/api.ts"
click node_mobile_auth "https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/mobile/src/auth/AuthProvider.tsx"
click node_calendar_export "https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/mobile/src/lib/calendarExport.ts"
click node_fastapi "https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/main.py"
click node_auth_bridge "https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/auth.py"
click node_orchestrator "https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/orchestrator.py"
click node_interpreter "https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/interpreter.py"
click node_sarvam_agent "https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/agent_model.py"
click node_task_models "https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/models.py"
click node_travel_registry "https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/travel_tools.py"
click node_constraint_solver "https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/solver.py"
click node_itinerary "https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/itinerary.py"
click node_store "https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/store.py"
click node_postgres "https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/supabase/migrations/20260725111310_initial.sql"
click node_calendar_service "https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/calendar_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_mobile_app,node_chat_ui,node_map_ui,node_mobile_api,node_mobile_auth,node_calendar_export toneBlue
class node_fastapi,node_auth_bridge,node_postgres toneAmber
class node_orchestrator,node_interpreter,node_sarvam_agent,node_task_models toneMint
class node_travel_registry,node_constraint_solver,node_itinerary toneRose
class node_store,node_calendar_service,node_traveller,node_google,node_supabase_auth,node_travel_providers,node_google_calendar toneIndigo
```

## Components

### Mobile experience

- [Mobile app](https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/mobile/src/screens/AppShell.tsx): `mobile/src/screens/AppShell.tsx`
- [Conversation UI](https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/mobile/src/components/MessageRenderer.tsx): `mobile/src/components/MessageRenderer.tsx`
- [Route maps](https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/mobile/src/components/ItineraryMap.tsx): `mobile/src/components/ItineraryMap.tsx`
- [API client](https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/mobile/src/lib/api.ts): `mobile/src/lib/api.ts`
- [Sign-in UI](https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/mobile/src/auth/AuthProvider.tsx): `mobile/src/auth/AuthProvider.tsx`
- [Calendar file export](https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/mobile/src/lib/calendarExport.ts): `mobile/src/lib/calendarExport.ts`

### API and identity

- [FastAPI routes](https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/main.py): `backend/app/main.py`
- [Google auth bridge](https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/auth.py): `backend/app/auth.py`

### Planning agent

- [Run orchestrator](https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/orchestrator.py): `backend/app/orchestrator.py`
- [Request interpreter](https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/interpreter.py): `backend/app/interpreter.py`
- [Sarvam agent](https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/agent_model.py): `backend/app/agent_model.py`
- [Travel and run models](https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/models.py): `backend/app/models.py`

### Travel planning

- [Travel tool registry](https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/travel_tools.py): `backend/app/travel_tools.py`
- [Constraint solver](https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/solver.py): `backend/app/solver.py`
- [Itinerary composer](https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/itinerary.py): `backend/app/itinerary.py`

### Persistence and export

- [Run and user store](https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/store.py): `backend/app/store.py`
- [Calendar integration](https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/backend/app/calendar_service.py): `backend/app/calendar_service.py`

### Other components

- **Traveller**
- **Google identity**
- **Supabase Auth**
- **Travel data providers**
- [Supabase Postgres](https://github.com/cneuralnetwork/safar-autonomous-travel/blob/main/supabase/migrations/20260725111310_initial.sql): `supabase/migrations/20260725111310_initial.sql`
- **Google Calendar**

## Connections

- Traveller → Mobile app: plans a trip (evidence: `README.md`)
- Mobile app → Sign-in UI: signs in (evidence: `README.md`)
- Mobile app → Conversation UI: converses through
- Mobile app → API client: sends requests (evidence: `README.md`)
- API client → FastAPI routes: calls over HTTPS (evidence: `README.md`)
- Mobile app → Route maps: views routes
- Mobile app → Calendar file export: exports plan
- Sign-in UI → FastAPI routes: starts sign-in (evidence: `README.md`)
- FastAPI routes → Google auth bridge: routes OAuth (evidence: `backend/app/main.py`)
- Google auth bridge → Google identity: exchanges identity (evidence: `backend/app/auth.py`)
- Google auth bridge → Supabase Auth: creates session (evidence: `backend/app/auth.py`)
- FastAPI routes → Run orchestrator: dispatches runs (evidence: `backend/app/main.py`)
- FastAPI routes → Run and user store: reads run events (evidence: `backend/app/main.py`)
- FastAPI routes → Travel tool registry: configures tools (evidence: `backend/app/main.py`)
- FastAPI routes → Request interpreter: configures interpreter (evidence: `backend/app/main.py`)
- Run orchestrator → Request interpreter: interprets turns (evidence: `backend/app/orchestrator.py`)
- Request interpreter → Sarvam agent: requests interpretation (evidence: `backend/app/interpreter.py`)
- Run orchestrator → Sarvam agent: plans and replans (evidence: `README.md`)
- Run orchestrator → Travel and run models: uses run schemas (evidence: `backend/app/orchestrator.py`)
- Run orchestrator → Travel tool registry: dispatches searches (evidence: `backend/app/orchestrator.py`)
- Travel tool registry → Travel data providers: queries providers (evidence: `backend/app/travel_tools.py`)
- Run orchestrator → Constraint solver: checks constraints (evidence: `backend/app/orchestrator.py`)
- Run orchestrator → Itinerary composer: composes itinerary (evidence: `backend/app/orchestrator.py`)
- Run orchestrator → Run and user store: persists run state (evidence: `backend/app/orchestrator.py`)
- Run and user store → Supabase Postgres: reads and writes (evidence: `backend/app/store.py`)
- Mobile app → Supabase Postgres: subscribes to updates (evidence: `README.md`)
- Mobile app → FastAPI routes: catches up events (evidence: `README.md`)
- FastAPI routes → Calendar integration: routes calendar actions
- Calendar integration → Run and user store: stores connection tokens (evidence: `backend/app/calendar_service.py`)
- Calendar integration → Google Calendar: writes itinerary events (evidence: `backend/app/calendar_service.py`)
