# montasim2003/smart-sos-system architecture

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

- Interactive diagram: https://gitdiagram.com/montasim2003/smart-sos-system
- Repository: https://github.com/montasim2003/smart-sos-system

## Overview

Smart SOS is a citizen emergency-response system with user and provider portals, real-time SOS handling, and Android background location and crash detection. The main flow is citizen authentication, SOS creation with location/media, provider dispatch and tracking, and status updates. The graph also includes provider authentication, user-profile/device synchronization, and the native crash-detection path. Source excerpts show the app routing, some API calls, model use, and Android service interactions; several UI-to-backend and socket details are not visible, so those links are marked unverified or omitted.

Main entry points: [`server/index.js`](https://github.com/montasim2003/smart-sos-system/blob/main/server/index.js) (HTTP and socket API), [`client/src/App.jsx`](https://github.com/montasim2003/smart-sos-system/blob/main/client/src/App.jsx) (Portal router), [`client/src/components/ProviderDashboard.jsx`](https://github.com/montasim2003/smart-sos-system/blob/main/client/src/components/ProviderDashboard.jsx) (Provider dashboard), [`client/src/components/UserApp.jsx`](https://github.com/montasim2003/smart-sos-system/blob/main/client/src/components/UserApp.jsx) (Citizen SOS portal)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["Portal router<br/>[App.jsx]"]
  node_userauth["User authentication<br/>[UserLogin.jsx]"]
  node_userportal["Citizen SOS portal<br/>[UserApp.jsx]"]
  node_crashui["Crash detection UI"]
  node_providerauth["Provider authentication<br/>[ProviderLogin.jsx]"]
  node_dashboard["Provider dashboard"]
end

subgraph group_server["SOS backend"]
  node_api["HTTP and socket API<br/>[index.js]"]
end

subgraph group_native["Android runtime"]
  node_nativeactivity["Native activity bridge<br/>[MainActivity.java]"]
  node_location["Location and crash service"]
end

subgraph group_data["Domain data"]
  node_users[("User records<br/>[User.js]")]
  node_providers[("Provider records<br/>[Provider.js]")]
  node_emergencies[("Emergency records<br/>[Emergency.js]")]
end

node_citizen(("Citizen"))
node_provider(("Emergency provider"))
node_mongodb[("MongoDB")]
node_socket["Socket.IO clients"]

node_citizen -->|"opens portal"| node_app
node_app -->|"routes to"| node_userauth
node_app -->|"routes to"| node_userportal
node_app -->|"routes to"| node_providerauth
node_app -->|"routes to"| node_dashboard
node_userauth -->|"sends auth request"| node_api
node_providerauth -.->|"authenticates"| node_api
node_userportal -.->|"SOS and profile requests"| node_api
node_userportal -->|"uses detector"| node_crashui
node_dashboard -->|"presents incidents"| node_provider
node_provider -->|"reviews and responds"| node_dashboard
node_dashboard -.->|"socket and API requests"| node_api
node_api -->|"reads and updates"| node_users
node_api -->|"reads and updates"| node_providers
node_api -->|"creates and updates"| node_emergencies
node_users -.->|"persists records"| node_mongodb
node_providers -.->|"persists records"| node_mongodb
node_emergencies -.->|"persists records"| node_mongodb
node_api -.->|"dispatches events"| node_socket
node_socket -.->|"delivers updates"| node_dashboard
node_app -.->|"runs on native"| node_nativeactivity
node_nativeactivity -->|"starts service"| node_location
node_location -->|"launches crash intent"| node_nativeactivity
node_location -->|"syncs device location"| node_api

click node_app "https://github.com/montasim2003/smart-sos-system/blob/main/client/src/App.jsx"
click node_userauth "https://github.com/montasim2003/smart-sos-system/blob/main/client/src/components/UserLogin.jsx"
click node_userportal "https://github.com/montasim2003/smart-sos-system/blob/main/client/src/components/UserApp.jsx"
click node_crashui "https://github.com/montasim2003/smart-sos-system/blob/main/client/src/components/AutoCrashDetector.jsx"
click node_providerauth "https://github.com/montasim2003/smart-sos-system/blob/main/client/src/components/ProviderLogin.jsx"
click node_dashboard "https://github.com/montasim2003/smart-sos-system/blob/main/client/src/components/ProviderDashboard.jsx"
click node_api "https://github.com/montasim2003/smart-sos-system/blob/main/server/index.js"
click node_nativeactivity "https://github.com/montasim2003/smart-sos-system/blob/main/client/android/app/src/main/java/com/smartsos/app/MainActivity.java"
click node_location "https://github.com/montasim2003/smart-sos-system/blob/main/client/android/app/src/main/java/LocationService.java"
click node_users "https://github.com/montasim2003/smart-sos-system/blob/main/server/models/User.js"
click node_providers "https://github.com/montasim2003/smart-sos-system/blob/main/server/models/Provider.js"
click node_emergencies "https://github.com/montasim2003/smart-sos-system/blob/main/server/models/Emergency.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_userauth,node_userportal,node_crashui,node_providerauth,node_dashboard,node_socket toneBlue
class node_api,node_mongodb toneAmber
class node_nativeactivity,node_location toneMint
class node_users,node_providers,node_emergencies toneRose
class node_citizen,node_provider toneIndigo
```

## Components

### Web client

- [Portal router](https://github.com/montasim2003/smart-sos-system/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [User authentication](https://github.com/montasim2003/smart-sos-system/blob/main/client/src/components/UserLogin.jsx): `client/src/components/UserLogin.jsx`
- [Citizen SOS portal](https://github.com/montasim2003/smart-sos-system/blob/main/client/src/components/UserApp.jsx): `client/src/components/UserApp.jsx`
- [Crash detection UI](https://github.com/montasim2003/smart-sos-system/blob/main/client/src/components/AutoCrashDetector.jsx): `client/src/components/AutoCrashDetector.jsx`
- [Provider authentication](https://github.com/montasim2003/smart-sos-system/blob/main/client/src/components/ProviderLogin.jsx): `client/src/components/ProviderLogin.jsx`
- [Provider dashboard](https://github.com/montasim2003/smart-sos-system/blob/main/client/src/components/ProviderDashboard.jsx): `client/src/components/ProviderDashboard.jsx`

### SOS backend

- [HTTP and socket API](https://github.com/montasim2003/smart-sos-system/blob/main/server/index.js): `server/index.js`

### Android runtime

- [Native activity bridge](https://github.com/montasim2003/smart-sos-system/blob/main/client/android/app/src/main/java/com/smartsos/app/MainActivity.java): `client/android/app/src/main/java/com/smartsos/app/MainActivity.java`
- [Location and crash service](https://github.com/montasim2003/smart-sos-system/blob/main/client/android/app/src/main/java/LocationService.java): `client/android/app/src/main/java/LocationService.java`

### Domain data

- [User records](https://github.com/montasim2003/smart-sos-system/blob/main/server/models/User.js): `server/models/User.js`
- [Provider records](https://github.com/montasim2003/smart-sos-system/blob/main/server/models/Provider.js): `server/models/Provider.js`
- [Emergency records](https://github.com/montasim2003/smart-sos-system/blob/main/server/models/Emergency.js): `server/models/Emergency.js`

### Other components

- **Citizen**
- **Emergency provider**
- **MongoDB**
- **Socket.IO clients**

## Connections

- Citizen → Portal router: opens portal (evidence: `client/src/App.jsx`)
- Portal router → User authentication: routes to (evidence: `client/src/App.jsx`)
- Portal router → Citizen SOS portal: routes to (evidence: `client/src/App.jsx`)
- Portal router → Provider authentication: routes to (evidence: `client/src/App.jsx`)
- Portal router → Provider dashboard: routes to (evidence: `client/src/App.jsx`)
- User authentication → HTTP and socket API: sends auth request (evidence: `client/src/components/UserLogin.jsx`)
- Provider authentication → HTTP and socket API: authenticates
- Citizen SOS portal → HTTP and socket API: SOS and profile requests
- Citizen SOS portal → Crash detection UI: uses detector (evidence: `client/src/components/UserApp.jsx`)
- Provider dashboard → Emergency provider: presents incidents (evidence: `client/src/components/ProviderDashboard.jsx`)
- Emergency provider → Provider dashboard: reviews and responds (evidence: `client/src/components/ProviderDashboard.jsx`)
- Provider dashboard → HTTP and socket API: socket and API requests
- HTTP and socket API → User records: reads and updates (evidence: `server/index.js`)
- HTTP and socket API → Provider records: reads and updates (evidence: `server/index.js`)
- HTTP and socket API → Emergency records: creates and updates (evidence: `server/index.js`)
- User records → MongoDB: persists records
- Provider records → MongoDB: persists records
- Emergency records → MongoDB: persists records
- HTTP and socket API → Socket.IO clients: dispatches events
- Socket.IO clients → Provider dashboard: delivers updates
- Portal router → Native activity bridge: runs on native
- Native activity bridge → Location and crash service: starts service (evidence: `client/android/app/src/main/java/com/smartsos/app/MainActivity.java`)
- Location and crash service → Native activity bridge: launches crash intent (evidence: `client/android/app/src/main/java/LocationService.java`)
- Location and crash service → HTTP and socket API: syncs device location (evidence: `client/android/app/src/main/java/LocationService.java`)
