A full-stack emergency safety platform built for Indian women, featuring multilingual AI assistance, SOS triggering, real-time location sharing, legal rights guidance, and nearby resource discovery — all in one app.
- Hold-to-trigger SOS — 3-second hold with visual progress ring
- Instant Panic Mode — one-tap for critical emergencies
- Live GPS tracking — location pushed to backend every ~10 seconds during active SOS
- Auto SOS — AI chat detects risk score ≥ 9 and triggers SOS automatically
- Emergency contact notifications — SMS/WhatsApp alerts queued via Twilio-ready pipeline
- Live map — Google Maps iframe embedded in SOS active screen
- Multilingual understanding — detects and responds in 10 Indian languages (Hindi, Tamil, Telugu, Marathi, Bengali, Gujarati, Kannada, Malayalam, Punjabi, English)
- Intent detection — classifies emergency, harassment, mental health, legal help, and more
- Emotion analysis — detects fear, panic, distress, anger with intensity scoring
- Risk scoring — 1–10 scale; score ≥ 7 triggers audit log, ≥ 9 triggers auto SOS
- Abuse detection — flags harassment and domestic violence language
- Conversation context — maintains session history for multi-turn conversations
- Voice input — Web Speech API with SOS keyword detection in all supported languages
- Know Your Rights — covers sexual harassment (POSH), domestic violence (PWDVA), rape & assault, stalking, eve-teasing, child marriage
- AI Legal Q&A — ask any question, get answers with IPC sections and next steps in your selected language
- FIR Draft Generator — fills a complete FIR complaint template from form inputs
- Relevant helplines — NCW (1800-111-900), Women Helpline (181), Police (100), Cyber Crime portal
- GPS-based search — finds hospitals, police stations, fire stations, shelters, and safe zones
- Adjustable radius — 1km, 2km, 5km, 10km, 20km
- AI enrichment — when database results are thin (< 3), Groq AI generates realistic local resources
- Google Maps integration — directions and map links for every result
- Phone call buttons — tap to call any resource instantly
- Fully localised UI — labels, buttons, and status messages in selected language
- Categorised: Police, Medical, Fire, Women, Child, Mental Health, Legal
- 24×7 badge, working hours, state-specific filtering
- Translated category names in all 10 languages
- SOS incident statistics (total, resolved, false alarms, panic mode)
- Monthly trend chart (SVG line graph)
- Emergency type breakdown, trigger type breakdown
- AI chat intent and emotion distribution
- Languages used across AI conversations
- Avatar upload to Supabase Storage
- Encrypted phone number (AES-256-GCM)
- Blood group, gender, date of birth, medical conditions
- Language preference (persisted to DB and localStorage)
- Privacy & consent management (DPDP 2023 compliant)
- Emergency contact priority reordering (drag-and-drop + ▲▼ buttons)
SafeGuard/
├── frontend/ # React 18 SPA
│ └── src/
│ ├── components/
│ │ ├── AI/ # AIChat with Groq analysis display
│ │ ├── Analytics/ # Usage reports & trend charts
│ │ ├── Auth/ # Register (2-step), Login, PrivateRoute
│ │ ├── Legal/ # LegalAssistant (Rights / Q&A / FIR)
│ │ ├── Privacy/ # ConsentManager
│ │ ├── Profile/ # ProfileDashboard, EmergencyContacts, LanguageSelector
│ │ └── SOS/ # SOSButton, SOSLiveMap, Helplines, HelpHistory, NearbyResources
│ ├── context/ # LanguageContext (i18n)
│ ├── hooks/ # useVoiceInput (Web Speech API)
│ ├── services/ # API clients (Supabase, Node backend, SOS, AI)
│ └── utils/ # translations.js (10 languages), languages.js
│
└── backend/
└── node/ # Express.js API server
└── src/
├── ai/ # groqService.js — analyzeMessage + generateResponse
├── config/ # supabase.js
├── middleware/ # auth.js, encryption.js (AES-256-GCM)
└── routes/
├── ai.js # /api/ai — chat, analyze, history, context
├── auth.js # /api/auth — register, login, logout, me, refresh
├── emergency.js # /api/emergency-contacts — CRUD
├── legal.js # /api/legal — topics, rights, FIR draft, AI Q&A, analytics
├── profile.js # /api/profile — get/update profile, preferences, languages
└── sos.js # /api/sos — trigger, location, resolve, history, helplines, nearby
| Layer | Technology |
|---|---|
| Frontend | React 18, React Router v6 |
| Styling | Pure CSS (no framework), Google Fonts (Syne + DM Sans) |
| Backend | Node.js 18+, Express 4 |
| Database | Supabase (PostgreSQL + Auth + Storage) |
| AI | Groq API — llama-3.3-70b-versatile |
| Encryption | AES-256-GCM (Node.js crypto) |
| Voice Input | Web Speech API (browser-native) |
| Maps | Google Maps iframe embed (no API key required) |
| Auth | Supabase Auth (JWT) |
| Rate Limiting | express-rate-limit |
| Security | helmet, cors |
- Node.js ≥ 18
- npm ≥ 9
- A Supabase project
- A Groq API key (free tier available at console.groq.com)
git clone https://github.com/your-org/safeguard.git
cd safeguardcd backend/node
npm installCreate .env in backend/node/:
# Server
PORT=5000
NODE_ENV=development
# Supabase
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
# Encryption — generate with: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
ENCRYPTION_KEY=your-64-hex-character-key
# Groq AI
GROQ_API_KEY=gsk_your_groq_api_key
# Frontend URL (for CORS in production)
FRONTEND_URL=http://localhost:3000Start the backend:
npm run dev # development (nodemon)
npm start # productionThe server runs at http://localhost:5000. Visit /health to confirm.
cd frontend
npm installCreate .env in frontend/:
REACT_APP_SUPABASE_URL=https://your-project.supabase.co
REACT_APP_SUPABASE_ANON_KEY=your-anon-key
REACT_APP_NODE_API_URL=http://localhost:5000Start the frontend:
npm startThe app runs at http://localhost:3000.
Run the following in your Supabase SQL editor to create required tables:
-- Core tables required
-- users, user_profiles, user_preferences, emergency_contacts,
-- sos_incidents, sos_locations, chat_messages, helplines,
-- safety_resources, help_history, notifications, audit_logs,
-- privacy_consents, supported_languages
-- Minimum: ensure emergency_contacts and users have auth tag columns
ALTER TABLE emergency_contacts ADD COLUMN IF NOT EXISTS contact_name_auth_tag TEXT;
ALTER TABLE emergency_contacts ADD COLUMN IF NOT EXISTS phone_number_auth_tag TEXT;
ALTER TABLE users ADD COLUMN IF NOT EXISTS phone_number_auth_tag TEXT;Seed helplines data into the helplines table with columns: name, phone_number, category, description, available_24x7, working_hours, state, priority_order, is_active.
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register |
Register new user |
| POST | /api/auth/login |
Login |
| POST | /api/auth/logout |
Logout |
| GET | /api/auth/me |
Get current user |
| POST | /api/auth/refresh |
Refresh JWT token |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/sos/trigger |
Trigger SOS incident |
| POST | /api/sos/:id/location |
Update live location |
| PATCH | /api/sos/:id/resolve |
Resolve / cancel SOS |
| GET | /api/sos/active |
Get active incident |
| GET | /api/sos/history |
Paginated incident history |
| GET | /api/sos/helplines |
Get helplines (filterable) |
| GET | /api/sos/nearby |
Nearby safety resources (GPS) |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/ai/chat |
Full multilingual AI conversation |
| POST | /api/ai/analyze |
Analyze text only (no response) |
| GET | /api/ai/history |
Fetch chat history |
| DELETE | /api/ai/context |
Clear conversation context |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/legal/topics |
List all legal topics |
| GET | /api/legal/know-your-rights/:topic |
Get rights info for topic |
| POST | /api/legal/fir-draft |
Generate FIR draft |
| POST | /api/legal/ai-legal-help |
AI legal Q&A |
| GET | /api/legal/analytics |
Usage analytics |
| Method | Endpoint | Description |
|---|---|---|
| GET/PUT | /api/profile |
Get / update profile |
| GET/PUT | /api/profile/preferences |
Language, notifications, consents |
| GET | /api/profile/languages |
Supported languages list |
| GET/POST | /api/emergency-contacts |
List / add contacts |
| PUT/DELETE | /api/emergency-contacts/:id |
Update / remove contact |
- AES-256-GCM encryption on all phone numbers and contact names at rest
- JWT authentication via Supabase Auth on every protected route
- Rate limiting — 100 req/15min globally, 10 req/15min on auth routes
- Helmet.js HTTP security headers
- CORS restricted to configured frontend URL in production
- Audit logging — every sensitive action logged to
audit_logstable - DPDP 2023 compliant — consent management with per-user granular controls
| Code | Language | Native Name |
|---|---|---|
en |
English | English |
hi |
Hindi | हिंदी |
ta |
Tamil | தமிழ் |
te |
Telugu | తెలుగు |
mr |
Marathi | मराठी |
bn |
Bengali | বাংলা |
gu |
Gujarati | ગુજરાતી |
kn |
Kannada | ಕನ್ನಡ |
ml |
Malayalam | മലയാളം |
pa |
Punjabi | ਪੰਜਾਬੀ |
Language selection persists to user_preferences in the database and is restored on login.
The voice engine listens for emergency keywords in all 10 languages and automatically sends the message when detected:
English: help, sos, emergency, danger, save me, call police
Hindi: bachao, madad, khatra, police bulao, mujhe bachao
Tamil: udhavi, aapaththu, kaapaadunga
Telugu: sahaayam, praanam, kapaadu
Marathi: mala vachva, madad kara
| Module # | Feature | Files |
|---|---|---|
| 3 | Emergency Contact Management + Priority Reordering | EmergencyContacts.jsx, emergency.js |
| 4 | SOS Button (Hold-to-trigger) | SOSButton.jsx, sos.js |
| 5 | Real-time Location + Live Map | SOSLiveMap.jsx, sosService.js |
| 6 | Voice Input | useVoiceInput.js |
| 7 | Text Chat | AIChat.jsx |
| 8 | Emotion Detection | groqService.js |
| 9 | Help History | HelpHistory.jsx |
| 11 | Intent Detection | sos.js (classifyEmergency) |
| 12 | Panic Mode | SOSButton.jsx, sos.js |
| 13 | Helplines Directory | Helplines.jsx, sos.js |
| 14 | Auto Alert Message | sos.js (buildAutoMessage) |
| 15 | Nearby Safety Resources | NearbyResources.jsx, sos.js |
| 16 | AI Intent Classification | groqService.js |
| 17 | Conversation Context | groqService.js (ConversationContext) |
| 18 | Abuse Detection | groqService.js |
| 19 | Risk Scoring | groqService.js |
| 20 | Multilingual NLP | groqService.js (generateResponse) |
| 23 | Legal Content Management | LegalAssistant.jsx, legal.js |
| 26 | Notification Pipeline | sos.js (notifyEmergencyContacts) |
| 28 | Privacy & Consent | ConsentManager.jsx, profile.js |
| 30 | Analytics & Reports | Analytics.jsx, legal.js |
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Commit changes:
git commit -m 'Add your feature' - Push:
git push origin feature/your-feature - Open a Pull Request
MIT License — see LICENSE for details.
SafeGuard is a supplementary safety tool. In any life-threatening emergency, always contact official emergency services first:
- 112 — National Emergency Number (India)
- 100 — Police
- 108 — Ambulance
- 1091 — Women in Distress
- 181 — Women Helpline