# subham-khandual/suraksha-setu architecture

> Architecture diagram of the GitHub repository subham-khandual/suraksha-setu, 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/subham-khandual/suraksha-setu
- Repository: https://github.com/subham-khandual/suraksha-setu

## Overview

Suraksha Setu is a tourist-safety and emergency-response platform with a React tourist/admin interface and an Express/MongoDB backend. The main user journey runs from account access through safety features such as digital-ID verification, location monitoring, SOS and incident reporting, then into authority monitoring and response. The README also documents ambulance, accommodation/payment, and real-time communication capabilities. Frontend routing and several backend relationships are evidenced in excerpts or the source index; unsampled screen-to-API wiring is not asserted.

Main entry points: [`frontend/tourist/src/App.tsx`](https://github.com/subham-khandual/suraksha-setu/blob/main/frontend/tourist/src/App.tsx) (Application Router), [`backend/server.js`](https://github.com/subham-khandual/suraksha-setu/blob/main/backend/server.js) (Express API Server), [`backend/routes/incidents.js`](https://github.com/subham-khandual/suraksha-setu/blob/main/backend/routes/incidents.js) (Incident Management), [`backend/routes/auth.js`](https://github.com/subham-khandual/suraksha-setu/blob/main/backend/routes/auth.js) (Authentication Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Tourist and Admin UI"]
  node_app["Application Router<br/>[App.tsx]"]
  node_dashboard["Safety Dashboard"]
  node_adminui["Admin Command Center"]
  node_trackingui["Live Tracking Map<br/>[MapScreen.tsx]"]
  node_sosui["Emergency Alert UI"]
  node_incidentui["Incident Reporting UI"]
  node_authui["Sign In and Registration<br/>[LoginScreen.tsx]"]
  node_verifyui["Digital ID Screens"]
end

subgraph group_identity["Identity and Access"]
  node_verifyapi["ID Verification"]
  node_authroutes["Authentication Routes<br/>[auth.js]"]
  node_authmw["JWT Access Control<br/>[auth.js]"]
  node_users[("Tourist Accounts<br/>[User.js]")]
end

subgraph group_response["Safety Response"]
  node_incidentroutes["Incident Management<br/>[incidents.js]"]
  node_incidentdata[("Incident Records<br/>[IncidentReport.js]")]
  node_alerts[("Emergency Alerts<br/>[Alert.js]")]
  node_activity["Activity Logging<br/>[activityService.js]"]
end

subgraph group_services["Travel and Communication"]
  node_ambulance["Ambulance Booking<br/>[ambulance.js]"]
  node_travelui["Hotels and Payments"]
  node_payment["Payment Routes<br/>[payment.js]"]
  node_chatui["Community Chat"]
  node_chatroute["Community Chat API<br/>[communityChat.js]"]
  node_socket["Live Socket Events<br/>[socketHandler.js]"]
  node_messages[("Community Messages")]
end

subgraph group_platform["Backend Platform"]
  node_server["Express API Server<br/>[server.js]"]
  node_database[("MongoDB")]
end

node_tourist(("Tourist"))
node_authority(("Admin and Authorities"))

node_tourist -->|"uses"| node_app
node_authority -->|"uses"| node_app
node_app -->|"routes to"| node_authui
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_adminui
node_app -->|"routes to"| node_trackingui
node_app -->|"routes to"| node_sosui
node_app -->|"routes to"| node_incidentui
node_app -->|"routes to"| node_verifyui
node_app -->|"routes to"| node_travelui
node_app -->|"routes to"| node_chatui
node_server -->|"mounts"| node_authroutes
node_server -->|"mounts"| node_incidentroutes
node_server -->|"mounts"| node_ambulance
node_server -->|"mounts"| node_payment
node_server -->|"mounts"| node_chatroute
node_server -->|"initializes"| node_socket
node_server -->|"connects"| node_database
node_authroutes -->|"reads and writes"| node_users
node_authmw -->|"loads account"| node_users
node_authroutes -->|"uses access control"| node_authmw
node_authroutes -->|"uses verification"| node_verifyapi
node_verifyapi -->|"looks up"| node_users
node_verifyapi -->|"checks active alerts"| node_alerts
node_incidentroutes -->|"reads and writes"| node_incidentdata
node_incidentroutes -->|"uses alerts"| node_alerts
node_incidentroutes -->|"logs activity"| node_activity
node_activity -.->|"persists activity"| node_database
node_socket -->|"saves messages"| node_messages
node_socket -->|"authenticates users"| node_users
node_chatroute -.->|"uses access control"| node_authmw
node_ambulance -.->|"persists bookings"| node_database
node_payment -.->|"uses persistence"| node_database
node_chatui -.->|"exchanges live messages"| node_socket
node_sosui -.->|"submits SOS"| node_server
node_incidentui -.->|"submits reports"| node_incidentroutes
node_verifyui -.->|"requests ID checks"| node_verifyapi

click node_app "https://github.com/subham-khandual/suraksha-setu/blob/main/frontend/tourist/src/App.tsx"
click node_dashboard "https://github.com/subham-khandual/suraksha-setu/blob/main/frontend/tourist/src/screens/DashboardScreen.tsx"
click node_adminui "https://github.com/subham-khandual/suraksha-setu/blob/main/frontend/tourist/src/screens/AdminDashboardScreen.tsx"
click node_trackingui "https://github.com/subham-khandual/suraksha-setu/blob/main/frontend/tourist/src/screens/MapScreen.tsx"
click node_sosui "https://github.com/subham-khandual/suraksha-setu/blob/main/frontend/tourist/src/screens/EmergencyAlertScreen.tsx"
click node_incidentui "https://github.com/subham-khandual/suraksha-setu/blob/main/frontend/tourist/src/screens/ReportIncidentScreen.tsx"
click node_authui "https://github.com/subham-khandual/suraksha-setu/blob/main/frontend/tourist/src/screens/LoginScreen.tsx"
click node_verifyui "https://github.com/subham-khandual/suraksha-setu/blob/main/frontend/tourist/src/screens/admin/AdminQRScannerScreen.tsx"
click node_verifyapi "https://github.com/subham-khandual/suraksha-setu/blob/main/backend/services/verificationService.js"
click node_authroutes "https://github.com/subham-khandual/suraksha-setu/blob/main/backend/routes/auth.js"
click node_authmw "https://github.com/subham-khandual/suraksha-setu/blob/main/backend/middleware/auth.js"
click node_users "https://github.com/subham-khandual/suraksha-setu/blob/main/backend/models/User.js"
click node_incidentroutes "https://github.com/subham-khandual/suraksha-setu/blob/main/backend/routes/incidents.js"
click node_incidentdata "https://github.com/subham-khandual/suraksha-setu/blob/main/backend/models/IncidentReport.js"
click node_alerts "https://github.com/subham-khandual/suraksha-setu/blob/main/backend/models/Alert.js"
click node_activity "https://github.com/subham-khandual/suraksha-setu/blob/main/backend/services/activityService.js"
click node_ambulance "https://github.com/subham-khandual/suraksha-setu/blob/main/backend/routes/ambulance.js"
click node_travelui "https://github.com/subham-khandual/suraksha-setu/blob/main/frontend/tourist/src/screens/HotelListingScreen.tsx"
click node_payment "https://github.com/subham-khandual/suraksha-setu/blob/main/backend/routes/payment.js"
click node_chatui "https://github.com/subham-khandual/suraksha-setu/blob/main/frontend/tourist/src/screens/CommunityChatScreen.tsx"
click node_chatroute "https://github.com/subham-khandual/suraksha-setu/blob/main/backend/routes/communityChat.js"
click node_socket "https://github.com/subham-khandual/suraksha-setu/blob/main/backend/socket/socketHandler.js"
click node_messages "https://github.com/subham-khandual/suraksha-setu/blob/main/backend/models/CommunityMessage.js"
click node_server "https://github.com/subham-khandual/suraksha-setu/blob/main/backend/server.js"

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_dashboard,node_adminui,node_trackingui,node_sosui,node_incidentui,node_authui,node_verifyui toneBlue
class node_verifyapi,node_authroutes,node_authmw,node_users toneAmber
class node_incidentroutes,node_incidentdata,node_alerts,node_activity toneMint
class node_ambulance,node_travelui,node_payment,node_chatui,node_chatroute,node_socket,node_messages toneRose
class node_server,node_database,node_tourist,node_authority toneIndigo
```

## Components

### Tourist and Admin UI

- [Application Router](https://github.com/subham-khandual/suraksha-setu/blob/main/frontend/tourist/src/App.tsx): `frontend/tourist/src/App.tsx`
- [Safety Dashboard](https://github.com/subham-khandual/suraksha-setu/blob/main/frontend/tourist/src/screens/DashboardScreen.tsx): `frontend/tourist/src/screens/DashboardScreen.tsx`
- [Admin Command Center](https://github.com/subham-khandual/suraksha-setu/blob/main/frontend/tourist/src/screens/AdminDashboardScreen.tsx): `frontend/tourist/src/screens/AdminDashboardScreen.tsx`
- [Live Tracking Map](https://github.com/subham-khandual/suraksha-setu/blob/main/frontend/tourist/src/screens/MapScreen.tsx): `frontend/tourist/src/screens/MapScreen.tsx`
- [Emergency Alert UI](https://github.com/subham-khandual/suraksha-setu/blob/main/frontend/tourist/src/screens/EmergencyAlertScreen.tsx): `frontend/tourist/src/screens/EmergencyAlertScreen.tsx`
- [Incident Reporting UI](https://github.com/subham-khandual/suraksha-setu/blob/main/frontend/tourist/src/screens/ReportIncidentScreen.tsx): `frontend/tourist/src/screens/ReportIncidentScreen.tsx`
- [Sign In and Registration](https://github.com/subham-khandual/suraksha-setu/blob/main/frontend/tourist/src/screens/LoginScreen.tsx): `frontend/tourist/src/screens/LoginScreen.tsx`
- [Digital ID Screens](https://github.com/subham-khandual/suraksha-setu/blob/main/frontend/tourist/src/screens/admin/AdminQRScannerScreen.tsx): `frontend/tourist/src/screens/admin/AdminQRScannerScreen.tsx`

### Identity and Access

- [ID Verification](https://github.com/subham-khandual/suraksha-setu/blob/main/backend/services/verificationService.js): `backend/services/verificationService.js`
- [Authentication Routes](https://github.com/subham-khandual/suraksha-setu/blob/main/backend/routes/auth.js): `backend/routes/auth.js`
- [JWT Access Control](https://github.com/subham-khandual/suraksha-setu/blob/main/backend/middleware/auth.js): `backend/middleware/auth.js`
- [Tourist Accounts](https://github.com/subham-khandual/suraksha-setu/blob/main/backend/models/User.js): `backend/models/User.js`

### Safety Response

- [Incident Management](https://github.com/subham-khandual/suraksha-setu/blob/main/backend/routes/incidents.js): `backend/routes/incidents.js`
- [Incident Records](https://github.com/subham-khandual/suraksha-setu/blob/main/backend/models/IncidentReport.js): `backend/models/IncidentReport.js`
- [Emergency Alerts](https://github.com/subham-khandual/suraksha-setu/blob/main/backend/models/Alert.js): `backend/models/Alert.js`
- [Activity Logging](https://github.com/subham-khandual/suraksha-setu/blob/main/backend/services/activityService.js): `backend/services/activityService.js`

### Travel and Communication

- [Ambulance Booking](https://github.com/subham-khandual/suraksha-setu/blob/main/backend/routes/ambulance.js): `backend/routes/ambulance.js`
- [Hotels and Payments](https://github.com/subham-khandual/suraksha-setu/blob/main/frontend/tourist/src/screens/HotelListingScreen.tsx): `frontend/tourist/src/screens/HotelListingScreen.tsx`
- [Payment Routes](https://github.com/subham-khandual/suraksha-setu/blob/main/backend/routes/payment.js): `backend/routes/payment.js`
- [Community Chat](https://github.com/subham-khandual/suraksha-setu/blob/main/frontend/tourist/src/screens/CommunityChatScreen.tsx): `frontend/tourist/src/screens/CommunityChatScreen.tsx`
- [Community Chat API](https://github.com/subham-khandual/suraksha-setu/blob/main/backend/routes/communityChat.js): `backend/routes/communityChat.js`
- [Live Socket Events](https://github.com/subham-khandual/suraksha-setu/blob/main/backend/socket/socketHandler.js): `backend/socket/socketHandler.js`
- [Community Messages](https://github.com/subham-khandual/suraksha-setu/blob/main/backend/models/CommunityMessage.js): `backend/models/CommunityMessage.js`

### Backend Platform

- [Express API Server](https://github.com/subham-khandual/suraksha-setu/blob/main/backend/server.js): `backend/server.js`
- **MongoDB**

### Other components

- **Tourist**
- **Admin and Authorities**

## Connections

- Tourist → Application Router: uses (evidence: `README.md`)
- Admin and Authorities → Application Router: uses (evidence: `README.md`)
- Application Router → Sign In and Registration: routes to (evidence: `frontend/tourist/src/App.tsx`)
- Application Router → Safety Dashboard: routes to (evidence: `frontend/tourist/src/App.tsx`)
- Application Router → Admin Command Center: routes to (evidence: `frontend/tourist/src/App.tsx`)
- Application Router → Live Tracking Map: routes to (evidence: `frontend/tourist/src/App.tsx`)
- Application Router → Emergency Alert UI: routes to (evidence: `frontend/tourist/src/App.tsx`)
- Application Router → Incident Reporting UI: routes to (evidence: `frontend/tourist/src/App.tsx`)
- Application Router → Digital ID Screens: routes to (evidence: `frontend/tourist/src/App.tsx`)
- Application Router → Hotels and Payments: routes to (evidence: `frontend/tourist/src/App.tsx`)
- Application Router → Community Chat: routes to (evidence: `frontend/tourist/src/App.tsx`)
- Express API Server → Authentication Routes: mounts (evidence: `backend/server.js`)
- Express API Server → Incident Management: mounts (evidence: `backend/server.js`)
- Express API Server → Ambulance Booking: mounts (evidence: `backend/server.js`)
- Express API Server → Payment Routes: mounts (evidence: `backend/server.js`)
- Express API Server → Community Chat API: mounts (evidence: `backend/server.js`)
- Express API Server → Live Socket Events: initializes (evidence: `backend/server.js`)
- Express API Server → MongoDB: connects
- Authentication Routes → Tourist Accounts: reads and writes (evidence: `backend/routes/auth.js`)
- JWT Access Control → Tourist Accounts: loads account (evidence: `backend/middleware/auth.js`)
- Authentication Routes → JWT Access Control: uses access control (evidence: `backend/routes/auth.js`)
- Authentication Routes → ID Verification: uses verification (evidence: `backend/routes/auth.js`)
- ID Verification → Tourist Accounts: looks up (evidence: `backend/services/verificationService.js`)
- ID Verification → Emergency Alerts: checks active alerts (evidence: `backend/services/verificationService.js`)
- Incident Management → Incident Records: reads and writes (evidence: `backend/routes/incidents.js`)
- Incident Management → Emergency Alerts: uses alerts (evidence: `backend/routes/incidents.js`)
- Incident Management → Activity Logging: logs activity (evidence: `backend/routes/incidents.js`)
- Activity Logging → MongoDB: persists activity
- Live Socket Events → Community Messages: saves messages (evidence: `backend/socket/socketHandler.js`)
- Live Socket Events → Tourist Accounts: authenticates users (evidence: `backend/socket/socketHandler.js`)
- Community Chat API → JWT Access Control: uses access control
- Ambulance Booking → MongoDB: persists bookings
- Payment Routes → MongoDB: uses persistence
- Community Chat → Live Socket Events: exchanges live messages
- Emergency Alert UI → Express API Server: submits SOS
- Incident Reporting UI → Incident Management: submits reports
- Digital ID Screens → ID Verification: requests ID checks
