# pavithran244/tourist-safety architecture

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

- Interactive diagram: https://gitdiagram.com/pavithran244/tourist-safety
- Repository: https://github.com/pavithran244/tourist-safety

## Overview

Tourist Safety combines an Expo mobile app with a FastAPI service and SQLite persistence. The principal workflow is tourist location capture and submission, backend geofence evaluation and status/history updates, then monitoring of tourists and alerts; the documented SOS flow similarly exposes submitted alerts to an authorized monitoring interface. Registration and QR identification, geofence configuration, and the dashboard are distinct capabilities. Backend implementation is concentrated in one sampled file; mobile excerpts establish location submission, while some dashboard and QR details are documented only in the README.

Main entry points: [`backend/main.py`](https://github.com/pavithran244/tourist-safety/blob/main/backend/main.py) (REST API), [`mobile/app/index.tsx`](https://github.com/pavithran244/tourist-safety/blob/main/mobile/app/index.tsx) (Tourist app), [`backend/dashboard.html`](https://github.com/pavithran244/tourist-safety/blob/main/backend/dashboard.html) (Monitoring dashboard), [`mobile/src/app/index.tsx`](https://github.com/pavithran244/tourist-safety/blob/main/mobile/src/app/index.tsx) (Safety monitor UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Tourist mobile app"]
  node_mobileapp["Tourist app<br/>[index.tsx]"]
  node_mobilemonitor["Safety monitor UI<br/>[index.tsx]"]
end

subgraph group_backend["Safety backend"]
  node_api["REST API<br/>[main.py]"]
  node_registration["Tourist registration<br/>[main.py]"]
  node_qr["QR identification<br/>[main.py]"]
  node_location["Location updates<br/>[main.py]"]
  node_geofence["Geofence evaluation<br/>[main.py]"]
  node_sos["SOS alerts<br/>[main.py]"]
  node_monitoring["Tourist and alert queries<br/>[main.py]"]
  node_database[("SQLite records<br/>[main.py]")]
end

subgraph group_monitor["Monitoring interface"]
  node_dashboard["Monitoring dashboard<br/>[dashboard.html]"]
end

node_tourist(("Tourist"))
node_admin(("Administrator"))

node_tourist -->|"uses"| node_mobileapp
node_mobileapp -->|"submits locations"| node_api
node_mobileapp -->|"sends SOS"| node_api
node_mobileapp -.->|"configures zones"| node_api
node_api -->|"routes updates"| node_location
node_api -->|"routes registration"| node_registration
node_api -->|"routes QR operations"| node_qr
node_api -->|"routes SOS"| node_sos
node_api -->|"serves queries"| node_monitoring
node_location -->|"checks coordinates"| node_geofence
node_location -->|"updates records"| node_database
node_geofence -->|"reads zone config"| node_database
node_sos -->|"checks coordinates"| node_geofence
node_sos -->|"stores alerts"| node_database
node_registration -.->|"stores tourist"| node_database
node_qr -->|"reads tourist"| node_database
node_monitoring -->|"reads records"| node_database
node_admin -->|"monitors"| node_dashboard
node_dashboard -->|"retrieves alerts"| node_api
node_mobilemonitor -.->|"supports monitoring"| node_api

click node_mobileapp "https://github.com/pavithran244/tourist-safety/blob/main/mobile/app/index.tsx"
click node_mobilemonitor "https://github.com/pavithran244/tourist-safety/blob/main/mobile/src/app/index.tsx"
click node_api "https://github.com/pavithran244/tourist-safety/blob/main/backend/main.py"
click node_registration "https://github.com/pavithran244/tourist-safety/blob/main/backend/main.py"
click node_qr "https://github.com/pavithran244/tourist-safety/blob/main/backend/main.py"
click node_location "https://github.com/pavithran244/tourist-safety/blob/main/backend/main.py"
click node_geofence "https://github.com/pavithran244/tourist-safety/blob/main/backend/main.py"
click node_sos "https://github.com/pavithran244/tourist-safety/blob/main/backend/main.py"
click node_monitoring "https://github.com/pavithran244/tourist-safety/blob/main/backend/main.py"
click node_database "https://github.com/pavithran244/tourist-safety/blob/main/backend/main.py"
click node_dashboard "https://github.com/pavithran244/tourist-safety/blob/main/backend/dashboard.html"

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_mobileapp,node_mobilemonitor toneBlue
class node_api,node_registration,node_qr,node_location,node_geofence,node_sos,node_monitoring,node_database toneAmber
class node_dashboard toneMint
class node_tourist,node_admin toneIndigo
```

## Components

### Tourist mobile app

- [Tourist app](https://github.com/pavithran244/tourist-safety/blob/main/mobile/app/index.tsx): `mobile/app/index.tsx`
- [Safety monitor UI](https://github.com/pavithran244/tourist-safety/blob/main/mobile/src/app/index.tsx): `mobile/src/app/index.tsx`

### Safety backend

- [REST API](https://github.com/pavithran244/tourist-safety/blob/main/backend/main.py): `backend/main.py`
- [Tourist registration](https://github.com/pavithran244/tourist-safety/blob/main/backend/main.py): `backend/main.py`
- [QR identification](https://github.com/pavithran244/tourist-safety/blob/main/backend/main.py): `backend/main.py`
- [Location updates](https://github.com/pavithran244/tourist-safety/blob/main/backend/main.py): `backend/main.py`
- [Geofence evaluation](https://github.com/pavithran244/tourist-safety/blob/main/backend/main.py): `backend/main.py`
- [SOS alerts](https://github.com/pavithran244/tourist-safety/blob/main/backend/main.py): `backend/main.py`
- [Tourist and alert queries](https://github.com/pavithran244/tourist-safety/blob/main/backend/main.py): `backend/main.py`
- [SQLite records](https://github.com/pavithran244/tourist-safety/blob/main/backend/main.py): `backend/main.py`

### Monitoring interface

- [Monitoring dashboard](https://github.com/pavithran244/tourist-safety/blob/main/backend/dashboard.html): `backend/dashboard.html`

### Other components

- **Tourist**
- **Administrator**

## Connections

- Tourist → Tourist app: uses (evidence: `README.md`)
- Tourist app → REST API: submits locations (evidence: `mobile/app/index.tsx`)
- Tourist app → REST API: sends SOS (evidence: `README.md`)
- Tourist app → REST API: configures zones
- REST API → Location updates: routes updates (evidence: `backend/main.py`)
- REST API → Tourist registration: routes registration (evidence: `README.md`)
- REST API → QR identification: routes QR operations (evidence: `backend/main.py`)
- REST API → SOS alerts: routes SOS (evidence: `backend/main.py`)
- REST API → Tourist and alert queries: serves queries (evidence: `README.md`)
- Location updates → Geofence evaluation: checks coordinates (evidence: `backend/main.py`)
- Location updates → SQLite records: updates records (evidence: `backend/main.py`)
- Geofence evaluation → SQLite records: reads zone config (evidence: `backend/main.py`)
- SOS alerts → Geofence evaluation: checks coordinates (evidence: `backend/main.py`)
- SOS alerts → SQLite records: stores alerts (evidence: `backend/main.py`)
- Tourist registration → SQLite records: stores tourist (evidence: `backend/main.py`)
- QR identification → SQLite records: reads tourist (evidence: `backend/main.py`)
- Tourist and alert queries → SQLite records: reads records (evidence: `backend/main.py`)
- Administrator → Monitoring dashboard: monitors (evidence: `README.md`)
- Monitoring dashboard → REST API: retrieves alerts (evidence: `README.md`)
- Safety monitor UI → REST API: supports monitoring
