Skip to content

SHREESHANTH99/CivicAlert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

36 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CivicAlert 🚨

CivicAlert Logo

Real-Time Emergency Incident Reporting Platform

Empowering communities through instant incident reporting, intelligent routing, and coordinated emergency response systems.

Next.js NestJS TypeScript MongoDB License

Live Demo β€’ Report Bug β€’ Request Feature


πŸ“‹ Table of Contents


🎯 Overview

CivicAlert is a comprehensive emergency incident reporting and management platform designed to bridge the gap between citizens and emergency services. It enables real-time incident reporting, verification, tracking, and resolution through an intuitive web interface with advanced mapping capabilities.

Why CivicAlert?

  • Instant Reporting: Report emergencies in seconds with photo, location, and voice notes
  • Real-Time Updates: Live incident tracking on interactive maps
  • Admin Verification: Multi-level verification system ensures accuracy before dispatch
  • Community Engagement: Foster civic participation through transparent incident resolution
  • Smart Notifications: Intelligent alert system notifies relevant responders and nearby citizens

✨ Features

🚨 Core Features

1. Real-Time Incident Reporting System

The platform provides a comprehensive incident reporting interface that makes emergency reporting quick, accurate, and accessible to everyone.

  • Multi-Format Media Upload

    • πŸ“Έ Photo upload with drag-and-drop interface or click-to-browse
    • 🎀 Voice note recording for hands-free reporting (up to 60 seconds)
    • πŸ“Ή Video upload support for detailed incident documentation
    • πŸ–ΌοΈ Image preview before submission with edit/delete options
    • πŸ“¦ Multiple file upload support (up to 5 files per report)
    • ⚑ Automatic image compression and optimization
  • Advanced Location Services

    • πŸ—ΊοΈ Real-time GPS location tracking with high accuracy
    • πŸ” Address autocomplete powered by OpenStreetMap
    • πŸ“ Manual location picker with interactive map interface
    • 🏠 Address verification and formatting
    • 🌐 Reverse geocoding for automatic address detection
    • πŸ“± Mobile device location permission handling
  • Smart Categorization

    • πŸ”₯ Fire Emergency: Building fires, forest fires, vehicle fires
    • πŸš‘ Medical Emergency: Accidents, health emergencies, injuries
    • 🚨 Crime: Theft, assault, suspicious activity
    • πŸ—οΈ Infrastructure Issue: Potholes, broken streetlights, damaged roads
    • 🌊 Natural Disaster: Floods, earthquakes, storms
    • πŸš— Road Accident: Vehicle collisions, traffic hazards
    • ⚠️ Other: General safety concerns and civic issues
  • Severity Assessment

    • πŸ”΄ Critical: Immediate life-threatening situations requiring instant response
    • 🟠 High: Urgent matters needing rapid attention
    • 🟑 Medium: Important issues requiring timely resolution
    • 🟒 Low: Non-urgent matters for routine handling
  • Detailed Incident Documentation

    • ✍️ Rich text description with character count (up to 1000 characters)
    • 🏷️ Optional custom tags and keywords
    • πŸ‘€ Anonymous reporting option for sensitive situations
    • πŸ“… Automatic timestamp and date logging
    • πŸ”’ Unique incident ID generation for tracking

2. Interactive Mapping System

Advanced mapping capabilities provide real-time visualization and geographic analysis of incidents.

  • Dynamic Incident Visualization

    • πŸ—ΊοΈ OpenStreetMap integration with Leaflet.js
    • πŸ“Œ Color-coded markers based on severity levels
    • 🎯 Click markers to view incident summaries
    • πŸ”„ Auto-refresh every 30 seconds for live updates
    • πŸ“ Distance calculation between user and incidents
    • 🎨 Custom marker icons for different incident types
  • Map Interaction Features

    • πŸ” Zoom controls (zoom in/out/reset)
    • πŸ–±οΈ Pan and drag to explore areas
    • πŸ“ Center map on user location
    • 🎯 Search location by address or coordinates
    • πŸ“ Measure distance tool
    • πŸŒ“ Toggle between map styles (street/satellite)
  • Filtering and Search

    • πŸ”Ž Filter by incident type, severity, status
    • πŸ“… Date range filtering
    • πŸ“ Radius-based search (1km, 5km, 10km, 20km)
    • 🏷️ Tag-based filtering
    • πŸ’Ύ Save custom filter presets
  • Geographic Clustering

    • 🎈 Automatic clustering for dense areas
    • πŸ”’ Cluster count badges
    • ⚑ Smooth zoom animations
    • πŸ“Š Heat map view option

3. Comprehensive Admin Dashboard

A powerful control center for managing incidents, users, and system operations.

  • Incident Management

    • πŸ“‹ View all incidents in list or grid view
    • πŸ” Advanced search and filtering system
    • πŸ“Š Sort by date, severity, status, location
    • ✏️ Edit incident details inline
    • πŸ—‘οΈ Archive or delete inappropriate reports
    • πŸ“ˆ Bulk operations (verify multiple, update status)
    • πŸ”„ Incident workflow automation
  • Verification System

    • βœ… Multi-level verification workflow:
      • Step 1: Initial review for validity
      • Step 2: Cross-reference with other reports
      • Step 3: Contact verification (optional)
      • Step 4: Final approval
    • πŸ€– AI-powered duplicate detection
    • πŸ“Έ Image authenticity verification
    • πŸ”— Link related incidents
    • πŸ“Š Credibility scoring system
    • ⚠️ Flag suspicious reports
    • πŸ‘₯ Assign to specific admin teams
  • Status Tracking

    • πŸ“ Reported: New incident submitted by user
    • πŸ” Verified: Confirmed legitimate by admin
    • βš™οΈ In Progress: Emergency response in action
    • βœ… Resolved: Issue successfully addressed
    • ❌ Rejected: Invalid or duplicate report
    • πŸ“¦ Archived: Historical record
  • Analytics Dashboard

    • πŸ“Š Real-time statistics and metrics
    • πŸ“ˆ Incident trends and patterns
    • 🌍 Geographic heat maps
    • ⏱️ Average response time tracking
    • πŸ‘₯ User engagement metrics
    • πŸ“‰ Resolution rate over time
    • πŸ“… Daily/weekly/monthly reports
    • πŸ“€ Export data to CSV/PDF
  • Admin Tools

    • πŸ”§ System configuration settings
    • πŸ‘₯ User management and roles
    • 🚫 Ban/suspend problematic users
    • πŸ“’ Send mass notifications
    • πŸ—‚οΈ Category management
    • 🎨 Customize severity levels
    • πŸ“ Incident templates

4. Communication & Messaging System

Real-time communication between citizens, admins, and emergency responders.

  • Incident-Specific Conversations

    • πŸ’¬ Thread-based messaging per incident
    • πŸ‘€ User-to-admin direct messaging
    • πŸ‘₯ Multi-party conversations for complex incidents
    • πŸ“Ž Attach files and images to messages
    • πŸ”— Share incident links within conversations
    • πŸ“Œ Pin important messages
  • Real-Time Features

    • ⚑ Instant message delivery with WebSocket
    • βœ“ Read receipts and typing indicators
    • πŸ”” Push notifications for new messages
    • πŸ’Ύ Automatic message history
    • πŸ” Search within conversations
    • πŸ“€ Message delivery status
  • Admin Communication Panel

    • πŸ“¬ Unified inbox for all conversations
    • πŸ”’ Unread message counters
    • 🎯 Priority message flagging
    • πŸ“‹ Conversation filtering by incident
    • 🏷️ Tag conversations for organization
    • πŸ“Š Response time analytics
    • πŸ€– Quick response templates
  • User Messaging Dashboard

    • πŸ“± Mobile-responsive message interface
    • πŸ”„ Auto-refresh for new messages
    • πŸ“… Message timestamp and history
    • πŸ”” Desktop and mobile notifications
    • βœ‰οΈ Email notifications (optional)
    • πŸ“ž Request callback feature

5. Smart Notifications & Alert System

Intelligent notification system that keeps everyone informed in real-time.

  • User Notifications

    • πŸ”” Real-time push notifications
    • πŸ“§ Email alerts (configurable)
    • πŸ“± SMS notifications (optional)
    • 🌍 Location-based proximity alerts
    • πŸ“Š Notification preferences dashboard
    • πŸ”• Do not disturb mode
    • ⏰ Schedule quiet hours
  • Alert Types

    • 🚨 Emergency Alert: Critical incidents nearby
    • βœ… Status Update: Incident status changes
    • πŸ’¬ New Message: Admin response received
    • βœ“ Verification: Report verified
    • πŸ† Achievement: Milestone reached
    • πŸ“’ Public Announcement: Community-wide alerts
    • ⚠️ Warning: Weather or safety advisories
  • Public Emergency Alerts

    • πŸ“‘ Broadcast to users within radius
    • 🎯 Severity-based alert prioritization
    • πŸ—ΊοΈ Map-based alert visualization
    • ⏰ Automatic expiration
    • πŸ“’ Custom alert messages
    • πŸ”Š Audio alert option
    • πŸ“ž Call-to-action buttons
  • Notification Management

    • βœ“ Mark as read/unread
    • πŸ—‘οΈ Delete or archive
    • πŸ” Search notification history
    • πŸ“Š Notification statistics
    • βš™οΈ Granular notification settings
    • 🎨 Priority color coding
    • πŸ“± Mobile app integration ready

6. Advanced User Management

Comprehensive user profiles and account management system.

  • Authentication & Security

    • πŸ” Firebase Authentication integration
    • πŸ“§ Email/password authentication
    • πŸ”— Social login (Google, Facebook, Twitter)
    • πŸ“± Phone number verification
    • πŸ”‘ Two-factor authentication (2FA)
    • πŸ”„ Password reset and recovery
    • πŸ›‘οΈ Account security monitoring
    • 🚫 Brute force protection
  • Role-Based Access Control

    • πŸ‘€ Citizen: Report and view incidents
    • πŸ›‘οΈ Admin: Verify and manage incidents
    • πŸ‘‘ Super Admin: Full system access
    • πŸ”§ Moderator: Content moderation
    • πŸ“Š Analyst: Read-only access to analytics
    • 🚨 Emergency Responder: Priority access
    • 🏒 Department Head: Team management
  • Profile Management

    • πŸ‘€ Personal information (name, email, phone)
    • πŸ“Έ Profile photo upload and cropping
    • 🏠 Default location settings
    • πŸ“ Saved addresses (home, work)
    • πŸ”” Notification preferences
    • 🌐 Language and region settings
    • 🎨 Theme preferences (light/dark)
    • πŸ”’ Privacy settings
  • Activity Tracking

    • πŸ“Š Incident submission history
    • βœ… Resolved incidents count
    • πŸ’¬ Message activity
    • πŸ† Achievements and badges
    • ⭐ Community reputation score
    • πŸ“ˆ Engagement metrics
    • πŸ“… Account creation date
    • πŸ”„ Last activity timestamp
  • User Statistics Dashboard

    • πŸ“ˆ Personal impact metrics
    • 🎯 Reports by category breakdown
    • πŸ“‰ Resolution success rate
    • ⏱️ Average response time received
    • πŸ… Achievement progress
    • πŸ‘₯ Community ranking
    • πŸ“… Activity calendar
    • πŸ“Š Contribution graphs

πŸ“Š Analytics & Statistics

Comprehensive data visualization and reporting tools.

  • Personal Impact Dashboard

    • πŸ“ˆ Total incidents reported (lifetime)
    • βœ… Verified reports percentage
    • 🎯 Resolved incidents count
    • ⚑ Active incidents tracking
    • ⏱️ Average response time
    • πŸ‘₯ Community impact (people helped)
    • πŸ“… Reports this month/week
    • πŸ† Achievement milestones
  • Category Analysis

    • πŸ“Š Reports by category pie chart
    • πŸ“ˆ Trend analysis over time
    • πŸ”₯ Most reported issue types
    • πŸ“ Category distribution by location
    • πŸ“‰ Category resolution rates
    • ⏱️ Average resolution time per category
  • Severity Breakdown

    • πŸ”΄ Critical incidents count
    • 🟠 High priority reports
    • 🟑 Medium severity issues
    • 🟒 Low priority matters
    • πŸ“Š Severity distribution graph
    • πŸ“ˆ Severity trends
  • Monthly Trends

    • πŸ“… 6-month reporting trend chart
    • πŸ“Š Month-over-month comparison
    • πŸ“ˆ Growth rate analysis
    • 🎯 Peak reporting days/times
    • πŸ“‰ Seasonal patterns
  • Achievement System

    • πŸ† Quick Reporter: 10+ verified reports
    • πŸ›‘οΈ Community Guardian: 15+ resolved incidents
    • ⭐ Top Contributor: Monthly leader
    • πŸš€ Early Adopter: First 100 users
    • πŸ’Ž Platinum Member: 50+ verified reports
    • πŸ”₯ Rapid Responder: Quick reporting streak
    • 🌟 Civic Hero: 100+ total reports

πŸ”’ Security & Privacy

Enterprise-grade security measures to protect user data and system integrity.

  • Data Protection

    • πŸ” End-to-end encryption for sensitive data
    • πŸ›‘οΈ SSL/TLS for all communications
    • πŸ”’ Secure password hashing (bcrypt)
    • πŸ’Ύ Encrypted database storage
    • πŸ”‘ API key authentication
    • 🚫 SQL injection prevention
    • πŸ›‘οΈ XSS attack protection
    • πŸ” CSRF token validation
  • Access Control

    • πŸ” JWT-based authentication
    • πŸ‘€ Session management
    • ⏰ Automatic session timeout
    • πŸ”’ Role-based permissions
    • πŸ“ Audit logging
    • 🚫 IP blacklisting
    • ⚑ Rate limiting
  • Privacy Compliance

    • πŸ“œ GDPR compliant data handling
    • πŸ”’ User data anonymization options
    • πŸ“‹ Comprehensive privacy policy
    • πŸ“„ Clear terms of service
    • πŸ—‘οΈ Right to data deletion
    • πŸ“€ Data export functionality
    • πŸ” Transparent data usage
    • πŸ‘€ Anonymous reporting option
  • System Security

    • πŸ”§ Regular security audits
    • πŸ”„ Automatic security updates
    • πŸ›‘οΈ DDoS protection
    • πŸ” Vulnerability scanning
    • πŸ“Š Security monitoring
    • 🚨 Incident response plan
    • πŸ’Ύ Regular backups
    • πŸ”„ Disaster recovery

🎨 User Experience Features

Thoughtful design elements that enhance usability and accessibility.

  • Responsive Design

    • πŸ“± Mobile-first approach
    • πŸ’» Desktop optimized layouts
    • πŸ“² Tablet-friendly interface
    • πŸ”„ Adaptive UI components
    • ⚑ Fast page load times
    • 🎨 Consistent design system
    • πŸ–ΌοΈ Progressive image loading
  • Performance Optimization

    • ⚑ Lazy loading for images
    • πŸ“¦ Code splitting
    • πŸ”„ Caching strategies
    • πŸš€ CDN integration
    • πŸ“ˆ Lighthouse score optimization
    • πŸ’¨ Minimal bundle size
    • βš™οΈ Server-side rendering
  • Accessibility

    • β™Ώ WCAG 2.1 AA compliant
    • ⌨️ Keyboard navigation support
    • πŸ”Š Screen reader compatibility
    • 🎨 High contrast mode
    • πŸ“ Adjustable text sizes
    • 🎯 Focus indicators
    • πŸ—£οΈ Voice command support (planned)
  • Internationalization

    • 🌐 Multi-language support (planned)
    • πŸ—ΊοΈ Locale-based formatting
    • πŸ“… Regional date/time formats
    • πŸ’± Currency localization
    • 🌍 Timezone handling

πŸ› οΈ Tech Stack

Frontend

  • Framework: Next.js 16.1.1 (React 19.2.3)
  • Language: TypeScript 5.x
  • Styling: Tailwind CSS 4
  • UI Components: Custom components with Lucide React icons
  • Maps: Leaflet + React-Leaflet
  • Authentication: Firebase Auth
  • HTTP Client: Fetch API
  • Deployment: Vercel

Backend

  • Framework: NestJS (Node.js)
  • Language: TypeScript
  • Database: MongoDB with Mongoose ODM
  • Real-Time: Socket.IO for WebSocket connections
  • Authentication: JWT + Firebase Admin SDK
  • File Upload: Multer for multipart/form-data
  • Deployment: Render

Development Tools

  • Version Control: Git
  • Code Editor: VS Code recommended
  • Package Manager: npm
  • Linting: ESLint
  • API Testing: Postman/Thunder Client

πŸ“ Project Structure

CivicAlert/
β”œβ”€β”€ frontend/                    # Next.js Frontend Application
β”‚   β”œβ”€β”€ app/                     # App Router (Next.js 13+)
β”‚   β”‚   β”œβ”€β”€ components/          # Reusable React components
β”‚   β”‚   β”‚   β”œβ”€β”€ Navbar.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Footer.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Hero.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ IncidentCard.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ IncidentMap.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ MapPreview.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ LocationPicker.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ AlertNotifications.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ProfileMenu.tsx
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   β”œβ”€β”€ admin/               # Admin-only pages
β”‚   β”‚   β”‚   β”œβ”€β”€ page.tsx         # Admin dashboard
β”‚   β”‚   β”‚   β”œβ”€β”€ profile/
β”‚   β”‚   β”‚   β”œβ”€β”€ communication/
β”‚   β”‚   β”‚   └── public-alerts/
β”‚   β”‚   β”œβ”€β”€ dashboard/           # User dashboard
β”‚   β”‚   β”‚   β”œβ”€β”€ page.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ messages/
β”‚   β”‚   β”‚   └── alerts/
β”‚   β”‚   β”œβ”€β”€ report/              # Incident reporting
β”‚   β”‚   β”‚   └── page.tsx
β”‚   β”‚   β”œβ”€β”€ incidents/           # Public incidents view
β”‚   β”‚   β”‚   └── page.tsx
β”‚   β”‚   β”œβ”€β”€ incident/            # Incident details
β”‚   β”‚   β”‚   └── [id]/
β”‚   β”‚   β”œβ”€β”€ statistics/          # User statistics
β”‚   β”‚   β”‚   └── page.tsx
β”‚   β”‚   β”œβ”€β”€ login/               # Authentication
β”‚   β”‚   β”‚   └── page.tsx
β”‚   β”‚   β”œβ”€β”€ signup/
β”‚   β”‚   β”‚   └── page.tsx
β”‚   β”‚   β”œβ”€β”€ profile/             # User profile
β”‚   β”‚   β”‚   └── page.tsx
β”‚   β”‚   β”œβ”€β”€ privacy/             # Privacy policy
β”‚   β”‚   β”‚   └── page.tsx
β”‚   β”‚   β”œβ”€β”€ terms/               # Terms of service
β”‚   β”‚   β”‚   └── page.tsx
β”‚   β”‚   β”œβ”€β”€ layout.tsx           # Root layout
β”‚   β”‚   β”œβ”€β”€ page.tsx             # Landing page
β”‚   β”‚   └── globals.css          # Global styles
β”‚   β”œβ”€β”€ lib/                     # Utility libraries
β”‚   β”‚   β”œβ”€β”€ AuthContext.tsx      # Authentication context
β”‚   β”‚   β”œβ”€β”€ authService.ts       # Auth helper functions
β”‚   β”‚   β”œβ”€β”€ firebase.ts          # Firebase configuration
β”‚   β”‚   └── config.ts            # API configuration
β”‚   β”œβ”€β”€ public/                  # Static assets
β”‚   β”œβ”€β”€ next.config.ts           # Next.js configuration
β”‚   β”œβ”€β”€ tailwind.config.js       # Tailwind CSS configuration
β”‚   β”œβ”€β”€ tsconfig.json            # TypeScript configuration
β”‚   └── package.json             # Frontend dependencies
β”‚
β”œβ”€β”€ backend/                     # NestJS Backend Application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ incidents/           # Incident management module
β”‚   β”‚   β”‚   β”œβ”€β”€ incidents.controller.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ incidents.service.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ incidents.module.ts
β”‚   β”‚   β”‚   └── schemas/
β”‚   β”‚   β”‚       └── incident.schema.ts
β”‚   β”‚   β”œβ”€β”€ alerts/              # Alert system module
β”‚   β”‚   β”‚   β”œβ”€β”€ alerts.controller.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ alerts.service.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ alerts.module.ts
β”‚   β”‚   β”‚   └── schemas/
β”‚   β”‚   β”œβ”€β”€ communication/       # Messaging module
β”‚   β”‚   β”‚   β”œβ”€β”€ communication.controller.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ communication.service.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ communication.module.ts
β”‚   β”‚   β”‚   └── schemas/
β”‚   β”‚   β”œβ”€β”€ profile/             # User profile module
β”‚   β”‚   β”‚   β”œβ”€β”€ profile.controller.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ profile.service.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ profile.module.ts
β”‚   β”‚   β”‚   └── schemas/
β”‚   β”‚   β”œβ”€β”€ auth/                # Authentication module
β”‚   β”‚   β”œβ”€β”€ app.module.ts        # Root module
β”‚   β”‚   └── main.ts              # Application entry point
β”‚   β”œβ”€β”€ scripts/                 # Database setup scripts
β”‚   β”‚   └── setup-database.js
β”‚   β”œβ”€β”€ nest-cli.json            # NestJS CLI configuration
β”‚   β”œβ”€β”€ tsconfig.json            # TypeScript configuration
β”‚   └── package.json             # Backend dependencies
β”‚
β”œβ”€β”€ README.md                    # Project documentation
└── .gitignore                   # Git ignore rules

πŸš€ Getting Started

Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js >= 18.x
  • npm >= 9.x
  • MongoDB >= 6.x (local or Atlas)
  • Git
  • Firebase Account (for authentication)

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/civicalert.git
    cd civicalert/CivicAlert
  2. Install Frontend Dependencies

    cd frontend
    npm install
  3. Install Backend Dependencies

    cd ../backend
    npm install

Environment Variables

Frontend Environment Variables

Create a .env.local file in the frontend/ directory:

# API Configuration
NEXT_PUBLIC_API_URL=http://localhost:3001

# 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_FIREBASE_MEASUREMENT_ID=your_measurement_id

Backend Environment Variables

Create a .env file in the backend/ directory:

# Server Configuration
PORT=3001
NODE_ENV=development

# MongoDB Configuration
MONGODB_URI=mongodb://localhost:27017/civicalert
# OR for MongoDB Atlas:
# MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/civicalert?retryWrites=true&w=majority

# Firebase Admin SDK
FIREBASE_PROJECT_ID=your_project_id
FIREBASE_CLIENT_EMAIL=your_service_account@your_project.iam.gserviceaccount.com
FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nYour_Private_Key\n-----END PRIVATE KEY-----\n"

# CORS Configuration
CORS_ORIGIN=http://localhost:3000

# JWT Configuration (Optional)
JWT_SECRET=your_jwt_secret_key
JWT_EXPIRES_IN=7d

# File Upload Configuration
MAX_FILE_SIZE=10485760  # 10MB in bytes
UPLOAD_PATH=./uploads

Running Locally

1. Start MongoDB

If using local MongoDB:

# macOS/Linux
mongod

# Windows
"C:\Program Files\MongoDB\Server\6.0\bin\mongod.exe"

Or use MongoDB Atlas (cloud database).

2. Start Backend Server

cd backend
npm run start:dev

Backend will be available at: http://localhost:3001

3. Start Frontend Development Server

cd frontend
npm run dev

Frontend will be available at: http://localhost:3000

4. Setup Database (Optional)

Initialize database collections and indexes:

cd backend
node scripts/setup-database.js

🌐 Deployment

Frontend Deployment (Vercel)

  1. Push to GitHub

    git add .
    git commit -m "Deploy to production"
    git push origin main
  2. Connect to Vercel

    • Go to vercel.com
    • Import your GitHub repository
    • Select the frontend directory as root
    • Configure environment variables (same as .env.local)
  3. Deploy

    • Click "Deploy"
    • Vercel will automatically build and deploy
    • Your site will be live at: https://your-project.vercel.app

Backend Deployment (Render)

  1. Create Render Account

  2. Create New Web Service

    • Connect your GitHub repository
    • Select the backend directory
    • Set build command: npm install && npm run build
    • Set start command: npm run start:prod
  3. Configure Environment Variables

    • Add all backend environment variables
    • Update MONGODB_URI to your production database
    • Update CORS_ORIGIN to your Vercel URL
  4. Deploy

    • Render will build and deploy automatically
    • Your API will be live at: https://your-backend.onrender.com
  5. Update Frontend API URL

    • In Vercel, update NEXT_PUBLIC_API_URL to your Render backend URL
    • Redeploy frontend

πŸ“‘ API Documentation

Base URL

Local: http://localhost:3001
Production: https://civicalert-fm6x.onrender.com

Incidents Endpoints

Method Endpoint Description Auth Required
GET /incidents Get all incidents No
GET /incidents/:id Get incident by ID No
POST /incidents Create new incident Yes
PATCH /incidents/:id Update incident Yes (Admin)
DELETE /incidents/:id Delete incident Yes (Admin)
POST /incidents/:id/check-duplicates Check for duplicate incidents Yes (Admin)

Alerts Endpoints

Method Endpoint Description Auth Required
GET /alerts/user/:userId Get user alerts Yes
GET /alerts/user/:userId/unread-count Get unread count Yes
PATCH /alerts/:id/read Mark alert as read Yes
POST /alerts/public Create public alert Yes (Admin)

Profile Endpoints

Method Endpoint Description Auth Required
GET /profile/user/:userId Get user profile Yes
GET /profile/admin/:userId Get admin profile Yes (Admin)
PATCH /profile/user/:userId Update user profile Yes
PATCH /profile/admin/:userId Update admin profile Yes (Admin)

Communication Endpoints

Method Endpoint Description Auth Required
GET /communication/messages/:incidentId Get incident messages Yes
POST /communication/messages Send message Yes
PATCH /communication/messages/:id/read Mark message as read Yes

Example Request

Create Incident

curl -X POST http://localhost:3001/incidents \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "type": "Fire",
    "description": "Building fire at Main Street",
    "severity": "CRITICAL",
    "location": {
      "latitude": 40.7128,
      "longitude": -74.0060,
      "address": "123 Main St, New York, NY"
    }
  }'

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the Project
  2. Create your Feature Branch
    git checkout -b feature/AmazingFeature
  3. Commit your Changes
    git commit -m 'Add some AmazingFeature'
  4. Push to the Branch
    git push origin feature/AmazingFeature
  5. Open a Pull Request

Coding Guidelines

  • Follow TypeScript best practices
  • Use meaningful variable and function names
  • Write clean, readable code with comments
  • Test your changes thoroughly
  • Update documentation as needed

Reporting Bugs

If you find a bug, please open an issue with:

  • Clear bug description
  • Steps to reproduce
  • Expected vs actual behavior
  • Screenshots if applicable
  • Environment details (OS, browser, versions)

πŸ“„ License

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



πŸ™ Acknowledgments


πŸ—ΊοΈ Roadmap

  • Mobile app (React Native)
  • SMS notifications
  • Email alerts
  • Multi-language support
  • Dark mode
  • Advanced analytics dashboard
  • Integration with emergency services APIs
  • Social media sharing
  • Incident heat maps
  • AI-powered incident categorization
  • Voice-to-text incident reporting
  • Offline support with PWA

Made with ❀️ for safer communities

⭐ Star this repo if you find it useful!

About

CivicAlert is a comprehensive emergency incident reporting and management platform designed to bridge the gap between citizens and emergency services. It enables real-time incident reporting, verification, tracking, and resolution through an intuitive web interface with advanced mapping capabilities.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages