A comprehensive emergency response system with real-time location tracking, SOS functionality, and intelligent route planning using H3 spatial indexing.
- Overview
- Features
- Architecture
- Quick Start
- Installation
- Configuration
- Usage
- API Documentation
- Development
- Contributing
- License
SHEILD is a comprehensive emergency response web application that combines real-time location tracking, SOS functionality, and intelligent route planning. The system uses H3 spatial indexing for efficient safety analysis and provides users with the safest routes based on incident data.
- Emergency Response: Instant SOS alerts with location sharing
- Safety Route Planning: AI-powered route optimization using incident data
- Real-time Tracking: Live location monitoring and sharing
- Contact Management: Emergency contact organization and communication
- Healthcare Integration: Medical information storage and emergency access
- SOS System: One-tap emergency alerts with custom messages
- Location Sharing: Real-time GPS coordinates with emergency contacts
- Emergency Contacts: Manage and communicate with trusted contacts
- Healthcare Info: Store critical medical information for emergency responders
- Smart Route Planning: Safety-optimized routes using H3 spatial indexing
- Incident Analysis: Real-time safety scoring based on historical data
- Time-based Safety: Day/night safety considerations
- Multiple Route Options: Alternative routes with safety rankings
- Profile Management: Personal information and photo management
- Authentication: Secure Firebase-based user authentication
- Settings: Customizable app preferences and notifications
- Theme Support: Dark/light mode toggle
- Responsive Design: Works seamlessly across all devices
- Progressive Web App: Installable web application
- Offline Support: Core functionality available without internet
- Push Notifications: Real-time alerts and updates
- Framework: Next.js 15 with App Router
- UI Library: React 18 with TypeScript
- Styling: Tailwind CSS with shadcn/ui components
- Maps: Google Maps API with @vis.gl/react-google-maps
- Forms: React Hook Form with Zod validation
- Authentication: Firebase Auth
- Database: Firestore (NoSQL)
- Storage: Firebase Storage
- Functions: Firebase Cloud Functions
- SMS: AWS SNS for emergency notifications
- Spatial Indexing: H3 hexagonal grid system
- Route Analysis: OpenRouteService API integration
- Safety Scoring: Incident-based risk assessment
- Data Processing: Python-based analytics pipeline
SHEILD/
βββ src/ # Next.js application
β βββ app/ # App router pages
β βββ components/ # React components
β βββ hooks/ # Custom React hooks
β βββ lib/ # Utility libraries
βββ api/ # Python API services
βββ database/ # Data processing & H3 analysis
βββ map/ # Route processing logic
βββ functions/ # Firebase Cloud Functions
βββ android/ # Android app (Capacitor)
βββ Documentation/ # Setup guides & documentation
- Node.js 18+ and npm
- Python 3.8+ (for data processing)
- Firebase project
- Google Cloud project with Maps API
- AWS account (for SMS functionality)
git clone https://github.com/your-username/SHEILD.git
cd SHEILD# Frontend dependencies
npm install
# Python dependencies (for data processing)
pip install -r requirements.txtCreate a .env.local file in the project root:
# Firebase Configuration
NEXT_PUBLIC_FIREBASE_API_KEY=your_firebase_api_key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_project.appspot.com
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
NEXT_PUBLIC_FIREBASE_APP_ID=your_app_id
NEXT_PUBLIC_MEASUREMENT_ID=your_measurement_id
# Google Maps Configuration
NEXT_PUBLIC_GOOGLE_MAPS_API_KEY=your_google_maps_api_key
NEXT_PUBLIC_GOOGLE_MAPS_MAP_ID=your_map_id
# AWS SNS Configuration
AWS_ACCESS_KEY_ID=your_aws_access_key
AWS_SECRET_ACCESS_KEY=your_aws_secret_key
AWS_REGION=eu-north-1
AWS_SNS_SENDER_ID=SHEILD
AWS_SNS_MONTHLY_LIMIT=1.00
AWS_SNS_DEFAULT_SENDER_ID=SHEILD
AWS_SNS_SMS_TYPE=Transactional
# Database Configuration
DATABASE_URL=your_postgresql_connection_string
OPENROUTESERVICE_API_KEY=your_ors_api_keynpm run devOpen http://localhost:9002 to view the application.
- Create a new Firebase project at Firebase Console
- Enable Authentication (Email/Password)
- Create Firestore Database
- Configure Storage for profile pictures
- Deploy security rules from
firestore.rulesandstorage.rules
- Create a Google Cloud project
- Enable required APIs:
- Maps JavaScript API
- Directions API
- Geocoding API
- Places API
- Create API key with appropriate restrictions
- Set up billing (required for Maps API)
- Create AWS account
- Set up IAM user with SNS permissions
- Configure SMS settings in SNS console
- Set up spending limits and verification
The application includes comprehensive security rules:
- Users can only access their own data
- All Firestore collections are protected by authentication
- Profile pictures are restricted to user's own uploads
- Emergency contacts require mutual consent
// User Profile
interface UserProfile {
uid: string;
email: string;
displayName: string;
photoURL?: string;
phoneNumber?: string;
emergencyContacts: EmergencyContact[];
healthcareInfo: HealthcareInfo;
settings: UserSettings;
}
// Emergency Contact
interface EmergencyContact {
id: string;
name: string;
phoneNumber: string;
relationship: string;
isVerified: boolean;
}
// Healthcare Information
interface HealthcareInfo {
bloodType?: string;
allergies?: string[];
medications?: string[];
conditions?: string[];
emergencyNotes?: string;
}- Tap the SOS button on the dashboard
- Add optional emergency message
- System automatically:
- Sends SMS to emergency contacts
- Shares current location
- Logs emergency event
- Enter start and destination locations
- System calculates multiple route options
- Routes are ranked by safety score
- Select preferred route for navigation
- Add emergency contacts with phone numbers
- Contacts receive verification SMS
- Manage contact relationships and permissions
- Test emergency communication
POST /api/safe-routes
Content-Type: application/json
{
"start_lat": 28.6139,
"start_lon": 77.2090,
"end_lat": 28.5355,
"end_lon": 77.3910,
"time_period": "day"
}GET /api/healthGET /api/configfrom map.route_processer import get_route_with_safety
result = get_route_with_safety(
start_lat=28.6139,
start_lon=77.2090,
end_lat=28.5355,
end_lon=77.3910,
time_period='day'
)# Calculate H3 safety scores
python database/h3_processing.py
# Start API server
python api/routes_api.py# Development
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint
npm run type-check # Run TypeScript checks
# Testing
npm run test # Run tests
npm run test:watch # Run tests in watch mode
# Mobile Development
npm run cap:add # Add Capacitor platforms
npm run cap:sync # Sync web code to native
npm run cap:open # Open in native IDE- Components: Reusable UI components in
src/components/ - Hooks: Custom React hooks in
src/hooks/ - Utilities: Helper functions in
src/lib/ - Pages: Route pages in
src/app/ - API: Backend services in
api/andfunctions/
# Run all tests
npm run test
# Test specific functionality
node tests/test-sos-functionality.js
node tests/test-location-sharing.js
node tests/test-aws-sns.jsWe welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow TypeScript best practices
- Use ESLint and Prettier for code formatting
- Write comprehensive tests for new features
- Update documentation for API changes
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: SETUP.md
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Firebase for backend services
- Google Maps for mapping
- H3 for spatial indexing
- shadcn/ui for UI components
- Next.js for the React framework