Skip to content

khalifadalhat/IncidentReport

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

403 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Incident Report - Real-Time Incident Management Platform

A comprehensive, real-time incident reporting and management platform for law enforcement agencies, emergency response teams, and community safety initiatives

TypeScript React Node.js MongoDB Socket.io

Live Demo

Features โ€ข Tech Stack โ€ข Quick Start โ€ข Live Demo โ€ข Documentation โ€ข Contributing


๐ŸŒŸ Overview

Incident Report is a comprehensive, real-time incident reporting and management platform designed specifically for law enforcement agencies, emergency response teams, and community safety initiatives. Built with modern web technologies, it streamlines the entire incident lifecycle from initial report to resolution.

๐Ÿ’ก Why Incident Report?

  • โšก Real-time Communication - Instant chat between citizens and law enforcement
  • ๐Ÿ”’ Secure & Anonymous - Report incidents with or without identification
  • ๐Ÿ“ฑ Mobile-First Design - Works seamlessly on any device
  • ๐ŸŽฏ Role-Based Access - Specialized interfaces for different user types
  • ๐Ÿ“Š Analytics Dashboard - Track response times and crime patterns
  • ๐ŸŒ Multi-Department Support - Coordinate across specialized units

๐ŸŽฏ Problem Statement

Traditional incident reporting systems are often:

  • โŒ Slow and bureaucratic
  • โŒ Lack real-time communication
  • โŒ Don't support anonymous reporting
  • โŒ Have poor mobile experiences
  • โŒ Provide limited tracking for citizens

Incident Report solves these problems with a modern, user-friendly platform that prioritizes speed, security, and transparency.

โœจ What Makes This Special?

Incident Report is a production-ready, enterprise-grade solution that combines real-time communication, intelligent case routing, and comprehensive analytics into one seamless experience. Whether you're handling customer support, incident reports, or emergency response, this platform scales with your needs.

  • โšก Lightning-Fast Real-Time Communication - Built on Socket.io for instant messaging
  • ๐ŸŽฏ Smart Case Routing - AI-ready architecture for intelligent agent assignment
  • ๐Ÿ“Š Rich Analytics Dashboard - Beautiful visualizations with Recharts
  • ๐Ÿ” Enterprise Security - JWT authentication, role-based access control
  • ๐ŸŽจ Modern UI/UX - Built with Tailwind CSS, Radix UI, and Framer Motion
  • ๐Ÿ“ฑ Fully Responsive - Works flawlessly on desktop, tablet, and mobile
  • ๐Ÿš€ Production Ready - Comprehensive error handling, validation, and testing
  • ๐Ÿ“š Fully Documented - Swagger API documentation included

โœจ Key Features

๐Ÿ‘ฅ For Citizens/Customers

  • ๐Ÿ“ Easy Reporting - Submit incidents in under 2 minutes
  • ๐Ÿ” Secure Account Creation - Email OTP verification for account registration
  • ๐Ÿ”‘ Password Recovery - Secure password reset via email OTP verification
  • ๐Ÿ•ต๏ธ Anonymous Options - Report without revealing identity
  • ๐Ÿ’ฌ Direct Communication - Chat with assigned officers in real-time
  • ๐Ÿ“ Location Tracking - Automatic GPS location capture
  • ๐Ÿ“Ž Evidence Upload - Attach photos, videos, and documents
  • ๐Ÿ”” Status Notifications - Get updates on your case progress
  • ๐Ÿ“ฑ Mobile App - iOS and Android support (coming soon)

๐Ÿ‘ฎ For Law Enforcement Agents

  • ๐ŸŽฏ Smart Assignment - Auto-routing to specialized departments
  • ๐Ÿ“Š Case Dashboard - Manage all assigned incidents
  • ๐Ÿ’ฌ Multi-Channel Communication - Chat, voice notes, file sharing
  • ๐Ÿ” Investigation Tools - Timeline tracking, evidence management
  • ๐Ÿค Collaboration - Work with other departments seamlessly
  • ๐Ÿ“ˆ Performance Metrics - Track response times and resolution rates
  • ๐Ÿ”” Real-time Alerts - Instant notifications for urgent cases

๐Ÿ‘” For Supervisors & Admins

  • ๐Ÿ“Š Analytics Dashboard - Comprehensive reporting and insights
  • ๐Ÿ‘ฅ Agent Management - Create, assign, and monitor agents
  • ๐Ÿข Department Oversight - Track workload distribution
  • ๐ŸŽš๏ธ Priority Management - Escalate critical incidents
  • ๐Ÿ“ˆ Trend Analysis - Identify crime patterns and hotspots
  • โš™๏ธ System Configuration - Customize workflows and settings
  • ๐Ÿ“‹ Audit Logs - Complete activity tracking

๐ŸŽฏ Technical Features

๐Ÿ’ฌ Real-Time Communication

  • Live Chat System - Instant messaging between customers and agents
  • Typing Indicators - See when someone is typing in real-time
  • Read Receipts - Track message delivery and read status
  • Emoji Support - Rich emoji picker for expressive communication
  • File Attachments - Upload and share images via Cloudinary

๐Ÿ“‹ Case Management

  • Multi-Status Workflow - Pending โ†’ Active โ†’ Resolved/Rejected
  • Department-Based Routing - 20+ specialized departments
  • Location Tracking - GPS-based location services
  • Case History - Complete audit trail of all interactions
  • Priority Assignment - Smart prioritization system

๐Ÿ‘ฅ Role-Based Access Control

  • Customer Portal - Submit cases, track status, chat with agents
  • Agent Dashboard - Manage assigned cases, real-time chat, analytics
  • Supervisor View - Oversee team performance and case distribution
  • Admin Panel - Full system control, user management, analytics

๐Ÿ“Š Analytics & Insights

  • Real-Time Dashboards - Live metrics and KPIs
  • Performance Tracking - Response times, resolution rates
  • Team Analytics - Agent performance metrics
  • Case Statistics - Department-wise breakdowns
  • Visual Charts - Beautiful data visualizations

๐Ÿ”” Notifications

  • Real-Time Alerts - Instant notifications for new messages and case updates
  • Email Notifications - Automated email alerts via Nodemailer/Resend
  • In-App Notifications - Persistent notification center
  • Status Updates - Automatic notifications on case status changes

๐Ÿ›ก๏ธ Security & Authentication

  • JWT Authentication - Secure token-based authentication
  • OTP Verification - Email-based OTP for account creation and password reset
  • Password Hashing - Bcrypt with salt rounds
  • Cookie-Based Sessions - Secure HTTP-only cookies
  • Role-Based Permissions - Granular access control
  • Input Validation - Yup schema validation

๐Ÿ› ๏ธ Tech Stack

Frontend (client/)

Technology Purpose Version
React 18 UI Framework Latest
TypeScript Type Safety Latest
Vite Build Tool Latest
Tailwind CSS Styling Latest
Radix UI Accessible Components Latest
Framer Motion Animations Latest
React Query Data Fetching v5
Zustand State Management v5
Socket.io Client Real-Time Communication v4
React Router Routing v6
React Hook Form Form Management Latest
Yup Validation Latest
Recharts Data Visualization Latest
Sonner Toast Notifications Latest

Backend (backend/)

Technology Purpose Version
Node.js Runtime Latest
Express.js Web Framework v4
MongoDB Database Latest
Mongoose ODM v8
Socket.io WebSocket Server v4
JWT Authentication v9
Bcrypt Password Hashing Latest
Multer File Upload Latest
Cloudinary Media Storage Latest
Nodemailer/Resend Email Service Latest
Swagger API Documentation Latest

๐Ÿš€ Quick Start

Prerequisites

  • Node.js >= 18.x
  • MongoDB >= 6.x (local or Atlas)
  • npm or yarn

Installation

  1. Clone the repository

    git clone https://github.com/khalifadalhat/IncidentReport.git
    cd IncidentReport
  2. Install dependencies

    # Install root dependencies (if any)
    npm install
    
    # Install backend dependencies
    cd backend
    npm install
    
    # Install frontend dependencies
    cd ../client
    npm install
  3. Environment Setup

    Backend (backend/.env):

    # Database
    MONGODB_URI=mongodb://localhost:27017/incidentreport
    
    # JWT
    JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
    
    # Server
    PORT=5000
    NODE_ENV=development
    
    # CORS
    ALLOWED_ORIGINS=http://localhost:5173,http://localhost:3000
    
    # Cloudinary (for file uploads)
    CLOUDINARY_CLOUD_NAME=your-cloud-name
    CLOUDINARY_API_KEY=your-api-key
    CLOUDINARY_API_SECRET=your-api-secret
    
    # Email (required for OTP functionality)
    GMAIL_USER=your-email@gmail.com
    GMAIL_APP_PASSWORD=your-gmail-app-password
    # Alternative email service (optional)
    EMAIL_HOST=smtp.gmail.com
    EMAIL_PORT=587
    EMAIL_USER=your-email@gmail.com
    EMAIL_PASS=your-app-password
    RESEND_API_KEY=your-resend-key

    Frontend (client/.env):

    VITE_API_URL=http://localhost:5000
  4. Create Admin User (Optional)

    cd backend
    node createAdmin.js
  5. Start Development Servers

    Terminal 1 - Backend:

    cd backend
    npm start

    Backend runs on http://localhost:5000 API Docs available at http://localhost:5000/api-docs

    Terminal 2 - Frontend:

    cd client
    npm run dev

    Frontend runs on http://localhost:5173

  6. Access the Application


๐Ÿ“ Project Structure

incidentreport/
โ”œโ”€โ”€ client/                 # React + TypeScript Frontend
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/    # Reusable UI components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ agent/     # Agent-specific components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ auth/      # Authentication components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ui/        # Base UI components (Radix UI)
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”œโ”€โ”€ pages/         # Page components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ admin/     # Admin dashboard pages
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ agent/     # Agent dashboard pages
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ customer/  # Customer portal pages
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ supervisor/# Supervisor pages
โ”‚   โ”‚   โ”œโ”€โ”€ hooks/         # Custom React hooks
โ”‚   โ”‚   โ”œโ”€โ”€ store/         # Zustand state management
โ”‚   โ”‚   โ”œโ”€โ”€ routes/        # React Router configuration
โ”‚   โ”‚   โ”œโ”€โ”€ utils/         # Utility functions
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”œโ”€โ”€ public/            # Static assets
โ”‚   โ””โ”€โ”€ package.json
โ”‚
โ”œโ”€โ”€ backend/               # Node.js + Express Backend
โ”‚   โ”œโ”€โ”€ config/           # Configuration files
โ”‚   โ”‚   โ”œโ”€โ”€ db.js         # MongoDB connection
โ”‚   โ”‚   โ””โ”€โ”€ cloudinary.js # Cloudinary setup
โ”‚   โ”œโ”€โ”€ controllers/      # Route controllers
โ”‚   โ”œโ”€โ”€ models/           # Mongoose models
โ”‚   โ”œโ”€โ”€ routes/           # Express routes
โ”‚   โ”œโ”€โ”€ middleware/       # Custom middleware
โ”‚   โ”œโ”€โ”€ utils/            # Utility functions
โ”‚   โ”œโ”€โ”€ server.js         # Entry point
โ”‚   โ””โ”€โ”€ swagger.js        # API documentation
โ”‚
โ””โ”€โ”€ README.md

๐Ÿ“š API Documentation

The backend includes comprehensive Swagger/OpenAPI documentation. Once the server is running, visit:

http://localhost:5000/api-docs

Key Endpoints

Authentication

User login/register (Customer/Agent/Admin)

  • POST /api/auth/login - Login user (Customer/Agent/Admin)
  • POST /api/auth/admin/create - Register new Admin

Account Registration with OTP:

  • POST /api/auth/register/request-otp - Request OTP for account registration (sends 6-digit OTP to email)
  • POST /api/auth/register/verify-otp - Verify OTP for registration (validates email and OTP)
  • POST /api/auth/register - Complete customer registration (after OTP verification)

Password Reset with OTP:

  • POST /api/auth/forgot-password - Request password reset OTP (sends 6-digit OTP to email)
  • POST /api/auth/forgot-password/verify-otp - Verify password reset OTP (validates email and OTP)
  • POST /api/auth/reset-password - Reset password (after OTP verification)

Password Change (Authenticated):

  • POST /api/auth/change-password/request-otp - Request OTP for password change (requires authentication)
  • POST /api/auth/change-password - Change password with OTP (requires authentication)

Cases

Support cases/tickets management

  • POST /api/cases - Create new case (Customer only)
  • GET /api/cases - Get all cases (Admin only)
  • GET /api/cases/my - Get my cases (Customer/Agent)
  • PATCH /api/cases/{caseId}/accept - Accept case (Agent only)
  • PATCH /api/cases/{caseId}/status - Update case status (Agent only)
  • PATCH /api/cases/assign - Assign case to agent (Admin only)

Chat

Chat history & unread counts

  • GET /api/chat/history - Get chat history (Customer/Agent)
  • GET /api/chat/case/{caseId} - Get case chat (Customer/Agent)
  • Note: Real-time messaging is handled via Socket.io (preferred method)

Messages

HTTP fallback for messages (real-time via Socket.IO)

  • GET /api/messages/case/{caseId} - Get messages for case (fallback)

Users

Profile management & agent creation (Admin/Supervisor only)

  • GET /api/users/profile - Get current user profile
  • PATCH /api/users/profile - Update user profile
  • POST /api/users/agents - Create new agent (Admin/Supervisor only)
  • GET /api/users/agents - Get all agents (Admin/Supervisor only)

Admin

Admin-only endpoints

  • GET /api/admin/dashboard - Get admin dashboard stats
  • GET /api/admin/users - Get all users (Admin only)
  • GET /api/admin/cases - Get all cases (Admin only)
  • DELETE /api/admin/users/{userId} - Delete user (Admin only)

Note: Additional admin endpoints like /api/admin/performance may be available but are not documented in the Swagger API.

Notifications

User-specific notifications and status updates

  • GET /api/notifications - Get a list of the user's notifications
  • GET /api/notifications/unread-count - Get the total count of unread notifications for the user
  • PATCH /api/notifications/{id}/read - Mark a specific notification as read
  • PATCH /api/notifications/mark-all-read - Mark all unread notifications for the current user as read
  • DELETE /api/notifications/{id} - Delete a specific notification by ID
  • DELETE /api/notifications/clear-read - Delete all notifications that have been read by the current user

Uploads

  • POST /upload - Upload an image to Cloudinary

๐Ÿ—บ๏ธ Live Location & Mapping

  • Leaflet Maps Integration - Interactive maps for real-time visualization
  • Browser Geolocation API - Users grant permission before location sharing
  • Live Updates - Location updates pushed in real time to agents and admins
  • Role-Based Visibility - Only authorized agents and admins can access tracking data

๐ŸŒ Live Demo

๐Ÿ”— View Live Application

Experience the full Incident Report platform with real-time features, role-based dashboards, and comprehensive case management.


๐ŸŽจ Screenshots & Demo

๐Ÿ  Landing Page

Landing Page

The welcoming landing page that introduces visitors to the Incident Report platform.


๐Ÿ‘ฅ Customer Portal

User Details & Profile

User Details

  • User profile management
  • Personal information updates

Department Selection

User Department

  • Choose the appropriate department for your incident
  • Multiple specialized departments available

My Cases

User Cases

  • View all your submitted cases
  • Track case status and progress
  • Monitor resolution timeline

My Cases (Mobile View)

User Cases Mobile

  • Mobile-optimized case management interface
  • Responsive design for on-the-go access
  • Touch-friendly navigation

Real-Time Chat

User Chat Mobile

  • Direct communication with assigned agents
  • Real-time messaging via Socket.io
  • File and image sharing support
  • Mobile-optimized chat interface

๐Ÿ‘ฎ Agent Dashboard

Agent Dashboard Overview

Agent Dashboard

  • Overview of assigned cases
  • Quick access to pending, active, and resolved cases
  • Performance metrics and statistics

Agent Cases Management

Agent Cases

  • Manage all assigned incidents
  • Filter by status (pending, active, resolved)
  • Quick case details and actions

Agent Chat

Agent Chat

  • Real-time communication with customers
  • Multi-case chat management
  • File sharing and media support
  • Instant message delivery

Agent Settings

Agent Settings

  • Profile configuration
  • Account settings and preferences

๐Ÿ‘” Admin Panel

Admin Dashboard

Admin Dashboard

  • Comprehensive analytics and statistics
  • System-wide overview
  • Key performance indicators

User Management

Admin Users

  • Manage all users (customers, agents, supervisors)
  • Create new agents and admins
  • User role assignment and permissions

Case Management

Admin Case Management

  • View all cases across the system
  • Assign cases to agents
  • Monitor case resolution rates
  • Department-wise case distribution

๐Ÿ—บ๏ธ Live User Tracking

Live Tracking Map

  • Real-time user location visualization using Leaflet
  • Accessible to agents and admins on the tracking page

๐Ÿ”ง Development

Available Scripts

Backend:

npm start          # Start development server with nodemon

Frontend:

npm run dev        # Start Vite dev server
npm run build      # Build for production
npm run preview    # Preview production build
npm run lint       # Run ESLint

Code Style

  • Frontend: TypeScript with strict mode enabled
  • Backend: ES6+ JavaScript
  • Linting: ESLint with TypeScript support
  • Formatting: Prettier (recommended)

๐Ÿšข Deployment

Backend Deployment

  1. Environment Variables: Set all required env vars in your hosting platform
  2. Database: Use MongoDB Atlas for production
  3. Recommended Platforms:
    • Render
    • Railway
    • Heroku
    • AWS EC2
    • DigitalOcean

Frontend Deployment

  1. Build the project:

    cd client
    npm run build
  2. Deploy the dist folder to:

    • Vercel (recommended)
    • Netlify
    • AWS S3 + CloudFront
    • GitHub Pages

Environment Variables for Production

Make sure to update:

  • ALLOWED_ORIGINS with your production frontend URL
  • MONGODB_URI with your production database
  • JWT_SECRET with a strong, random secret
  • CLOUDINARY_* with your production Cloudinary credentials

๐Ÿค Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated!

  1. Fork the repository
  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

Contribution Guidelines

  • Follow the existing code style
  • Write meaningful commit messages
  • Add tests for new features
  • Update documentation as needed
  • Ensure all tests pass

๐Ÿ“ License

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


๐Ÿ™ Acknowledgments


๐Ÿ“ง Contact & Support


โญ Show Your Support

If you find this project helpful, please consider giving it a โญ on GitHub! It helps others discover the project and motivates continued development.


Built with โค๏ธ by Dalhat Dalhat falalu

โฌ† Back to Top

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors