# abhishekmnnit6022/safechalein architecture

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

- Interactive diagram: https://gitdiagram.com/abhishekmnnit6022/safechalein
- Repository: https://github.com/abhishekmnnit6022/safechalein

## Overview

Safe Chalein is a React Native safety app with an Express/MongoDB user backend. The main shown workflow is a user triggering SOS from the home screen: a cancellable countdown precedes an HTTP request, and the backend uses Twilio to place an emergency call. The app also documents map-based tracking, discreet recording, fake calls, helplines, profiles, and camera capture. Those feature screens are represented from the tree and README; their internal wiring was not sampled, so uncertain connections are omitted or marked unverified.

Main entry points: [`app/(tabs)/index.jsx`](https://github.com/abhishekmnnit6022/safechalein/blob/main/app/(tabs)/index.jsx) (Home and SOS), [`Backend/server.js`](https://github.com/abhishekmnnit6022/safechalein/blob/main/Backend/server.js) (Express server), [`Backend/route/user.route.js`](https://github.com/abhishekmnnit6022/safechalein/blob/main/Backend/route/user.route.js) (User routes), [`app/utils/databaseUtils.tsx`](https://github.com/abhishekmnnit6022/safechalein/blob/main/app/utils/databaseUtils.tsx) (Recording metadata)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Safety app"]
  node_onboarding["Onboarding<br/>[index.jsx]"]
  node_auth["Login and signup<br/>[login.jsx]"]
  node_authcheck["Session check<br/>[authCheck.js]"]
  node_home["Home and SOS<br/>[index.jsx]"]
  node_profile["Profile settings<br/>[Settings.jsx]"]
  node_themedview["Themed view<br/>[ThemedView.tsx]"]
  node_theme["Theme colors<br/>[useThemeColor.ts]"]
end

subgraph group_features["Safety features"]
  node_map["Safety map<br/>[Mapview.jsx]"]
  node_location["Location context"]
  node_fakecall["Fake calls<br/>[FakeCall.jsx]"]
  node_helplines["Emergency helplines<br/>[Helpline.jsx]"]
  node_camera["SOS photo capture<br/>[camerause.jsx]"]
  node_friends["Trusted contacts<br/>[Addfriend.jsx]"]
end

subgraph group_backend["Backend services"]
  node_api["Express server<br/>[server.js]"]
  node_sosroute["SOS call endpoint<br/>[server.js]"]
  node_userroute["User routes<br/>[user.route.js]"]
  node_usercontroller["User authentication<br/>[user.controller.js]"]
  node_usermodel[("User records<br/>[user.model.js]")]
end

subgraph group_recordings["Recording storage"]
  node_recording["Discreet recording<br/>[Recording.tsx]"]
  node_recordingutils["Recording utilities<br/>[recordingUtils.tsx]"]
  node_recordingdata[("Recording metadata<br/>[databaseUtils.tsx]")]
  node_history["Recording history<br/>[History.tsx]"]
end

node_user(("App user"))
node_twilio["Twilio voice"]
node_mongodb[("MongoDB")]

node_user -->|"opens"| node_onboarding
node_onboarding -->|"navigates to"| node_auth
node_user -.->|"uses"| node_home
node_home -->|"renders"| node_map
node_home -->|"sends SOS request"| node_api
node_api -->|"handles SOS"| node_sosroute
node_sosroute -->|"places voice call"| node_twilio
node_api -->|"mounts routes"| node_userroute
node_userroute -->|"dispatches auth"| node_usercontroller
node_usercontroller -->|"reads and saves"| node_usermodel
node_usermodel -.->|"persists records"| node_mongodb
node_authcheck -.->|"routes unauthenticated"| node_auth
node_recording -.->|"uses recording"| node_recordingutils
node_recording -.->|"stores metadata"| node_recordingdata
node_recordingdata -->|"checks audio files"| node_recordingutils
node_history -.->|"loads recordings"| node_recordingdata
node_profile -.->|"may update profile"| node_userroute
node_map -.->|"uses location"| node_location
node_camera -.->|"may capture during SOS"| node_home
node_themedview -.->|"uses colors"| node_theme

click node_onboarding "https://github.com/abhishekmnnit6022/safechalein/blob/main/app/index.jsx"
click node_auth "https://github.com/abhishekmnnit6022/safechalein/blob/main/app/login.jsx"
click node_authcheck "https://github.com/abhishekmnnit6022/safechalein/blob/main/app/authCheck.js"
click node_home "https://github.com/abhishekmnnit6022/safechalein/blob/main/app/(tabs)/index.jsx"
click node_map "https://github.com/abhishekmnnit6022/safechalein/blob/main/app/Mapview.jsx"
click node_location "https://github.com/abhishekmnnit6022/safechalein/blob/main/context/UserLocationcontext.jsx"
click node_fakecall "https://github.com/abhishekmnnit6022/safechalein/blob/main/app/(tabs)/FakeCall.jsx"
click node_helplines "https://github.com/abhishekmnnit6022/safechalein/blob/main/app/(tabs)/Helpline.jsx"
click node_recording "https://github.com/abhishekmnnit6022/safechalein/blob/main/app/(tabs)/Recording.tsx"
click node_recordingutils "https://github.com/abhishekmnnit6022/safechalein/blob/main/app/utils/recordingUtils.tsx"
click node_recordingdata "https://github.com/abhishekmnnit6022/safechalein/blob/main/app/utils/databaseUtils.tsx"
click node_history "https://github.com/abhishekmnnit6022/safechalein/blob/main/app/(tabs)/History.tsx"
click node_camera "https://github.com/abhishekmnnit6022/safechalein/blob/main/app/camerause.jsx"
click node_profile "https://github.com/abhishekmnnit6022/safechalein/blob/main/app/Settings.jsx"
click node_friends "https://github.com/abhishekmnnit6022/safechalein/blob/main/app/Addfriend.jsx"
click node_api "https://github.com/abhishekmnnit6022/safechalein/blob/main/Backend/server.js"
click node_sosroute "https://github.com/abhishekmnnit6022/safechalein/blob/main/Backend/server.js"
click node_userroute "https://github.com/abhishekmnnit6022/safechalein/blob/main/Backend/route/user.route.js"
click node_usercontroller "https://github.com/abhishekmnnit6022/safechalein/blob/main/Backend/controller/user.controller.js"
click node_usermodel "https://github.com/abhishekmnnit6022/safechalein/blob/main/Backend/model/user.model.js"
click node_themedview "https://github.com/abhishekmnnit6022/safechalein/blob/main/components/ThemedView.tsx"
click node_theme "https://github.com/abhishekmnnit6022/safechalein/blob/main/hooks/useThemeColor.ts"

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_onboarding,node_auth,node_authcheck,node_home,node_profile,node_themedview,node_theme,node_user toneBlue
class node_map,node_location,node_fakecall,node_helplines,node_camera,node_friends,node_mongodb toneAmber
class node_api,node_sosroute,node_userroute,node_usercontroller,node_usermodel toneMint
class node_recording,node_recordingutils,node_recordingdata,node_history toneRose
class node_twilio toneIndigo
```

## Components

### Safety app

- [Onboarding](https://github.com/abhishekmnnit6022/safechalein/blob/main/app/index.jsx): `app/index.jsx`
- [Login and signup](https://github.com/abhishekmnnit6022/safechalein/blob/main/app/login.jsx): `app/login.jsx`
- [Session check](https://github.com/abhishekmnnit6022/safechalein/blob/main/app/authCheck.js): `app/authCheck.js`
- [Home and SOS](https://github.com/abhishekmnnit6022/safechalein/blob/main/app/(tabs)/index.jsx): `app/(tabs)/index.jsx`
- [Profile settings](https://github.com/abhishekmnnit6022/safechalein/blob/main/app/Settings.jsx): `app/Settings.jsx`
- [Themed view](https://github.com/abhishekmnnit6022/safechalein/blob/main/components/ThemedView.tsx): `components/ThemedView.tsx`
- [Theme colors](https://github.com/abhishekmnnit6022/safechalein/blob/main/hooks/useThemeColor.ts): `hooks/useThemeColor.ts`

### Safety features

- [Safety map](https://github.com/abhishekmnnit6022/safechalein/blob/main/app/Mapview.jsx): `app/Mapview.jsx`
- [Location context](https://github.com/abhishekmnnit6022/safechalein/blob/main/context/UserLocationcontext.jsx): `context/UserLocationcontext.jsx`
- [Fake calls](https://github.com/abhishekmnnit6022/safechalein/blob/main/app/(tabs)/FakeCall.jsx): `app/(tabs)/FakeCall.jsx`
- [Emergency helplines](https://github.com/abhishekmnnit6022/safechalein/blob/main/app/(tabs)/Helpline.jsx): `app/(tabs)/Helpline.jsx`
- [SOS photo capture](https://github.com/abhishekmnnit6022/safechalein/blob/main/app/camerause.jsx): `app/camerause.jsx`
- [Trusted contacts](https://github.com/abhishekmnnit6022/safechalein/blob/main/app/Addfriend.jsx): `app/Addfriend.jsx`

### Backend services

- [Express server](https://github.com/abhishekmnnit6022/safechalein/blob/main/Backend/server.js): `Backend/server.js`
- [SOS call endpoint](https://github.com/abhishekmnnit6022/safechalein/blob/main/Backend/server.js): `Backend/server.js`
- [User routes](https://github.com/abhishekmnnit6022/safechalein/blob/main/Backend/route/user.route.js): `Backend/route/user.route.js`
- [User authentication](https://github.com/abhishekmnnit6022/safechalein/blob/main/Backend/controller/user.controller.js): `Backend/controller/user.controller.js`
- [User records](https://github.com/abhishekmnnit6022/safechalein/blob/main/Backend/model/user.model.js): `Backend/model/user.model.js`

### Recording storage

- [Discreet recording](https://github.com/abhishekmnnit6022/safechalein/blob/main/app/(tabs)/Recording.tsx): `app/(tabs)/Recording.tsx`
- [Recording utilities](https://github.com/abhishekmnnit6022/safechalein/blob/main/app/utils/recordingUtils.tsx): `app/utils/recordingUtils.tsx`
- [Recording metadata](https://github.com/abhishekmnnit6022/safechalein/blob/main/app/utils/databaseUtils.tsx): `app/utils/databaseUtils.tsx`
- [Recording history](https://github.com/abhishekmnnit6022/safechalein/blob/main/app/(tabs)/History.tsx): `app/(tabs)/History.tsx`

### Other components

- **App user**
- **Twilio voice**
- **MongoDB**

## Connections

- App user → Onboarding: opens (evidence: `app/index.jsx`)
- Onboarding → Login and signup: navigates to (evidence: `app/index.jsx`)
- App user → Home and SOS: uses
- Home and SOS → Safety map: renders (evidence: `app/(tabs)/index.jsx`)
- Home and SOS → Express server: sends SOS request (evidence: `app/(tabs)/index.jsx`)
- Express server → SOS call endpoint: handles SOS (evidence: `Backend/server.js`)
- SOS call endpoint → Twilio voice: places voice call (evidence: `Backend/server.js`)
- Express server → User routes: mounts routes (evidence: `Backend/server.js`)
- User routes → User authentication: dispatches auth (evidence: `Backend/route/user.route.js`)
- User authentication → User records: reads and saves (evidence: `Backend/controller/user.controller.js`)
- User records → MongoDB: persists records
- Session check → Login and signup: routes unauthenticated
- Discreet recording → Recording utilities: uses recording
- Discreet recording → Recording metadata: stores metadata
- Recording metadata → Recording utilities: checks audio files (evidence: `app/utils/databaseUtils.tsx`)
- Recording history → Recording metadata: loads recordings
- Profile settings → User routes: may update profile
- Safety map → Location context: uses location
- SOS photo capture → Home and SOS: may capture during SOS
- Themed view → Theme colors: uses colors
