Skip to content

🚨 SafeStep – Emergency Services & Safety Management Platform is a full-stack emergency response application designed to empower users with real-time safety tools, multilingual support, and a powerful admin dashboard. Built with the MERN stack and featuring geolocation, emergency alerts, service discovery, and internationalization.

Notifications You must be signed in to change notification settings

fowzan2744/SafeStep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🚨 SafeStep - Emergency Services Application

A comprehensive emergency services application with real-time location tracking, emergency contacts management, dynamic emergency service discovery, and a powerful admin dashboard system.

🌟 Features

πŸ” Authentication & Security

  • OTP-based Registration - Secure email verification during signup
  • JWT Authentication - Token-based secure authentication
  • Password Reset - OTP-based password recovery system
  • Protected Routes - Secure access to user-specific features
  • Admin Authentication - Separate admin login with OTP verification

πŸ›οΈ Admin Dashboard System

  • Admin Registration - OTP-based admin signup with email verification
  • Comprehensive Dashboard - Overview, users, alerts, analytics, and system health
  • User Management - View, activate/deactivate users with reasons
  • Alert Management - Monitor and update emergency alert statuses
  • Analytics & Charts - Visual data representation with Chart.js
  • System Health Monitoring - Real-time system status and performance metrics
  • Data Export - CSV export functionality for reports

🌍 Internationalization (i18n)

  • Multi-language Support - English, Arabic, and Hindi
  • Dynamic Language Switching - Collapsible language tray with flags
  • Translated UI Elements - All major pages and components translated
  • RTL Support - Right-to-left layout for Arabic
  • Seamless Language Toggle - Instant language switching without page reload

πŸ“ Location Services

  • Real-time GPS Tracking - Automatic user location detection
  • Emergency Services Map - Interactive map with nearby emergency services
  • POI Integration - Dynamic discovery of emergency services via OpenStreetMap
  • Distance Calculation - Real-time distance to emergency services

πŸ‘₯ Emergency Contacts Management

  • Add/Remove Contacts - Manage emergency contact list
  • Contact Validation - Email-based contact verification
  • Dashboard Statistics - Track contact count and alert history
  • Inline Contact Form - Seamless contact addition with validation

🚨 Emergency Alert System

  • One-Click Alert - Send emergency alerts to all contacts
  • Location Sharing - Automatically include user's current location
  • Email Notifications - Instant email alerts to emergency contacts
  • Alert History - Track all sent emergency alerts
  • Alert Status Management - Active, resolved, and false alarm statuses

πŸ₯ Emergency Services Discovery

  • Seeded Data - 16 verified emergency services in Qatar
  • POI Search - Dynamic discovery via OverstreetMap API
  • Service Categories - Police, Fire, Hospital, Poison Control
  • Interactive Map - Click to call emergency services
  • Color-coded Cards - Detailed service information with quick actions

πŸ› οΈ Technology Stack

Backend

  • Node.js - Runtime environment
  • Express.js - Web framework
  • MongoDB - Database
  • Mongoose - ODM for MongoDB
  • JWT - Authentication
  • bcryptjs - Password hashing
  • Nodemailer - Email services
  • CORS - Cross-origin resource sharing

Frontend

  • React - UI framework
  • React Router - Client-side routing
  • React Leaflet - Interactive maps
  • Axios - HTTP client
  • Tailwind CSS - Styling
  • React Hot Toast - Notifications
  • React i18next - Internationalization
  • Chart.js - Data visualization
  • React Chart.js - Chart.js React wrapper

APIs & Services

  • OpenStreetMap - Base map tiles
  • Overpass API - POI data for emergency services
  • Geolocation API - User location detection

πŸ“ Project Structure

SafeStep/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ adminController.js           # Admin dashboard logic
β”‚   β”‚   β”œβ”€β”€ authController.js            # Authentication logic
β”‚   β”‚   β”œβ”€β”€ emergencyAlertController.js  # Alert management
β”‚   β”‚   β”œβ”€β”€ emergencyContactController.js # Contact management
β”‚   β”‚   β”œβ”€β”€ emergencyServiceController.js # Services API
β”‚   β”‚   └── userController.js            # User management
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”œβ”€β”€ adminAuth.js                 # Admin authentication
β”‚   β”‚   └── auth.js                      # JWT authentication
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ Admin.js                     # Admin schema
β”‚   β”‚   β”œβ”€β”€ EmergencyAlert.js            # Alert schema
β”‚   β”‚   β”œβ”€β”€ EmergencyContact.js          # Contact schema
β”‚   β”‚   β”œβ”€β”€ EmergencyService.js          # Service schema
β”‚   β”‚   β”œβ”€β”€ Otp.js                       # OTP schema
β”‚   β”‚   └── User.js                      # User schema
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ admin.js                     # Admin endpoints
β”‚   β”‚   β”œβ”€β”€ auth.js                      # Auth endpoints
β”‚   β”‚   β”œβ”€β”€ emergencyAlerts.js           # Alert endpoints
β”‚   β”‚   β”œβ”€β”€ emergencyContacts.js         # Contact endpoints
β”‚   β”‚   β”œβ”€β”€ emergencyServices.js         # Service endpoints
β”‚   β”‚   └── user.js                      # User endpoints
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ emergencyMailer.js           # Emergency email service
β”‚   β”‚   β”œβ”€β”€ generateOtp.js               # OTP generation
β”‚   β”‚   β”œβ”€β”€ mailer.js                    # Email service
β”‚   β”‚   └── userConfirmationMailer.js    # User confirmation emails
β”‚   β”œβ”€β”€ seedEmergencyServices.js         # Database seeding
β”‚   β”œβ”€β”€ server.js                        # Main server file
β”‚   └── package.json
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ public/
β”‚   β”‚   β”œβ”€β”€ locales/                     # Translation files
β”‚   β”‚   β”‚   β”œβ”€β”€ en/                      # English translations
β”‚   β”‚   β”‚   β”œβ”€β”€ ar/                      # Arabic translations
β”‚   β”‚   β”‚   └── hi/                      # Hindi translations
β”‚   β”‚   └── ...
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ EmergencyServicesMap.jsx # Interactive map
β”‚   β”‚   β”‚   └── ProtectedRoute.jsx       # Route protection
β”‚   β”‚   β”œβ”€β”€ context/
β”‚   β”‚   β”‚   └── AuthContext.jsx          # Authentication context
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ AdminDashboard.jsx       # Admin dashboard
β”‚   β”‚   β”‚   β”œβ”€β”€ AdminLogin.jsx           # Admin login
β”‚   β”‚   β”‚   β”œβ”€β”€ AdminSignup.jsx          # Admin signup
β”‚   β”‚   β”‚   β”œβ”€β”€ ChangePassword.jsx       # Password reset
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.jsx            # Main dashboard
β”‚   β”‚   β”‚   β”œβ”€β”€ Landing.jsx              # Landing page
β”‚   β”‚   β”‚   β”œβ”€β”€ Login.jsx                # Login page
β”‚   β”‚   β”‚   └── Register.jsx             # Registration page
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   └── api.js                   # API configuration
β”‚   β”‚   β”œβ”€β”€ i18n/
β”‚   β”‚   β”‚   └── i18n.js                  # i18n configuration
β”‚   β”‚   β”œβ”€β”€ App.jsx                      # Main app component
β”‚   β”‚   └── main.jsx                     # App entry point
β”‚   └── package.json
└── README.md

πŸš€ Quick Start

Prerequisites

  • Node.js (v14 or higher)
  • MongoDB
  • Gmail account (for email services)

Backend Setup

  1. Clone and navigate to backend
cd backend
  1. Install dependencies
npm install
  1. Environment Configuration Create a .env file in the backend directory:
MONGODB_URI=mongodb://localhost:27017/safestep
JWT_SECRET=your_jwt_secret_here
EMAIL_USER=your_gmail@gmail.com
EMAIL_PASS=your_gmail_app_password
  1. Seed the database
npm run seed
  1. Start the server
npm start

Frontend Setup

  1. Navigate to frontend
cd frontend
  1. Install dependencies
npm install
  1. Start the development server
npm run dev

πŸ“± Application Flow

1. User Registration

Email Input β†’ OTP Verification β†’ Account Creation β†’ Dashboard Access

2. Admin Registration

Admin Signup β†’ OTP to paul2744walker@gmail.com β†’ Verification β†’ Admin Dashboard Access

3. Emergency Contact Management

Add Contact β†’ Email Validation β†’ Contact Saved β†’ Dashboard Update

4. Emergency Alert System

User Location β†’ Alert Button β†’ Email Notifications β†’ Alert History β†’ Admin Review

5. Emergency Services Discovery

User Location β†’ Map Display β†’ POI Search β†’ Service Information

6. Language Switching

Language Tray β†’ Flag Selection β†’ Instant UI Translation β†’ RTL Support (Arabic)

πŸ”§ API Endpoints

Authentication

  • POST /api/auth/register - Direct user registration
  • POST /api/auth/login - User login
  • POST /api/auth/send-otp - Send registration OTP
  • POST /api/auth/verify-otp - Verify registration OTP
  • POST /api/auth/send-reset-password-otp - Send password reset OTP
  • POST /api/auth/verify-reset-password-otp - Verify password reset OTP
  • POST /api/auth/reset-password - Reset password

Admin Authentication

  • POST /api/admin/send-otp - Send admin signup OTP
  • POST /api/admin/verify-otp - Verify admin signup OTP
  • POST /api/admin/login - Admin login
  • GET /api/admin/stats - Get dashboard statistics
  • GET /api/admin/users - Get all users with pagination
  • GET /api/admin/alerts - Get all alerts with pagination
  • PATCH /api/admin/users/:id/status - Update user status
  • PATCH /api/admin/alerts/:id/status - Update alert status
  • GET /api/admin/analytics - Get analytics data
  • GET /api/admin/system-health - Get system health metrics
  • GET /api/admin/export - Export data as CSV

User Management

  • GET /api/user/dashboard-stats - Get user statistics

Emergency Contacts

  • GET /api/emergency-contacts - Get user's contacts
  • POST /api/emergency-contacts - Add new contact
  • DELETE /api/emergency-contacts/:id - Remove contact

Emergency Alerts

  • POST /api/emergency-alerts - Send emergency alert

Emergency Services

  • GET /api/emergency-services/nearby - Get nearby services

πŸ—ΊοΈ Emergency Services Data

Seeded Services (Qatar)

  • 5 Police Stations - Doha Central, West Bay, Al Wakrah, Al Sadd, Al Khor
  • 4 Fire Stations - Doha Central, Hamad Airport, Al Wakrah, Al Khor
  • 6 Hospitals - Hamad General, Al Wakra, Al Khor, Sidra Medicine, Al Ahli, Al Emadi
  • 1 Poison Control Center - Qatar Poison Control Center

POI Integration

  • Dynamic Discovery - Real-time emergency service search
  • OpenStreetMap Data - Comprehensive global coverage
  • Automatic Updates - Always current information
  • Multiple Categories - Police, Fire, Hospital, Specialized Services

πŸ›οΈ Admin Dashboard Features

Dashboard Overview

  • Real-time Statistics - Total users, alerts, active alerts, resolved alerts
  • Quick Actions - Direct access to user and alert management
  • System Status - Live monitoring of application health
  • Recent Activity - Latest user registrations and alert activities

User Management

  • User List - Comprehensive user database with search and pagination
  • User Details - Complete user information including registration date
  • Status Control - Activate/deactivate users with reason tracking
  • Deactivation History - Track when and why users were deactivated
  • Bulk Operations - Manage multiple users efficiently

Alert Management

  • Alert Monitoring - Real-time emergency alert tracking
  • Status Updates - Mark alerts as resolved or false alarms
  • Alert Details - Complete alert information with user and location data
  • Filtering Options - Filter by status, date range, and user
  • Admin Notes - Add notes and comments to alerts

Analytics & Reporting

  • Chart.js Integration - Interactive charts and graphs
  • Alert Trends - Time-based alert analysis
  • User Analytics - Registration and activity patterns
  • Status Distribution - Visual breakdown of alert statuses
  • Hourly Analysis - Peak usage time identification
  • Period Selection - Customizable date ranges for analysis

System Health

  • Performance Metrics - Response times and system load
  • Database Status - Connection health and query performance
  • Memory Usage - System resource monitoring
  • Error Tracking - Application error monitoring
  • Uptime Monitoring - System availability tracking

Data Export

  • CSV Export - Download user and alert data
  • Filtered Exports - Export specific data subsets
  • Report Generation - Automated report creation
  • Data Backup - Regular data export capabilities

🌍 Internationalization (i18n) System

Supported Languages

  • English (en) - Primary language with complete translations
  • Arabic (ar) - Full RTL support with Arabic translations
  • Hindi (hi) - Complete Hindi language support

Translation Features

  • Dynamic Language Switching - Instant language changes
  • Collapsible Language Tray - Elegant language selector with flags
  • RTL Layout Support - Proper right-to-left layout for Arabic
  • Contextual Translations - Context-aware translation system
  • Fallback System - Graceful fallback to English for missing translations

UI Components Translated

  • Authentication Pages - Login, register, password reset
  • Dashboard Elements - All dashboard text and labels
  • Emergency Services - Service names and descriptions
  • Navigation - Menu items and navigation text
  • Notifications - Toast messages and alerts
  • Forms - Input labels, placeholders, and validation messages

Language Tray Design

  • Flag Icons - Visual language identification
  • Smooth Animations - Elegant expand/collapse transitions
  • Fixed Positioning - Always accessible language switcher
  • Responsive Design - Works on all screen sizes

πŸ”’ Security Features

  • JWT Token Authentication - Secure session management
  • Password Hashing - bcrypt encryption
  • OTP Verification - Email-based security
  • Protected Routes - Role-based access control
  • Input Validation - Server-side data validation
  • CORS Protection - Cross-origin security

πŸ“§ Email Services

Email Templates

  • Registration OTP - Account verification
  • Password Reset OTP - Password recovery
  • Emergency Alerts - Contact notifications
  • User Confirmations - Account status updates

Email Configuration

  • Gmail SMTP - Reliable email delivery
  • App Passwords - Secure authentication
  • HTML Templates - Professional formatting
  • Error Handling - Graceful failure management

🎨 UI/UX Features

Modern Design

  • Responsive Layout - Mobile-first design
  • Gradient Backgrounds - Modern visual appeal
  • Interactive Maps - Real-time location services
  • Toast Notifications - User feedback
  • Loading States - Smooth user experience

User Experience

  • Intuitive Navigation - Easy-to-use interface
  • Real-time Updates - Live data synchronization
  • Error Handling - User-friendly error messages
  • Accessibility - Inclusive design principles

πŸš€ Deployment

Backend Deployment

  1. Set up MongoDB Atlas or local MongoDB
  2. Configure environment variables
  3. Deploy to Heroku, Vercel, or AWS
  4. Set up email service credentials

Frontend Deployment

  1. Build the production version
  2. Deploy to Netlify, Vercel, or AWS S3
  3. Configure API endpoint URLs
  4. Set up custom domain (optional)

πŸ”§ Configuration

Environment Variables

# Database
MONGODB_URI=mongodb://localhost:27017/safestep

# Authentication
JWT_SECRET=your_secure_jwt_secret

# Email Service
EMAIL_USER=your_gmail@gmail.com
EMAIL_PASS=your_gmail_app_password

# Server
PORT=5000
NODE_ENV=development

API Configuration

The frontend uses a centralized API configuration in src/services/api.js:

  • Base URL configuration
  • Endpoint management
  • Authentication headers
  • Error handling

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • OpenStreetMap - Map data and POI information
  • React Leaflet - Interactive map components
  • Tailwind CSS - Utility-first CSS framework
  • MongoDB - Database solution
  • Node.js Community - Backend framework and tools

πŸ“ž Support

For support and questions:

  • Create an issue in the repository
  • Check the documentation

Built with ❀️ by @fowzan2744 for emergency safety and community protection

About

🚨 SafeStep – Emergency Services & Safety Management Platform is a full-stack emergency response application designed to empower users with real-time safety tools, multilingual support, and a powerful admin dashboard. Built with the MERN stack and featuring geolocation, emergency alerts, service discovery, and internationalization.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages