# chary994/smart-tourist-safety architecture

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

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

## Overview

This prototype supports tourist registration and location-based safety incidents: a user registers for a DID, sends an SOS or fall event, and sees incidents in a map and live-updating list. The backend persists tourists and incidents, then broadcasts new incidents. The tree also contains a Python fall-event client and a Solidity ID registry; their relationship to the running backend is not established by the available excerpts. Edges reflect only shown calls, rendering, and data flow.

Main entry points: [`sih25002-proto/frontend/src/App.js`](https://github.com/chary994/smart-tourist-safety/blob/main/sih25002-proto/frontend/src/App.js) (Safety app), [`sih25002-proto/backend/index.js`](https://github.com/chary994/smart-tourist-safety/blob/main/sih25002-proto/backend/index.js) (HTTP API), [`sih25002-proto/frontend/src/map.js`](https://github.com/chary994/smart-tourist-safety/blob/main/sih25002-proto/frontend/src/map.js) (Incident map), [`sih25002-proto/ai_demo/fall_simulator.py`](https://github.com/chary994/smart-tourist-safety/blob/main/sih25002-proto/ai_demo/fall_simulator.py) (Fall simulator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Tourist client"]
  node_app["Safety app<br/>[App.js]"]
  node_map["Incident map<br/>[map.js]"]
end

subgraph group_server["Backend services"]
  node_api["HTTP API<br/>[index.js]"]
  node_did["DID generation<br/>[index.js]"]
  node_incident["Incident intake<br/>[index.js]"]
  node_store[("SQLite records<br/>[index.js]")]
  node_realtime["Incident broadcast<br/>[index.js]"]
end

subgraph group_integrations["Other components"]
  node_fallclient["Fall simulator<br/>[fall_simulator.py]"]
  node_registry["ID registry contract<br/>[IDRegistry.sol]"]
end

node_tourist(("Tourist"))
node_gps["Browser geolocation"]
node_tiles["OpenStreetMap tiles"]

node_tourist -->|"uses"| node_app
node_app -->|"registers via HTTP"| node_api
node_api -->|"generates DID"| node_did
node_api -->|"stores tourist"| node_store
node_app -->|"submits incident"| node_api
node_api -->|"routes incident"| node_incident
node_incident -->|"writes incident"| node_store
node_app -->|"fetches incidents"| node_api
node_api -->|"reads incidents"| node_store
node_incident -->|"broadcasts new event"| node_realtime
node_realtime -->|"pushes incident"| node_app
node_app -->|"renders incidents"| node_map
node_tourist -->|"requests location"| node_gps
node_gps -->|"returns coordinates"| node_app
node_map -->|"loads map tiles"| node_tiles
node_fallclient -->|"posts fall event"| node_incident

click node_app "https://github.com/chary994/smart-tourist-safety/blob/main/sih25002-proto/frontend/src/App.js"
click node_map "https://github.com/chary994/smart-tourist-safety/blob/main/sih25002-proto/frontend/src/map.js"
click node_api "https://github.com/chary994/smart-tourist-safety/blob/main/sih25002-proto/backend/index.js"
click node_did "https://github.com/chary994/smart-tourist-safety/blob/main/sih25002-proto/backend/index.js"
click node_incident "https://github.com/chary994/smart-tourist-safety/blob/main/sih25002-proto/backend/index.js"
click node_store "https://github.com/chary994/smart-tourist-safety/blob/main/sih25002-proto/backend/index.js"
click node_realtime "https://github.com/chary994/smart-tourist-safety/blob/main/sih25002-proto/backend/index.js"
click node_fallclient "https://github.com/chary994/smart-tourist-safety/blob/main/sih25002-proto/ai_demo/fall_simulator.py"
click node_registry "https://github.com/chary994/smart-tourist-safety/blob/main/sih25002-proto/solidity/IDRegistry.sol"

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,node_map,node_gps toneBlue
class node_api,node_did,node_incident,node_store,node_realtime toneAmber
class node_fallclient,node_registry toneMint
class node_tourist,node_tiles toneIndigo
```

## Components

### Tourist client

- [Safety app](https://github.com/chary994/smart-tourist-safety/blob/main/sih25002-proto/frontend/src/App.js): `sih25002-proto/frontend/src/App.js`
- [Incident map](https://github.com/chary994/smart-tourist-safety/blob/main/sih25002-proto/frontend/src/map.js): `sih25002-proto/frontend/src/map.js`

### Backend services

- [HTTP API](https://github.com/chary994/smart-tourist-safety/blob/main/sih25002-proto/backend/index.js): `sih25002-proto/backend/index.js`
- [DID generation](https://github.com/chary994/smart-tourist-safety/blob/main/sih25002-proto/backend/index.js): `sih25002-proto/backend/index.js`
- [Incident intake](https://github.com/chary994/smart-tourist-safety/blob/main/sih25002-proto/backend/index.js): `sih25002-proto/backend/index.js`
- [SQLite records](https://github.com/chary994/smart-tourist-safety/blob/main/sih25002-proto/backend/index.js): `sih25002-proto/backend/index.js`
- [Incident broadcast](https://github.com/chary994/smart-tourist-safety/blob/main/sih25002-proto/backend/index.js): `sih25002-proto/backend/index.js`

### Other components

- [Fall simulator](https://github.com/chary994/smart-tourist-safety/blob/main/sih25002-proto/ai_demo/fall_simulator.py): `sih25002-proto/ai_demo/fall_simulator.py`
- [ID registry contract](https://github.com/chary994/smart-tourist-safety/blob/main/sih25002-proto/solidity/IDRegistry.sol): `sih25002-proto/solidity/IDRegistry.sol`

### Other components

- **Tourist**
- **Browser geolocation**
- **OpenStreetMap tiles**

## Connections

- Tourist → Safety app: uses (evidence: `sih25002-proto/frontend/src/App.js`)
- Safety app → HTTP API: registers via HTTP (evidence: `sih25002-proto/frontend/src/App.js`)
- HTTP API → DID generation: generates DID (evidence: `sih25002-proto/backend/index.js`)
- HTTP API → SQLite records: stores tourist (evidence: `sih25002-proto/backend/index.js`)
- Safety app → HTTP API: submits incident (evidence: `sih25002-proto/frontend/src/App.js`)
- HTTP API → Incident intake: routes incident (evidence: `sih25002-proto/backend/index.js`)
- Incident intake → SQLite records: writes incident (evidence: `sih25002-proto/backend/index.js`)
- Safety app → HTTP API: fetches incidents (evidence: `sih25002-proto/frontend/src/App.js`)
- HTTP API → SQLite records: reads incidents (evidence: `sih25002-proto/backend/index.js`)
- Incident intake → Incident broadcast: broadcasts new event (evidence: `sih25002-proto/backend/index.js`)
- Incident broadcast → Safety app: pushes incident (evidence: `sih25002-proto/frontend/src/App.js`)
- Safety app → Incident map: renders incidents (evidence: `sih25002-proto/frontend/src/App.js`)
- Tourist → Browser geolocation: requests location
- Browser geolocation → Safety app: returns coordinates (evidence: `sih25002-proto/frontend/src/App.js`)
- Incident map → OpenStreetMap tiles: loads map tiles (evidence: `sih25002-proto/frontend/src/map.js`)
- Fall simulator → Incident intake: posts fall event (evidence: `sih25002-proto/ai_demo/fall_simulator.py`)
