COMPLAINT MANAGEMENT SYSTEM
Goal: Create a centralized platform for students to raise complaints (hostel
facilities) and for wardens/admins to track, respond and resolve them.
KEY FEATURES:
For Students:
1. Register/Login (Spring Security)
2. Raise a complaint (Category, details, optional image)
3. Track Complaint status
4. Edit/Delete own complaints
5. Comment thread on complaint
For Admin/Warden:
1. Login as Admin
2. View all complaints
3. Filter by status /category/date
4. Update status (with remarks)
5. Add comments/resolve/close complaints
6. Email notification on status update
Tech Stack:
Layer Tools
Backen Spring Boot, Spring Data JPA, Spring
d Security
DB MySQL / PostgreSQL
Auth JWT or Basic Auth
Fronten
[Link] or Thymeleaf
d
Swagger (API docs), Spring Mail (email),
Others
Lombok
Database Tables (Simplified):
users
| id | name | email | password | role (STUDENT/ADMIN) |
complaints
| id | title | description | category | status | created_by | created_at |
updated_at |
comments
| id | content | complaint_id | created_by | created_at |
FUNCTIONAL FLOW:
1. Student signs up/logs in
2. Student raises a complaint under a category (e.g. hostel)
3. Admin sees complaint in their dashboard
4. Admin adds remarks or resolves.
5. Student gets notified (email or dashboard)
6. Comments enable communication on the ticket
DEPENDENCIES:
1. Spring Web (WEB) – Build web, including RESTful, application using Spring
MVC. Uses Apache Tomcat as the default embedded container.
2. Spring Data JPA (SQL) – Persist data in SQL stores with Java Persistence API
using Spring Data and Hibernate
3. Spring Security (SECURITY) – Highly customizable authentication and
access-control framework for Spring applications
4. MySQL Driver (SQL) – MySQL JDBC driver
5. Lombok (DEVELOPER TOOLS) – Java annotation library which helps to
reduce boilerplate code
6. Spring Boot DevTools (DEVELOPER TOOLS) – Provides fast application
restarts, LiveReload, and configurations for enhanced development
experience
7. Validation (I/O) – Bean Validation with Hibernate validator
8. Java Mail Sender (I/O) – Send email using Java Mail and Spring
Framework’s JavaMailSender
JWT
JSON Web Token is a secure way to share information between two parties –
usually a server and a client – using a digitally signed token.
🧠 Think of it like a School ID Card:
When you log in to your school portal, it gives you an ID card (token).
The card has your name and a stamp so no one can forge it.
Every time you enter a room (API), you just show the ID — no need to log
in again.
When it expires, you get a new one by logging in again.
Technical Breakdown:
It's made of 3 parts:
1. Header – tells what algorithm is used (e.g., HS256)
2. Payload – contains user data (e.g., username, issued time, expiry)
3. Signature – a hash that ensures the token wasn’t tampered with
Why Use JWT?
Advantage What it means
✅ Stateless No need to store sessions in DB
📦 Self-contained Token holds all required data
🔐 Secure (signed
Tampering is detectable
tokens)
🌐 Works with REST Especially useful in microservices &
APIs mobile
🔄 Flow in Your Spring Boot App
1. 🧑 User logs in with username/password
2. ✅ Server verifies → generates JWT → sends it to user
3. User attaches JWT in the header of future requests:
AUTHORIZATION : BEARER <JWT>
4. 🔍 Server checks if JWT is valid — if yes, grants access
[Link] code
It is a utility class that helps:
Generate a JWT token for logged-in user
Read(decode) that token to extract the username
Check if a token is valid or expired
[Link]
Spring security needs to know how to load users form your database – that’s
what this file does.
[Link]
This is your actual User table in the database.
[Link]
This helps String Data JPA auto-generate queries like findByUsername()
[Link]
🧠What this does:
Endpoi
Role
nt
Registers a new user (with encrypted
/register
password)
Verifies credentials and returns a JWT
/login
token
[Link]
This is where we set up:
1. Password encoding
2. Public vs secured routes
3. JWT filter for validating tokens
[Link]
It is the heart of JWT security: the filter that checks for the token on every
request and loads the user into Spring Security’s context if it’s valid.
Ste
Purpose
p
1️⃣ Grab the Authorization header from the request
2️⃣ Extract the JWT and username using JwtUtil
3️⃣ Load user from DB using UserDetailsServiceImpl
Ste
Purpose
p
If token is valid, create an AuthenticationToken and set it in the
4️⃣
SecurityContext
5️⃣ Pass the request down the filter chain (or to the controller)
✅ Complaint System (Student side)
Complaint Entity with title, description, status, username
ComplaintRepository with findByUsername()
ComplaintController to:
o Submit complaint (POST)
o Get own complaints (GET)
Tested using Postman with JWT auth ✅
Next Key Features To Build
🔒 1. Role-Based Access (STUDENT / ADMIN / WARDEN)
Different users should have different access (e.g., only admins can update
complaint status).
⏩ We'll use Spring Security + method-level access control (@PreAuthorize
or custom filters).
2. Admin Panel Features
✅ View all complaints
🔄 Filter complaints by status/category/date
📝 Update status with remarks (RESOLVED, REJECTED, etc.)
💬 3. Comment System
Users & admins can post threaded comments under each complaint.
📨 4. Email Notifications (optional for later)
Send email to user when their complaint status is updated.
5. Edit/Delete Own Complaints
Allow students to update or delete their complaint (only when status is
PENDING).
🎨 6. Frontend (React or Thymeleaf)
We'll eventually build a simple frontend using React to consume these
APIs.
1. Create Comment Entity
2. Update Complaint entity
3. Create comment repository
4. Create comment controller