# hasishinfant/travelsphere architecture

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

- Interactive diagram: https://gitdiagram.com/hasishinfant/travelsphere
- Repository: https://github.com/hasishinfant/travelsphere

## Overview

TravelSphere combines trip planning, hotel booking, incident response, and live travel-safety assessment. The main flow is traveler planning or viewing a journey in the React app, requests through the Express API, then destination or route assessment by the Python risk service using provider data; assessment results support safety views and alerts. Hotels and emergency reporting are distinct product branches. Edges are limited to README statements and source-index/import evidence; several route and frontend-service connections are not shown in the excerpts and are therefore omitted.

Main entry points: [`risk-service/app/services/destination_service.py`](https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/services/destination_service.py) (Destination assessment), [`risk-service/app/services/journey_service.py`](https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/services/journey_service.py) (Journey assessment), [`src/App.tsx`](https://github.com/hasishinfant/travelsphere/blob/main/src/App.tsx) (TravelSphere app), [`risk-service/app/services/data.py`](https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/services/data.py) (Risk data service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Traveler app"]
  node_webapp["TravelSphere app<br/>[App.tsx]"]
  node_destinations["Destination catalog<br/>[destinations.ts]"]
  node_itinerary["Journey planner<br/>[ItineraryPage.tsx]"]
  node_hotel_ui["Hotel search UI"]
  node_hotel_search["Hotel search mapping"]
  node_emergency_ui["Emergency experience<br/>[EmergencyPage.tsx]"]
end

subgraph group_api["Express API"]
  node_express["API application<br/>[app.ts]"]
  node_api_routes["Journey and v1 routes"]
  node_risk_client["Risk service client<br/>[riskService.ts]"]
  node_weather["Weather service<br/>[weather.ts]"]
  node_hotel_provider_client["Hotel provider integration<br/>[liteapi.ts]"]
end

subgraph group_risk["Risk assessment"]
  node_risk_api["Assessment API<br/>[routes.py]"]
  node_destination_assess["Destination assessment"]
  node_journey_assess["Journey assessment<br/>[journey_service.py]"]
  node_context["Assessment context<br/>[context.py]"]
  node_factor_contract["Factor results<br/>[factors.py]"]
  node_factor_modules["Risk factors"]
  node_confidence["Confidence and quality<br/>[confidence.py]"]
  node_explanations["Assessment explanations<br/>[builder.py]"]
  node_scoring_config["Scoring configuration<br/>[config.py]"]
end

subgraph group_data["Risk data and models"]
  node_data_service["Risk data service<br/>[data.py]"]
  node_ingestion["Hazard and weather feeds"]
  node_repository[("Risk repository<br/>[repository.py]")]
  node_geometry["Geospatial operations<br/>[geometry.py]"]
  node_ml_predictor["Hazard model inference<br/>[predictor.py]"]
end

subgraph group_booking["Hotel booking"]
  node_hotel_provider["LiteAPI provider"]
end

node_traveler(("Traveler"))

node_traveler -->|"uses"| node_webapp
node_webapp -->|"navigates"| node_itinerary
node_webapp -->|"navigates"| node_emergency_ui
node_webapp -->|"navigates"| node_hotel_ui
node_hotel_ui -->|"searches"| node_hotel_search
node_hotel_search -->|"requests offers"| node_hotel_provider_client
node_hotel_provider_client -->|"queries"| node_hotel_provider
node_webapp -->|"uses API"| node_express
node_express -->|"mounts routes"| node_api_routes
node_express -->|"creates client"| node_risk_client
node_express -->|"creates service"| node_weather
node_risk_client -->|"requests assessments"| node_risk_api
node_risk_api -->|"assesses destination"| node_destination_assess
node_risk_api -->|"assesses journey"| node_journey_assess
node_destination_assess -->|"fetches inputs"| node_data_service
node_journey_assess -->|"fetches inputs"| node_data_service
node_data_service -->|"loads observations"| node_ingestion
node_data_service -->|"reads data"| node_repository
node_destination_assess -->|"builds context"| node_context
node_journey_assess -->|"builds context"| node_context
node_destination_assess -->|"computes factors"| node_factor_modules
node_journey_assess -->|"computes factors"| node_factor_modules
node_factor_modules -->|"reads inputs"| node_context
node_factor_modules -->|"returns results"| node_factor_contract
node_destination_assess -->|"computes confidence"| node_confidence
node_journey_assess -->|"computes confidence"| node_confidence
node_destination_assess -->|"builds explanation"| node_explanations
node_journey_assess -->|"builds explanation"| node_explanations
node_destination_assess -->|"loads scoring"| node_scoring_config
node_journey_assess -->|"loads scoring"| node_scoring_config
node_destination_assess -->|"uses prediction"| node_ml_predictor
node_data_service -->|"uses geometry"| node_geometry
node_repository -->|"constructs shapes"| node_geometry

click node_webapp "https://github.com/hasishinfant/travelsphere/blob/main/src/App.tsx"
click node_destinations "https://github.com/hasishinfant/travelsphere/blob/main/src/data/destinations.ts"
click node_itinerary "https://github.com/hasishinfant/travelsphere/blob/main/src/pages/ItineraryPage.tsx"
click node_hotel_ui "https://github.com/hasishinfant/travelsphere/blob/main/src/components/hotel/HotelSearchForm.tsx"
click node_hotel_search "https://github.com/hasishinfant/travelsphere/blob/main/src/services/hotelSearchService.ts"
click node_emergency_ui "https://github.com/hasishinfant/travelsphere/blob/main/src/pages/EmergencyPage.tsx"
click node_express "https://github.com/hasishinfant/travelsphere/blob/main/server/src/app.ts"
click node_api_routes "https://github.com/hasishinfant/travelsphere/tree/main/server/src/routes"
click node_risk_client "https://github.com/hasishinfant/travelsphere/blob/main/server/src/integrations/riskService.ts"
click node_weather "https://github.com/hasishinfant/travelsphere/blob/main/server/src/services/weather.ts"
click node_risk_api "https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/api/routes.py"
click node_destination_assess "https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/services/destination_service.py"
click node_journey_assess "https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/services/journey_service.py"
click node_context "https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/risk_engine/context.py"
click node_factor_contract "https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/schemas/factors.py"
click node_factor_modules "https://github.com/hasishinfant/travelsphere/tree/main/risk-service/app/risk_engine/factors"
click node_confidence "https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/risk_engine/confidence.py"
click node_explanations "https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/risk_engine/explanations/builder.py"
click node_scoring_config "https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/risk_engine/aggregation/config.py"
click node_data_service "https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/services/data.py"
click node_ingestion "https://github.com/hasishinfant/travelsphere/tree/main/risk-service/app/ingestion"
click node_repository "https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/database/repository.py"
click node_geometry "https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/geospatial/geometry.py"
click node_ml_predictor "https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/ml/inference/predictor.py"
click node_hotel_provider_client "https://github.com/hasishinfant/travelsphere/blob/main/server/src/integrations/liteapi.ts"

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_webapp,node_destinations,node_itinerary,node_hotel_ui,node_hotel_search,node_emergency_ui toneBlue
class node_express,node_api_routes,node_risk_client,node_weather,node_hotel_provider_client toneAmber
class node_risk_api,node_destination_assess,node_journey_assess,node_context,node_factor_contract,node_factor_modules,node_confidence,node_explanations,node_scoring_config toneMint
class node_data_service,node_ingestion,node_repository,node_geometry,node_ml_predictor toneRose
class node_hotel_provider,node_traveler toneIndigo
```

## Components

### Traveler app

- [TravelSphere app](https://github.com/hasishinfant/travelsphere/blob/main/src/App.tsx): `src/App.tsx`
- [Destination catalog](https://github.com/hasishinfant/travelsphere/blob/main/src/data/destinations.ts): `src/data/destinations.ts`
- [Journey planner](https://github.com/hasishinfant/travelsphere/blob/main/src/pages/ItineraryPage.tsx): `src/pages/ItineraryPage.tsx`
- [Hotel search UI](https://github.com/hasishinfant/travelsphere/blob/main/src/components/hotel/HotelSearchForm.tsx): `src/components/hotel/HotelSearchForm.tsx`
- [Hotel search mapping](https://github.com/hasishinfant/travelsphere/blob/main/src/services/hotelSearchService.ts): `src/services/hotelSearchService.ts`
- [Emergency experience](https://github.com/hasishinfant/travelsphere/blob/main/src/pages/EmergencyPage.tsx): `src/pages/EmergencyPage.tsx`

### Express API

- [API application](https://github.com/hasishinfant/travelsphere/blob/main/server/src/app.ts): `server/src/app.ts`
- [Journey and v1 routes](https://github.com/hasishinfant/travelsphere/tree/main/server/src/routes): `server/src/routes`
- [Risk service client](https://github.com/hasishinfant/travelsphere/blob/main/server/src/integrations/riskService.ts): `server/src/integrations/riskService.ts`
- [Weather service](https://github.com/hasishinfant/travelsphere/blob/main/server/src/services/weather.ts): `server/src/services/weather.ts`
- [Hotel provider integration](https://github.com/hasishinfant/travelsphere/blob/main/server/src/integrations/liteapi.ts): `server/src/integrations/liteapi.ts`

### Risk assessment

- [Assessment API](https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/api/routes.py): `risk-service/app/api/routes.py`
- [Destination assessment](https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/services/destination_service.py): `risk-service/app/services/destination_service.py`
- [Journey assessment](https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/services/journey_service.py): `risk-service/app/services/journey_service.py`
- [Assessment context](https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/risk_engine/context.py): `risk-service/app/risk_engine/context.py`
- [Factor results](https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/schemas/factors.py): `risk-service/app/schemas/factors.py`
- [Risk factors](https://github.com/hasishinfant/travelsphere/tree/main/risk-service/app/risk_engine/factors): `risk-service/app/risk_engine/factors`
- [Confidence and quality](https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/risk_engine/confidence.py): `risk-service/app/risk_engine/confidence.py`
- [Assessment explanations](https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/risk_engine/explanations/builder.py): `risk-service/app/risk_engine/explanations/builder.py`
- [Scoring configuration](https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/risk_engine/aggregation/config.py): `risk-service/app/risk_engine/aggregation/config.py`

### Risk data and models

- [Risk data service](https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/services/data.py): `risk-service/app/services/data.py`
- [Hazard and weather feeds](https://github.com/hasishinfant/travelsphere/tree/main/risk-service/app/ingestion): `risk-service/app/ingestion`
- [Risk repository](https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/database/repository.py): `risk-service/app/database/repository.py`
- [Geospatial operations](https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/geospatial/geometry.py): `risk-service/app/geospatial/geometry.py`
- [Hazard model inference](https://github.com/hasishinfant/travelsphere/blob/main/risk-service/app/ml/inference/predictor.py): `risk-service/app/ml/inference/predictor.py`

### Hotel booking

- **LiteAPI provider**

### Other components

- **Traveler**

## Connections

- Traveler → TravelSphere app: uses (evidence: `README.md`)
- TravelSphere app → Journey planner: navigates (evidence: `src/App.tsx`)
- TravelSphere app → Emergency experience: navigates (evidence: `src/App.tsx`)
- TravelSphere app → Hotel search UI: navigates (evidence: `src/App.tsx`)
- Hotel search UI → Hotel search mapping: searches (evidence: `src/components/hotel/HotelSearchForm.tsx`)
- Hotel search mapping → Hotel provider integration: requests offers (evidence: `README.md`)
- Hotel provider integration → LiteAPI provider: queries (evidence: `README.md`)
- TravelSphere app → API application: uses API (evidence: `README.md`)
- API application → Journey and v1 routes: mounts routes (evidence: `server/src/app.ts`)
- API application → Risk service client: creates client (evidence: `server/src/app.ts`)
- API application → Weather service: creates service (evidence: `server/src/app.ts`)
- Risk service client → Assessment API: requests assessments (evidence: `README.md`)
- Assessment API → Destination assessment: assesses destination (evidence: `risk-service/app/api/routes.py`)
- Assessment API → Journey assessment: assesses journey (evidence: `risk-service/app/api/routes.py`)
- Destination assessment → Risk data service: fetches inputs (evidence: `risk-service/app/services/destination_service.py`)
- Journey assessment → Risk data service: fetches inputs (evidence: `risk-service/app/services/journey_service.py`)
- Risk data service → Hazard and weather feeds: loads observations (evidence: `risk-service/app/services/data.py`)
- Risk data service → Risk repository: reads data (evidence: `risk-service/app/services/data.py`)
- Destination assessment → Assessment context: builds context (evidence: `risk-service/app/services/destination_service.py`)
- Journey assessment → Assessment context: builds context (evidence: `risk-service/app/services/journey_service.py`)
- Destination assessment → Risk factors: computes factors (evidence: `risk-service/app/services/destination_service.py`)
- Journey assessment → Risk factors: computes factors (evidence: `risk-service/app/services/journey_service.py`)
- Risk factors → Assessment context: reads inputs (evidence: `risk-service/app/risk_engine/context.py`)
- Risk factors → Factor results: returns results (evidence: `risk-service/app/schemas/factors.py`)
- Destination assessment → Confidence and quality: computes confidence (evidence: `risk-service/app/services/destination_service.py`)
- Journey assessment → Confidence and quality: computes confidence (evidence: `risk-service/app/services/journey_service.py`)
- Destination assessment → Assessment explanations: builds explanation (evidence: `risk-service/app/services/destination_service.py`)
- Journey assessment → Assessment explanations: builds explanation (evidence: `risk-service/app/services/journey_service.py`)
- Destination assessment → Scoring configuration: loads scoring (evidence: `risk-service/app/services/destination_service.py`)
- Journey assessment → Scoring configuration: loads scoring (evidence: `risk-service/app/services/journey_service.py`)
- Destination assessment → Hazard model inference: uses prediction (evidence: `risk-service/app/services/destination_service.py`)
- Risk data service → Geospatial operations: uses geometry (evidence: `risk-service/app/services/data.py`)
- Risk repository → Geospatial operations: constructs shapes (evidence: `risk-service/app/database/repository.py`)
