🧩 1.
Entity Relationship Overview (Reflecting your note)
scss
CopyEdit
Employee (1) ──── (M) Ticket (1) ──── (M) Message
│
└─── Assignee (optional)
2. Updated Schema
✅ 1. User (for all roles)
java
CopyEdit
@Entity
public class User {
@Id UUID id;
String username;
String email;
String password;
@ElementCollection(fetch = FetchType.EAGER)
List<Role> roles;
boolean enabled;
}
✅ 2. Role (Enum)
java
CopyEdit
public enum Role {
SUPER_ADMIN,
ADMIN,
ASSIGNEE,
EMPLOYEE
}
✅ 3. Employee
java
CopyEdit
@Entity
public class Employee {
@Id UUID id;
String name;
String contact;
String currentClient;
@OneToOne
User user;
@OneToMany(mappedBy = "employee", cascade = CascadeType.ALL)
List<Ticket> tickets;
}
✅ 4. Ticket
java
CopyEdit
@Entity
public class Ticket {
@Id UUID id;
String subject;
String category;
String description;
@Enumerated(EnumType.STRING)
TicketStatus status;
@ManyToOne
Employee employee;
@ManyToOne
Department department;
@ManyToOne
User assignee; // user with ASSIGNEE role
LocalDateTime createdAt;
LocalDateTime updatedAt;
@OneToMany(mappedBy = "ticket", cascade = CascadeType.ALL)
List<Message> messages;
}
✅ 5. Message
java
CopyEdit
@Entity
public class Message {
@Id UUID id;
@ManyToOne Ticket ticket;
@ManyToOne User sender;
String message;
LocalDateTime sentAt;
}
✅ 6. Department
java
CopyEdit
@Entity
public class Department {
@Id UUID id;
String name;
@OneToOne
User headOfDepartment;
@OneToMany
List<User> assignees; // all with ASSIGNEE role
}
✅ 7. TicketStatus (Enum)
java
CopyEdit
public enum TicketStatus {
OPEN,
IN_PROGRESS,
CLOSED,
REJECTED
}
🔧 3. Maven Monolithic Project Structure
swift
CopyEdit
ticketing-system/
├── src/
│ ├── main/
│ │ ├── java/com/company/ticketing/
│ │ │ ├── controller/
│ │ │ ├── dto/
│ │ │ ├── entity/
│ │ │ ├── enums/
│ │ │ ├── repository/
│ │ │ ├── security/
│ │ │ ├── service/
│ │ │ └── TicketingApplication.java
│ │ └── resources/
│ │ ├── application.yml
│ │ ├── application-dev.yml
│ │ └── application-uat.yml
│ ├── test/
│ │ └── java/com/company/ticketing/
├── Dockerfile
├── pom.xml
└── README.md
👥 User Role-Based Functionalities
👤 1. Employee
🔧 Functionalities:
Feature Description
Register/Login Auth via credentials (JWT-based)
Select department, category, subject,
Raise Ticket
description
View My Tickets List of tickets raised by the logged-in employee
View Ticket Status See status like OPEN, IN_PROGRESS, CLOSED
Chat/Message in
View and send messages for their tickets
Ticket
Edit Ticket
Edit only if ticket is still OPEN and unassigned
(limited)
Close Ticket Request closure if resolved (status:
(optional) CLOSED_PENDING)
2. Assignee
🔧 Functionalities:
Feature Description
Login Auth via credentials (JWT-based)
View Assigned
List of tickets assigned to them
Tickets
Change Ticket Update status to IN_PROGRESS, CLOSED, or
Status REJECTED
Message Chat with ticket-raising employee
Feature Description
Employee
Filter Tickets By status, category, department
Overview of new, pending, closed tickets
Daily Dashboard
(optional)
🧑💼 3. Admin (Head of Department)
🔧 Functionalities:
Feature Description
Login Auth via credentials
View Department
All tickets raised to the department
Tickets
Assign Assignee to
Assign assignee from within the department
Ticket
View All Assignees List of current assignees in department
Add/Remove Add new assignees or remove existing ones (via
Assignee linking users)
Track Ticket
Monitor ticket statuses
Progress
Chat on Ticket
Intervene on tickets via messages
(optional)
Filter/Search
By category, employee, assignee, status
Tickets
Department
Daily report: tickets opened, resolved, pending
Dashboard
🧑⚖️4. Super Admin
🔧 Functionalities:
Feature Description
Full System Access View all users, departments, and tickets
Create Admin Add a new department admin (head)
Create/Edit
Set up new departments, assign heads
Departments
Create Assignees Add assignees before assigning them to
Globally departments
Assign Admin to Promote user to admin of a department
Feature Description
Department
View System Stats Total tickets, department-wise reports
Promote/demote users (e.g., employee →
Manage User Roles
assignee)
View log of system-wide actions (via DB
Audit Logs (optional)
table)
🔄 Role Hierarchy Permissions
plaintext
CopyEdit
Super Admin > Admin > Assignee > Employee
Super Admin can manage everything.
Admin can manage tickets and assignees within their department.
Assignee can only work on assigned tickets.
Employee can only interact with their own tickets.
🎯 Suggested APIs by Role
Endpoint Access Description
POST /auth/login All Login with credentials
POST /tickets Employee Raise a ticket
GET /tickets/mine Employee List my tickets
GET /tickets/assigned Assignee List assigned tickets
PATCH /tickets/{id}/status Assignee/Admin Update ticket status
Assign assignee to
POST /tickets/{id}/assign Admin
ticket
List department
GET /admin/assignees Admin
assignees
Admin/ Add assignee to
POST /admin/assignee
SuperAdmin department
POST /superadmin/admin SuperAdmin Promote user to admin
POST
SuperAdmin Add new department
/superadmin/department