# chiranthan248/saferide architecture

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

- Interactive diagram: https://gitdiagram.com/chiranthan248/saferide
- Repository: https://github.com/chiranthan248/saferide

## Overview

SafeRide is a Django safety platform for commuters and guardians. A commuter registers or starts a ride, shares GPS updates, and can submit an incident or trigger SOS; guardians review and resolve alerts. Ride and incident records also feed hazard-zone clustering and incident-probability prediction, exposed through analytics endpoints and dashboards. The graph includes the documented REST API, trusted contacts, trip history, and fake-call feature. Some UI and routing links are based on README descriptions; unsampled implementation details are not inferred.

Main entry points: [`urls.py`](https://github.com/chiranthan248/saferide/blob/main/urls.py) (Application routing), [`templates/user`](https://github.com/chiranthan248/saferide/tree/main/templates/user) (Commuter screens), [`user/views.py`](https://github.com/chiranthan248/saferide/blob/main/user/views.py) (Ride and SOS flows), [`admin_app/views.py`](https://github.com/chiranthan248/saferide/blob/main/admin_app/views.py) (Alert management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_commuter["Commuter safety"]
  node_commuter_ui["Commuter screens"]
  node_commuter_views["Ride and SOS flows<br/>[views.py]"]
  node_trip_contacts["Trips and contacts<br/>[views.py]"]
  node_incident_reporting["Incident reporting<br/>[views.py]"]
end

subgraph group_guardian["Guardian response"]
  node_guardian_ui["Guardian dashboard"]
  node_guardian_views["Alert management<br/>[views.py]"]
  node_guardian_records[("Guardian records<br/>[models.py]")]
end

subgraph group_analytics["Safety analytics"]
  node_analytics_api["Analytics endpoints<br/>[api.py]"]
  node_analytics_service["ML analytics<br/>[services.py]"]
end

subgraph group_platform["Shared data and API"]
  node_user_api["Ride and incident API<br/>[api.py]"]
  node_serializers["API serializers<br/>[serializers.py]"]
  node_safety_records[("Commuter safety records<br/>[models.py]")]
  node_root_routes["Application routing<br/>[urls.py]"]
end

node_commuter_actor(("Commuter"))
node_guardian_actor(("Guardian"))
node_web_client(("Web client"))

node_commuter_actor -->|"uses"| node_commuter_ui
node_commuter_ui -.->|"submits actions"| node_commuter_views
node_commuter_views -->|"creates and reads"| node_safety_records
node_commuter_views -->|"handles"| node_trip_contacts
node_commuter_views -->|"records reports"| node_incident_reporting
node_guardian_actor -->|"uses"| node_guardian_ui
node_guardian_ui -.->|"submits actions"| node_guardian_views
node_guardian_views -->|"reads and updates"| node_safety_records
node_guardian_views -->|"reads and updates"| node_guardian_records
node_web_client -->|"requests"| node_root_routes
node_root_routes -->|"routes API"| node_user_api
node_root_routes -->|"routes analytics"| node_analytics_api
node_root_routes -->|"routes pages"| node_commuter_views
node_root_routes -->|"routes pages"| node_guardian_views
node_user_api -->|"queries and saves"| node_safety_records
node_user_api -->|"serializes"| node_serializers
node_analytics_api -->|"requests predictions"| node_analytics_service
node_analytics_service -->|"reads rides and incidents"| node_safety_records
node_commuter_ui -.->|"requests risk data"| node_analytics_api
node_guardian_ui -.->|"requests hazard data"| node_analytics_api
node_commuter_ui -.->|"offers fake call"| node_commuter_ui

click node_commuter_ui "https://github.com/chiranthan248/saferide/tree/main/templates/user"
click node_commuter_views "https://github.com/chiranthan248/saferide/blob/main/user/views.py"
click node_trip_contacts "https://github.com/chiranthan248/saferide/blob/main/user/views.py"
click node_incident_reporting "https://github.com/chiranthan248/saferide/blob/main/user/views.py"
click node_guardian_ui "https://github.com/chiranthan248/saferide/tree/main/templates/admin_app"
click node_guardian_views "https://github.com/chiranthan248/saferide/blob/main/admin_app/views.py"
click node_guardian_records "https://github.com/chiranthan248/saferide/blob/main/admin_app/models.py"
click node_analytics_api "https://github.com/chiranthan248/saferide/blob/main/analytics_app/api.py"
click node_analytics_service "https://github.com/chiranthan248/saferide/blob/main/analytics_app/services.py"
click node_user_api "https://github.com/chiranthan248/saferide/blob/main/user/api.py"
click node_serializers "https://github.com/chiranthan248/saferide/blob/main/user/serializers.py"
click node_safety_records "https://github.com/chiranthan248/saferide/blob/main/user/models.py"
click node_root_routes "https://github.com/chiranthan248/saferide/blob/main/urls.py"

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_commuter_ui,node_commuter_views,node_trip_contacts,node_incident_reporting,node_web_client toneBlue
class node_guardian_ui,node_guardian_views,node_guardian_records toneAmber
class node_analytics_api,node_analytics_service toneMint
class node_user_api,node_serializers,node_safety_records,node_root_routes toneRose
class node_commuter_actor,node_guardian_actor toneIndigo
```

## Components

### Commuter safety

- [Commuter screens](https://github.com/chiranthan248/saferide/tree/main/templates/user): `templates/user`
- [Ride and SOS flows](https://github.com/chiranthan248/saferide/blob/main/user/views.py): `user/views.py`
- [Trips and contacts](https://github.com/chiranthan248/saferide/blob/main/user/views.py): `user/views.py`
- [Incident reporting](https://github.com/chiranthan248/saferide/blob/main/user/views.py): `user/views.py`

### Guardian response

- [Guardian dashboard](https://github.com/chiranthan248/saferide/tree/main/templates/admin_app): `templates/admin_app`
- [Alert management](https://github.com/chiranthan248/saferide/blob/main/admin_app/views.py): `admin_app/views.py`
- [Guardian records](https://github.com/chiranthan248/saferide/blob/main/admin_app/models.py): `admin_app/models.py`

### Safety analytics

- [Analytics endpoints](https://github.com/chiranthan248/saferide/blob/main/analytics_app/api.py): `analytics_app/api.py`
- [ML analytics](https://github.com/chiranthan248/saferide/blob/main/analytics_app/services.py): `analytics_app/services.py`

### Shared data and API

- [Ride and incident API](https://github.com/chiranthan248/saferide/blob/main/user/api.py): `user/api.py`
- [API serializers](https://github.com/chiranthan248/saferide/blob/main/user/serializers.py): `user/serializers.py`
- [Commuter safety records](https://github.com/chiranthan248/saferide/blob/main/user/models.py): `user/models.py`
- [Application routing](https://github.com/chiranthan248/saferide/blob/main/urls.py): `urls.py`

### Other components

- **Commuter**
- **Guardian**
- **Web client**

## Connections

- Commuter → Commuter screens: uses (evidence: `README.md`)
- Commuter screens → Ride and SOS flows: submits actions
- Ride and SOS flows → Commuter safety records: creates and reads (evidence: `user/views.py`)
- Ride and SOS flows → Trips and contacts: handles (evidence: `user/views.py`)
- Ride and SOS flows → Incident reporting: records reports (evidence: `user/views.py`)
- Guardian → Guardian dashboard: uses (evidence: `README.md`)
- Guardian dashboard → Alert management: submits actions
- Alert management → Commuter safety records: reads and updates (evidence: `admin_app/views.py`)
- Alert management → Guardian records: reads and updates (evidence: `admin_app/views.py`)
- Web client → Application routing: requests (evidence: `urls.py`)
- Application routing → Ride and incident API: routes API (evidence: `urls.py`)
- Application routing → Analytics endpoints: routes analytics (evidence: `urls.py`)
- Application routing → Ride and SOS flows: routes pages (evidence: `urls.py`)
- Application routing → Alert management: routes pages (evidence: `urls.py`)
- Ride and incident API → Commuter safety records: queries and saves (evidence: `user/api.py`)
- Ride and incident API → API serializers: serializes (evidence: `user/api.py`)
- Analytics endpoints → ML analytics: requests predictions (evidence: `analytics_app/api.py`)
- ML analytics → Commuter safety records: reads rides and incidents (evidence: `analytics_app/services.py`)
- Commuter screens → Analytics endpoints: requests risk data (evidence: `README.md`)
- Guardian dashboard → Analytics endpoints: requests hazard data (evidence: `README.md`)
- Commuter screens → Commuter screens: offers fake call (evidence: `README.md`)
