# nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject architecture

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

- Interactive diagram: https://gitdiagram.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject
- Repository: https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject

## Overview

SafeHer AI is a women’s-safety platform with a mobile app for users, a FastAPI backend, and a web admin dashboard. The main user workflow is to register, trigger an SOS or submit text/voice for danger analysis, then share location and alert trusted contacts and administrators; users can also manage contacts, chat, and report complaints. The backend provides REST and Socket.IO services, while administrators monitor alerts, maps, analytics, and broadcasts. Some subsystem links are supported only by README descriptions because their implementation was not excerpted.

Main entry points: [`backend/app/main.py`](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/backend/app/main.py) (REST API), [`frontend/src/api/client.ts`](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/frontend/src/api/client.ts) (Mobile API client), [`frontend/App.tsx`](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/frontend/App.tsx) (Mobile app shell), [`admin-dashboard/src/App.tsx`](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/admin-dashboard/src/App.tsx) (Dashboard routing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile safety app"]
  node_mobile_app["Mobile app shell<br/>[App.tsx]"]
  node_mobile_auth["User authentication<br/>[AuthContext.tsx]"]
  node_mobile_api["Mobile API client<br/>[client.ts]"]
  node_sos_ui["SOS experience<br/>[SOSScreen.tsx]"]
  node_map_ui["Safety map<br/>[MapScreen.tsx]"]
  node_mobile_socket["Live connection<br/>[SocketContext.tsx]"]
  node_mobile_features["Safety features"]
end

subgraph group_backend["Backend services"]
  node_api_server["REST API<br/>[main.py]"]
  node_auth_routes["Auth routes<br/>[auth.py]"]
  node_sos_routes["SOS routes<br/>[sos.py]"]
  node_ai_routes["AI analysis routes<br/>[ai.py]"]
  node_location_routes["Location routes<br/>[location.py]"]
  node_other_routes["Other product routes"]
  node_llm["Danger analysis engine<br/>[llm_engine.py]"]
  node_dispatch["Emergency dispatch<br/>[twilio_service.py]"]
  node_socket_server["Live event server<br/>[socket_manager.py]"]
end

subgraph group_admin["Admin command center"]
  node_admin_app["Dashboard routing<br/>[App.tsx]"]
  node_admin_auth["Admin authentication<br/>[AuthContext.tsx]"]
  node_admin_api["Dashboard API client<br/>[api.ts]"]
  node_admin_socket["Dashboard live connection<br/>[SocketContext.tsx]"]
  node_admin_views["Monitoring and management"]
end

subgraph group_platform["Platform infrastructure"]
  node_database[("MongoDB access<br/>[database.py]")]
end

node_user(("Safety app user"))
node_administrator(("Administrator"))
node_twilio["Twilio"]
node_llm_provider["GPT-4 / Whisper AI"]

node_user -->|"uses"| node_mobile_app
node_mobile_app -->|"provides context"| node_mobile_auth
node_mobile_app -->|"provides context"| node_mobile_socket
node_mobile_app -->|"navigates screens"| node_mobile_features
node_mobile_auth -->|"calls auth API"| node_mobile_api
node_sos_ui -->|"submits SOS"| node_mobile_api
node_mobile_api -->|"sends REST requests"| node_api_server
node_api_server -->|"registers routes"| node_auth_routes
node_api_server -->|"registers routes"| node_sos_routes
node_api_server -->|"registers routes"| node_ai_routes
node_api_server -->|"registers routes"| node_location_routes
node_api_server -->|"registers routes"| node_other_routes
node_mobile_api -->|"posts SOS"| node_sos_routes
node_mobile_api -->|"requests analysis"| node_ai_routes
node_mobile_api -->|"updates location"| node_location_routes
node_sos_routes -.->|"requests emergency dispatch"| node_dispatch
node_dispatch -->|"sends SMS and calls"| node_twilio
node_ai_routes -.->|"runs danger analysis"| node_llm
node_llm -->|"uses AI models"| node_llm_provider
node_sos_routes -->|"broadcasts alert"| node_socket_server
node_location_routes -->|"broadcasts location"| node_socket_server
node_api_server -->|"connects at startup"| node_database
node_administrator -->|"uses"| node_admin_app
node_admin_app -->|"provides auth context"| node_admin_auth
node_admin_app -->|"provides socket context"| node_admin_socket
node_admin_app -->|"routes to views"| node_admin_views
node_admin_auth -->|"authenticates through"| node_admin_api
node_admin_views -->|"requests dashboard data"| node_admin_api
node_admin_socket -->|"connects live"| node_socket_server
node_socket_server -->|"delivers alerts"| node_admin_socket
node_map_ui -.->|"loads map data"| node_mobile_api

click node_mobile_app "https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/frontend/App.tsx"
click node_mobile_auth "https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/frontend/src/context/AuthContext.tsx"
click node_mobile_api "https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/frontend/src/api/client.ts"
click node_sos_ui "https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/frontend/src/screens/SOSScreen.tsx"
click node_map_ui "https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/frontend/src/screens/MapScreen.tsx"
click node_mobile_socket "https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/frontend/src/context/SocketContext.tsx"
click node_mobile_features "https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/tree/main/frontend/src/screens"
click node_api_server "https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/backend/app/main.py"
click node_auth_routes "https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/backend/app/api/routes/auth.py"
click node_sos_routes "https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/backend/app/api/routes/sos.py"
click node_ai_routes "https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/backend/app/api/routes/ai.py"
click node_location_routes "https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/backend/app/api/routes/location.py"
click node_other_routes "https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/tree/main/backend/app/api/routes"
click node_llm "https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/backend/app/ai/llm_engine.py"
click node_dispatch "https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/backend/app/services/twilio_service.py"
click node_socket_server "https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/backend/app/websockets/socket_manager.py"
click node_database "https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/backend/app/core/database.py"
click node_admin_app "https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/admin-dashboard/src/App.tsx"
click node_admin_auth "https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/admin-dashboard/src/AuthContext.tsx"
click node_admin_api "https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/admin-dashboard/src/api.ts"
click node_admin_socket "https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/admin-dashboard/src/SocketContext.tsx"
click node_admin_views "https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/tree/main/admin-dashboard/src"

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_mobile_app,node_mobile_auth,node_mobile_api,node_sos_ui,node_map_ui,node_mobile_socket,node_mobile_features,node_user toneBlue
class node_api_server,node_auth_routes,node_sos_routes,node_ai_routes,node_location_routes,node_other_routes,node_llm,node_dispatch,node_socket_server toneAmber
class node_admin_app,node_admin_auth,node_admin_api,node_admin_socket,node_admin_views toneMint
class node_database toneRose
class node_administrator,node_twilio,node_llm_provider toneIndigo
```

## Components

### Mobile safety app

- [Mobile app shell](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/frontend/App.tsx): `frontend/App.tsx`
- [User authentication](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/frontend/src/context/AuthContext.tsx): `frontend/src/context/AuthContext.tsx`
- [Mobile API client](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [SOS experience](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/frontend/src/screens/SOSScreen.tsx): `frontend/src/screens/SOSScreen.tsx`
- [Safety map](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/frontend/src/screens/MapScreen.tsx): `frontend/src/screens/MapScreen.tsx`
- [Live connection](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/frontend/src/context/SocketContext.tsx): `frontend/src/context/SocketContext.tsx`
- [Safety features](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/tree/main/frontend/src/screens): `frontend/src/screens`

### Backend services

- [REST API](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/backend/app/main.py): `backend/app/main.py`
- [Auth routes](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/backend/app/api/routes/auth.py): `backend/app/api/routes/auth.py`
- [SOS routes](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/backend/app/api/routes/sos.py): `backend/app/api/routes/sos.py`
- [AI analysis routes](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/backend/app/api/routes/ai.py): `backend/app/api/routes/ai.py`
- [Location routes](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/backend/app/api/routes/location.py): `backend/app/api/routes/location.py`
- [Other product routes](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/tree/main/backend/app/api/routes): `backend/app/api/routes`
- [Danger analysis engine](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/backend/app/ai/llm_engine.py): `backend/app/ai/llm_engine.py`
- [Emergency dispatch](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/backend/app/services/twilio_service.py): `backend/app/services/twilio_service.py`
- [Live event server](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/backend/app/websockets/socket_manager.py): `backend/app/websockets/socket_manager.py`

### Admin command center

- [Dashboard routing](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/admin-dashboard/src/App.tsx): `admin-dashboard/src/App.tsx`
- [Admin authentication](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/admin-dashboard/src/AuthContext.tsx): `admin-dashboard/src/AuthContext.tsx`
- [Dashboard API client](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/admin-dashboard/src/api.ts): `admin-dashboard/src/api.ts`
- [Dashboard live connection](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/admin-dashboard/src/SocketContext.tsx): `admin-dashboard/src/SocketContext.tsx`
- [Monitoring and management](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/tree/main/admin-dashboard/src): `admin-dashboard/src`

### Platform infrastructure

- [MongoDB access](https://github.com/nikhil-shetty14/safeher-ai--womensafetyintelligencesystem_majorproject/blob/main/backend/app/core/database.py): `backend/app/core/database.py`

### Other components

- **Safety app user**
- **Administrator**
- **Twilio**
- **GPT-4 / Whisper AI**

## Connections

- Safety app user → Mobile app shell: uses (evidence: `README.md`)
- Mobile app shell → User authentication: provides context (evidence: `frontend/App.tsx`)
- Mobile app shell → Live connection: provides context (evidence: `frontend/App.tsx`)
- Mobile app shell → Safety features: navigates screens
- User authentication → Mobile API client: calls auth API (evidence: `frontend/src/context/AuthContext.tsx`)
- SOS experience → Mobile API client: submits SOS (evidence: `frontend/src/screens/SOSScreen.tsx`)
- Mobile API client → REST API: sends REST requests (evidence: `frontend/src/api/client.ts`)
- REST API → Auth routes: registers routes (evidence: `backend/app/main.py`)
- REST API → SOS routes: registers routes (evidence: `backend/app/main.py`)
- REST API → AI analysis routes: registers routes (evidence: `backend/app/main.py`)
- REST API → Location routes: registers routes (evidence: `backend/app/main.py`)
- REST API → Other product routes: registers routes (evidence: `backend/app/main.py`)
- Mobile API client → SOS routes: posts SOS (evidence: `frontend/src/api/client.ts`)
- Mobile API client → AI analysis routes: requests analysis (evidence: `README.md`)
- Mobile API client → Location routes: updates location (evidence: `README.md`)
- SOS routes → Emergency dispatch: requests emergency dispatch (evidence: `README.md`)
- Emergency dispatch → Twilio: sends SMS and calls (evidence: `README.md`)
- AI analysis routes → Danger analysis engine: runs danger analysis
- Danger analysis engine → GPT-4 / Whisper AI: uses AI models (evidence: `README.md`)
- SOS routes → Live event server: broadcasts alert (evidence: `README.md`)
- Location routes → Live event server: broadcasts location (evidence: `README.md`)
- REST API → MongoDB access: connects at startup (evidence: `backend/app/main.py`)
- Administrator → Dashboard routing: uses (evidence: `README.md`)
- Dashboard routing → Admin authentication: provides auth context (evidence: `admin-dashboard/src/App.tsx`)
- Dashboard routing → Dashboard live connection: provides socket context (evidence: `admin-dashboard/src/App.tsx`)
- Dashboard routing → Monitoring and management: routes to views (evidence: `admin-dashboard/src/App.tsx`)
- Admin authentication → Dashboard API client: authenticates through (evidence: `admin-dashboard/src/AuthContext.tsx`)
- Monitoring and management → Dashboard API client: requests dashboard data (evidence: `admin-dashboard/src/AlertsPage.tsx`)
- Dashboard live connection → Live event server: connects live (evidence: `README.md`)
- Live event server → Dashboard live connection: delivers alerts (evidence: `README.md`)
- Safety map → Mobile API client: loads map data
