Skip to content

shrihari7396/eFIR-Complaint-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

19 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ›ก๏ธ eFIR โ€” Electronic First Information Report System

A full-stack civic legal platform enabling citizens to file FIR complaints digitally and police officers to review, accept, or reject them โ€” built with Spring Boot and React.


๐Ÿ“‹ Table of Contents


๐Ÿ” Overview

The eFIR Complaint System digitizes the First Information Report process. Citizens can register, verify via OTP, and file complaints online. Police officers access a dedicated dashboard to manage incoming complaints with pagination and verdict controls. All sensitive PII fields are AES-256-ECB encrypted on the frontend before transmission โ€” the backend stores and returns them as-is, ensuring data privacy.


โœจ Features

๐Ÿ‘ค Citizen Portal

  • Registration with AES-encrypted PII fields (Aadhaar, name, address)
  • Email OTP verification for account activation
  • JWT-based login with auto-expiry detection
  • File FIR complaints with victim, accused, and incident details
  • Track complaint status (Processing โ†’ Succeeded / Rejected)
  • AI Legal Assistant powered by Groq (LLaMA 3) for guidance

๐Ÿ‘ฎ Police Portal

  • Separate police login with role-based access
  • Paginated complaint dashboard with sorting
  • Accept or reject complaints with one-click verdict
  • Seeded admin account auto-created on startup

๐Ÿ” Security

  • AES-256-ECB client-side encryption for all PII
  • BCrypt password hashing
  • JWT authentication (24h expiry)
  • Role-based route protection (frontend + backend)
  • CORS policy locked to allowed origins

๐Ÿ› ๏ธ Tech Stack

Backend

Technology Purpose
Java 17+ Language
Spring Boot 3.4.2 Application framework
Spring Security 6.x JWT authentication & authorization
Spring Data JPA / Hibernate ORM & database access
MySQL 8 Relational database
MapStruct DTO โ†” Entity mapping
Lombok Boilerplate reduction
Springdoc OpenAPI Swagger UI auto-documentation
JavaMailSender OTP email delivery
WebClient (WebFlux) Groq AI API integration

Frontend

Technology Purpose
React 19 UI library
Vite 6 Build tool & dev server
TailwindCSS 3.4 Utility-first styling
React Router v7 Client-side routing
Formik + Yup Form management & validation
Axios HTTP client
CryptoJS AES-256 client-side encryption
react-hot-toast Toast notifications
react-icons Icon library
react-markdown AI response rendering

๐Ÿ—๏ธ Architecture

flowchart TB
    subgraph Frontend["๐Ÿ–ฅ๏ธ Frontend โ€” React 19 + Vite"]
        direction LR
        Landing["Landing Page"]
        Register["Register"]
        OTP["OTP Verify"]
        Login["Citizen Login"]
        PLogin["Police Login"]
        Dashboard["Citizen Dashboard"]
        PDashboard["Police Dashboard"]
        AI["AI Chat Assistant"]

        Landing --> Register --> OTP --> Login --> Dashboard
        Landing --> PLogin --> PDashboard
        Dashboard --> AI
    end

    subgraph Security["๐Ÿ” Security Layer"]
        AES["AES-256-ECB\n(Client Encryption)"]
        JWT["JWT Authentication\nFilter"]
        BCrypt["BCrypt\n(Password Hashing)"]
    end

    subgraph Backend["โš™๏ธ Backend โ€” Spring Boot 3.4"]
        direction TB
        Controllers["Controllers\nUser ยท Complaint ยท Police ยท AI"]
        
        subgraph Services["Service Layer (SOLID)"]
            direction LR
            AuthSvc["Auth\nService"]
            RegSvc["Registration\nService"]
            OTPSvc["OTP\nService"]
            ProfileSvc["Profile\nService"]
            ComplaintSvc["Complaint\nService"]
            PoliceSvc["Police\nService"]
            AISvc["AI Chat\nService"]
        end
        
        subgraph Infra["Infrastructure"]
            direction LR
            Repos["JPA\nRepositories"]
            Mappers["MapStruct\nMappers"]
            Strategy["OTP Delivery\nStrategy Pattern"]
        end
    end

    subgraph Data["๐Ÿ—„๏ธ Data Layer"]
        MySQL[("MySQL 8\nefir_db")]
        Groq["Groq API\n(LLaMA 3)"]
        Mail["SMTP\n(Gmail)"]
    end

    Frontend -- "REST API\n(JSON + JWT)" --> JWT
    JWT --> Controllers
    AES -.-> Frontend
    BCrypt -.-> Backend
    Controllers --> Services
    Services --> Infra
    Repos --> MySQL
    AISvc --> Groq
    Strategy --> Mail
Loading

๐Ÿ“ Project Structure

eFIR-Complaint-System/
โ”‚
โ”œโ”€โ”€ Backend/eFIR/
โ”‚   โ”œโ”€โ”€ Dockerfile            # [NEW] Multi-stage backend build
โ”‚   โ”œโ”€โ”€ .dockerignore         # [NEW] Backend build ignore rules
โ”‚   โ”œโ”€โ”€ pom.xml
โ”‚   โ”œโ”€โ”€ src/main/java/com/efir/
โ”‚   โ”‚   โ”œโ”€โ”€ EfirApplication.java
โ”‚   โ”‚   โ”œโ”€โ”€ config/           # Security, CORS, JWT, Mail, OpenAPI
โ”‚   โ”‚   โ”œโ”€โ”€ controller/       # UserController, ComplaintController,
โ”‚   โ”‚   โ”‚                     # PoliceController, AiController
โ”‚   โ”‚   โ”œโ”€โ”€ service/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ auth/         # Registration + Authentication
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ otp/          # OTP (Strategy Pattern)
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ user/         # Profile retrieval
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ complaint/    # Complaint filing
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ police/       # Police operations
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ai/           # Groq AI integration
โ”‚   โ”‚   โ”œโ”€โ”€ entity/           # User, Complaint, Person, Incidence,
โ”‚   โ”‚   โ”‚                     # Address, OtpRecord
โ”‚   โ”‚   โ”œโ”€โ”€ dto/              # Request & Response DTOs
โ”‚   โ”‚   โ”œโ”€โ”€ repository/       # JPA repository interfaces
โ”‚   โ”‚   โ”œโ”€โ”€ mapper/           # MapStruct mappers
โ”‚   โ”‚   โ”œโ”€โ”€ security/         # JWT provider, filter, UserDetails
โ”‚   โ”‚   โ”œโ”€โ”€ exception/        # Custom exceptions + GlobalHandler
โ”‚   โ”‚   โ””โ”€โ”€ util/             # OtpGenerator, RoleValidator
โ”‚   โ””โ”€โ”€ src/main/resources/
โ”‚       โ””โ”€โ”€ application.properties
โ”‚
โ”œโ”€โ”€ Frontend/efir-complaint-system/
โ”‚   โ”œโ”€โ”€ Dockerfile            # [NEW] Multi-stage frontend build (Nginx)
โ”‚   โ”œโ”€โ”€ .dockerignore         # [NEW] Frontend build ignore rules
โ”‚   โ”œโ”€โ”€ nginx.conf            # [NEW] Nginx SPA routing config
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ”œโ”€โ”€ index.html
โ”‚   โ”œโ”€โ”€ tailwind.config.js
โ”‚   โ”œโ”€โ”€ vite.config.js
โ”‚   โ””โ”€โ”€ src/
โ”‚       โ”œโ”€โ”€ App.jsx
โ”‚       โ”œโ”€โ”€ main.jsx
โ”‚       โ”œโ”€โ”€ api/              # Axios instance
โ”‚       โ”œโ”€โ”€ context/          # AuthContext, DecryptionHelper
โ”‚       โ”œโ”€โ”€ utils/            # AES encryption, session management
โ”‚       โ””โ”€โ”€ components/
โ”‚           โ”œโ”€โ”€ Landing.jsx
โ”‚           โ”œโ”€โ”€ Register.jsx
โ”‚           โ”œโ”€โ”€ Login.jsx
โ”‚           โ”œโ”€โ”€ PoliceLogin.jsx
โ”‚           โ”œโ”€โ”€ Verification.jsx
โ”‚           โ”œโ”€โ”€ Navigation.jsx
โ”‚           โ”œโ”€โ”€ ChatBox.jsx         # AI assistant
โ”‚           โ”œโ”€โ”€ ComplaintList.jsx
โ”‚           โ”œโ”€โ”€ PoliceDashboard.jsx
โ”‚           โ”œโ”€โ”€ ProtectedRoute.jsx
โ”‚           โ”œโ”€โ”€ DashBoard/
โ”‚           โ”‚   โ”œโ”€โ”€ Dashboard.jsx
โ”‚           โ”‚   โ”œโ”€โ”€ ComplaintSubmission.jsx
โ”‚           โ”‚   โ”œโ”€โ”€ Complaints.jsx
โ”‚           โ”‚   โ”œโ”€โ”€ Overview.jsx
โ”‚           โ”‚   โ””โ”€โ”€ SideBar.jsx
โ”‚           โ””โ”€โ”€ ui/           # ErrorBoundary, LoadingSpinner
โ”‚
โ””โ”€โ”€ README.md                 โ† You are here

๐Ÿš€ Getting Started

Prerequisites

Tool Version
Java 17 or higher
Maven 3.8+
Node.js 18+
npm 9+
MySQL 8.0+

1๏ธโƒฃ Database Setup

CREATE DATABASE efir_db;

2๏ธโƒฃ Backend Setup

cd Backend/eFIR

# Configure your database credentials in application.properties
# (or use environment variables โ€” see below)

# Build & Run
mvn clean install
mvn spring-boot:run

The backend starts on http://localhost:8085 Swagger UI is available at http://localhost:8085/swagger-ui.html

Note: A police admin account (admin_police / Police@123) is auto-seeded on first startup.

3๏ธโƒฃ Frontend Setup

cd Frontend/efir-complaint-system

# Create .env file
cp .env.example .env

# Install dependencies
npm install

# Start development server
npm run dev

The frontend starts on http://localhost:5173


๐Ÿณ Docker Deployment (Recommended)

The entire system (MySQL + Backend + Frontend) can be launched using a single command:

1๏ธโƒฃ Prerequisites

  • Docker and Docker Compose installed.

2๏ธโƒฃ Configuration

  • Ensure your environment variables are set in docker-compose.yml (e.g., MAIL_USERNAME, GROQ_API_KEY).

3๏ธโƒฃ Launch

# Build and start all services
docker-compose up -d --build

๐Ÿ”ง Environment Variables

Backend (application.properties)

Variable Default Description
DB_USERNAME root MySQL username
DB_PASSWORD โ€” MySQL password
JWT_SECRET โ€” JWT signing secret (min 32 chars)
MAIL_USERNAME โ€” Gmail address for OTP
MAIL_PASSWORD โ€” Gmail app password
GROQ_API_KEY โ€” Groq API key for AI assistant

Frontend (.env)

Variable Default Description
VITE_API_BASE_URL http://localhost:8085 Backend API base URL

๐Ÿ“ก API Reference

All endpoints are documented via Swagger at /swagger-ui.html. Summary:

Authentication (Public)

Method Endpoint Description
POST /user/register Register new user
POST /user/login Citizen login โ†’ JWT (text/plain)
POST /user/login/police Police login โ†’ JWT (text/plain)
POST /user/sendOtp Send OTP to email
POST /user/verifyOtp Verify OTP โ†’ JWT (text/plain)

Citizen (JWT Required โ€” Role: USER)

Method Endpoint Description
GET /user/get Get user profile
POST /complaint/save File a new complaint
GET /complaint/fetch Get user's complaints

Police (JWT Required โ€” Role: POLICE)

Method Endpoint Description
GET /api/police/complaints Paginated complaint list
POST /api/police/update Accept/reject a complaint

AI (Public)

Method Endpoint Description
POST /ai/api/groq AI legal assistant chat

๐Ÿ”’ Security

Layer Mechanism
Password Storage BCrypt (Spring Security)
PII Protection AES-256-ECB (client-side via CryptoJS)
Authentication JWT (24h expiry, HS256)
Authorization Role-based (USER / POLICE) on both frontend routes and backend endpoints
Session Stateless (no server-side session)
CORS Restricted to configured origins
Input Validation Jakarta Bean Validation on all DTOs

๐Ÿ“ธ Screenshots

Visit the Live Demo or run locally at http://localhost:5173 to explore the full UI.

Page Route Description
๐Ÿ  Landing / Hero section with feature highlights
๐Ÿ“ Register /register Citizen registration with encrypted fields
๐Ÿ” Login /login Citizen OTP-based login flow
๐Ÿ‘ฎ Police Login /police-login Police credentials login
โœ… Verification /verification OTP input screen
๐Ÿ“Š Dashboard /dashboard File complaints, view status, AI chat
๐Ÿ›๏ธ Police Dashboard /police-dashboard Review & verdict complaints

๐Ÿ‘ฅ Team

Role Contributor
Backend Development Shrihari Kulkarni
Frontend Development Athrav Katavkar
Architecture & Design Sanidhya Kulkarni

๐Ÿ“„ License

This project is licensed under the MIT License โ€” see the LICENSE file for details.


Built for Web Technology Laboratory Mini Project
Spring Boot ยท React ยท MySQL ยท AES-256 ยท JWT

citizen_user Citizen@123

admin_police Police@123

About

๐Ÿ›ก๏ธ eFIR โ€” Digital FIR complaint system with AES-256 encryption, JWT auth, OTP verification, AI legal assistant & police dashboard. Built with Spring Boot + React.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors