Real-time dog bite incident tracking and prevention platform for India
SafePaw is a comprehensive web application that helps citizens report dog bite incidents, enables government bodies to manage and respond to reports, and provides legal aid resources for victims. Built with React, Firebase, and Google Maps.
Dog bite incidents and rabies deaths remain a critical public health challenge in India. Despite prevention efforts, the numbers continue to rise, with vulnerable populationsβchildren, elderly, and differently-abled citizensβbeing the worst affected.
Tamil Nadu
- 5.25 lakh (525,000) dog bite cases reported
- 28 rabies deaths recorded
- Vulnerable groups: Children, elderly, and differently-abled citizens most affected
Kerala
- 23 rabies deaths in first 7 months of 2025
- Continuing trend of high incident rates
Karnataka
- Over 2.3 lakh (230,000) dog bite cases (January-June 2025)
- At least 19 confirmed rabies deaths
- Significant increase from previous years
Maharashtra
- Over 56,000 dog bite cases in January 2025 alone
- 30 rabies deaths reported (2021-2023 period)
- High-density urban areas most affected
- Delayed Response: Many incidents go unreported or receive delayed government action
- Resource Allocation: Inefficient distribution of rescue teams and veterinary services
- Lack of Coordination: No centralized system for tracking and managing incidents
- Prevention Gaps: Insufficient data for identifying high-risk areas and implementing ABC programs
- Victim Support: Limited awareness of legal rights and compensation procedures
SafePaw addresses these challenges through:
- Real-time Incident Reporting with GPS tracking and photo evidence
- AI-Powered Prioritization using multi-agent system for urgent case identification
- Automated Escalation for incidents delayed >24 hours
- Resource Optimization through intelligent allocation of government resources
- Data-Driven Insights for prevention and ABC program planning
- Legal Aid Support with compensation calculator and rights information
- π Report Incidents - Quick incident reporting with GPS auto-detection, photo upload, and severity selection
- πΊοΈ Risk Heatmap - Interactive Google Maps showing color-coded incident locations
- π¨ Emergency Help - First aid guidance and nearest hospitals with rabies vaccine availability
- βοΈ Legal Aid - Compensation calculator based on Indian laws, rights information, and required documents
- π My Reports - Track all submitted reports with real-time status updates
- π Dashboard - Key metrics including total incidents, pending actions, resolution rates
- π Incident Management - Review and update incident reports with filtering by status/severity
- π€ AI-Powered Prioritization - Automatic incident priority scoring (1-10 scale) using multi-agent AI
- π Smart Action Recommendations - AI-suggested actions based on severity and context
- π Resource Allocation - Automated assignment of rescue teams, vets, and animal control
- β° Automatic Escalation - Auto-contact system for incidents delayed >24 hours via SMS/Email
- βοΈ ABC Program Tracking - Monitor Animal Birth Control sterilization statistics and drives
- π Analytics & Reports - Data insights, trends, and export functionality
- β Role-based authentication (Citizen & Government)
- β Anonymous incident reporting
- β Real-time data synchronization
- β Secure photo uploads to Firebase Storage
- β Geolocation-based incident mapping
- β Responsive design (mobile & desktop)
- β Smooth animations and modern UI
- π€ Multi-Agent AI System - 4 specialized agents working together
- π― Smart Prioritization - Automatic incident scoring (1-10 scale)
- π Action Recommendations - AI-suggested government actions
- π Resource Allocation - Intelligent assignment of rescue teams, vets, animal control
- β° Auto-Escalation - Detects incidents delayed >24 hours
- π§ Automated Notifications - SMS/Email to government agents
- π AI Dashboard - Real-time agent actions and history
- β Approve/Override - Government can approve or override AI recommendations
SafePaw uses Google Genkit with Gemini AI to power an intelligent multi-agent system:
-
Priority Analyzer Agent
- Calculates incident urgency (1-10 scale)
- Considers: severity, location risk, time urgency, resource availability
- Output: Priority score + urgency level (low/medium/high/critical)
-
Action Coordinator Agent
- Recommends specific government actions
- Based on: incident severity and priority
- Output: List of actions with priority levels and estimated times
-
Resource Manager Agent
- Allocates available resources
- Resources: rescue teams, veterinarians, animal control
- Output: Assigned resources with distance calculations
-
Escalation Monitor Agent
- Monitors incidents for delays >24 hours
- Triggers automatic escalation
- Output: List of delayed incidents requiring attention
New Incident β Priority Analyzer β Action Coordinator β Resource Manager β Update Firestore
β
Government Dashboard
β
Approve/Override AI Actions
Automatic Escalation Flow:
Hourly Check β Escalation Monitor β Detect Delays >24h β Update Status β Contact Agents (SMS/Email)
- Framework: React 18 + TypeScript
- Build Tool: Vite
- Styling: Tailwind CSS
- Animations: Framer Motion
- Icons: Lucide React
- Maps: Google Maps JavaScript API
- Fonts: Fraunces, Inter
- State Management: React Hooks
- Real-time Updates: Firestore onSnapshot listeners
- Runtime: Node.js (Firebase Functions v2)
- Language: TypeScript
- Authentication: Firebase Auth (Email/Password & Phone OTP)
- Database: Cloud Firestore (NoSQL)
- Storage: Firebase Storage (Cloud Storage)
- Analytics: Firebase Analytics
- Functions: Firebase Cloud Functions v2
- Scheduled Tasks: Cloud Scheduler (hourly checks)
- AI Framework: Google Genkit (v1.27.0)
- AI Model: Google Gemini AI (via Google AI Studio)
- Multi-Agent System: 4 specialized AI agents
- Priority Analyzer Agent
- Action Coordinator Agent
- Resource Manager Agent
- Escalation Monitor Agent
- Schema Validation: Zod (for AI tool inputs/outputs)
- AI Features:
- Automatic incident priority scoring (1-10 scale)
- Smart action recommendations
- Resource allocation optimization
- Automatic escalation detection (>24 hours)
- SMS: Twilio API
- Email: Nodemailer (SMTP)
- Real-time: Firestore real-time listeners
- Firebase Platform:
- Firebase Authentication
- Cloud Firestore
- Cloud Storage for Firebase
- Firebase Cloud Functions
- Firebase Analytics
- Google AI:
- Gemini AI (via Google AI Studio)
- Genkit AI Framework
- Google Maps Platform:
- Maps JavaScript API
- Geocoding API (optional)
- Places API (optional)
SafePaw/
βββ firebase.json # Firebase configuration
βββ firestore.rules # Database security rules
βββ storage.rules # Storage security rules
βββ firestore.indexes.json # Query optimization indexes
βββ Guides/
β βββ Project_Requirements.md # Complete project requirements
β βββ System_Architecture.html # System architecture diagram
β βββ User_flow.html # User flow diagrams
βββ functions/ # π€ AI Multi-Agent System
β βββ src/
β β βββ agents/ # AI Agent modules
β β β βββ priorityAnalyzer.ts
β β β βββ actionCoordinator.ts
β β β βββ resourceManager.ts
β β β βββ escalationMonitor.ts
β β βββ services/ # Business logic
β β β βββ orchestrator.ts
β β β βββ contactService.ts
β β β βββ notificationService.ts
β β βββ types/ # TypeScript types
β β βββ utils/ # Helper functions
β β βββ index.ts # Cloud Functions
β βββ package.json
β βββ .env.example # API keys template
β βββ README.md # Functions documentation
β βββ ARCHITECTURE.md # Architecture guide
βββ frontend/
βββ config/
β βββ firebase.ts # Firebase credentials
βββ lib/
β βββ firebase.ts # Firebase initialization
βββ services/
β βββ authService.ts # Authentication logic
β βββ incidentService.ts # Database operations
βββ components/
β βββ AuthPage.tsx # Login & Signup pages
β βββ Dashboard.tsx # Citizen Dashboard (6 pages)
β βββ GovDashboard.tsx # Government Dashboard (4 pages)
β βββ MapComponent.tsx # Google Maps integration
β βββ Navbar.tsx # Navigation bar
β βββ Hero.tsx # Landing page hero
β βββ Footer.tsx # Footer
βββ App.tsx # Main application
βββ index.html # HTML entry point
βββ package.json # Dependencies
βββ vite.config.ts # Vite configuration
- Node.js 16+ and npm
- Firebase account
- Google Maps API key (optional, for maps)
-
Clone the repository
git clone <repository-url> cd SafePaw
-
Install dependencies
cd frontend npm install -
Set up Firebase
Follow the detailed guide in
firebase_setup_guide.md:- Create Firebase project
- Enable Authentication (Email/Password & Phone)
- Create Firestore database
- Enable Firebase Storage
- Copy your Firebase configuration
-
Add Firebase credentials
Update
frontend/config/firebase.ts:export const firebaseConfig = { apiKey: "YOUR_API_KEY", authDomain: "YOUR_PROJECT.firebaseapp.com", projectId: "YOUR_PROJECT_ID", storageBucket: "YOUR_PROJECT.appspot.com", messagingSenderId: "YOUR_SENDER_ID", appId: "YOUR_APP_ID", measurementId: "YOUR_MEASUREMENT_ID" };
-
Deploy Firebase security rules
cd .. firebase login firebase init firebase deploy --only firestore:rules,storage:rules -
Add Google Maps API key (optional)
Update
frontend/components/MapComponent.tsxline 85:script.src = `https://maps.googleapis.com/maps/api/js?key=YOUR_GOOGLE_MAPS_KEY&libraries=places`;
-
Run the development server
cd frontend npm run dev -
Open your browser
Navigate to
http://localhost:5173
- Full Name
- Phone Number (10 digits)
- Password (minimum 6 characters)
- Full Name
- Official Email
- Government ID Card Number
- Ward Number
- State
- City
- Gender
- Password (minimum 6 characters)
- Email + Password (works for both roles)
All data is securely stored in Firebase Firestore with role-based access control.
{
uid: string,
email: string,
phone?: string,
role: 'citizen' | 'government' | 'ngo',
name: string,
createdAt: timestamp,
// Government-specific fields
govtId?: string,
wardNo?: string,
state?: string,
city?: string,
gender?: 'male' | 'female' | 'other',
organization?: string
}{
id: string,
userId: string,
userName: string,
location: {
address: string,
coordinates: geopoint
},
dogType: 'Stray' | 'Pet' | 'Unknown',
severity: 'Minor' | 'Moderate' | 'Severe',
description: string,
photos: string[],
status: 'Reported' | 'Under Review' | 'Action Taken' | 'Resolved',
createdAt: timestamp,
updatedAt: timestamp,
reviewedBy?: string,
actionTaken?: string,
anonymous: boolean
}- Role-based access control
- Users can only edit their own reports
- Government officials can update any incident
- Anonymous reporting supported
- Authenticated-only access
- 5MB file size limit
- Image files only (.jpg, .png, .gif)
- User-specific upload paths
- Public read access for incident photos
After setting up Firebase, create test accounts:
Citizen Account:
- Email:
citizen@test.com - Password:
test123
Government Account:
- Email:
govt@test.com - Password:
test123
- β Sign up with email/password
- β Submit incident report with photo
- β View incidents on map
- β Calculate compensation (Legal Aid)
- β Government: Update incident status
- β Government: View analytics
- Setup Guide:
firebase_setup_guide.md - Project Requirements:
Guides/Project_Requirements.md - System Architecture:
Guides/System_Architecture.html - User Flows:
Guides/User_flow.html
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License.
- Firebase - Backend infrastructure
- Google Maps - Mapping services
- Lucide - Icon library
- Framer Motion - Animation library
- Tailwind CSS - Styling framework
For issues and questions:
- Create an issue on GitHub
- Email: support@safepaw.in (example)
First-of-its-kind compensation calculator for dog bite victims in India, based on:
- IPC Section 289 (Negligent conduct with animal)
- IPC Section 337/338 (Causing hurt)
- Municipal Corporation liability
- National Rabies Control Programme
Color-coded incident visualization:
- π΄ Red - Severe incidents
- π Orange - Moderate incidents
- π’ Green - Minor incidents
Protect victim identity while still enabling government response.
# Development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview
# Lint code
npm run lintCreate .env.local in frontend/ directory:
VITE_FIREBASE_API_KEY=your_api_key
VITE_FIREBASE_AUTH_DOMAIN=your_auth_domain
VITE_FIREBASE_PROJECT_ID=your_project_id
VITE_FIREBASE_STORAGE_BUCKET=your_storage_bucket
VITE_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
VITE_FIREBASE_APP_ID=your_app_id
VITE_FIREBASE_MEASUREMENT_ID=your_measurement_id
VITE_GOOGLE_MAPS_API_KEY=your_maps_key- Google Maps requires API key to display (placeholder shown otherwise)
- Phone OTP requires reCAPTCHA setup
- Analytics only works in production
If you find SafePaw useful, please consider giving it a star β
Built with β€οΈ for safer communities in India
SafePaw - Making India safer, one report at a time. πΎ