How prashanthcoder/employee-management-system works
Purpose and runtime
Spring Boot 3-style Java 17 backend for employee administration and user onboarding. It exposes REST endpoints for user registration, email OTP verification/login, and employee CRUD, backed by JPA and a relational database (documented as MySQL). The process starts through src/main/java/com/emsminiproject/Employee/management/system/EmployeeManagementSystemApplication.java; runtime properties, including database/SMTP configuration, are in src/main/resources/application.properties.
HTTP/API boundary
Controllers are the inbound REST boundary:
• User/authentication operations: src/main/java/com/emsminiproject/Employee/management/system/controller/UserController.java
• Employee CRUD operations: src/main/java/com/emsminiproject/Employee/management/system/controller/EmployeeController.java
The advertised API separates /auth/* registration, OTP verification, and login from /employees/* management. Controllers should translate request DTOs and HTTP concerns into service calls and response entities.
User registration and OTP activation
Registration accepts a dedicated request shape in src/main/java/com/emsminiproject/Employee/management/system/dto/RegisterRequestDTO.java and persists user/account state through src/main/java/com/emsminiproject/Employee/management/system/service/UserService.java.
OTP verification receives src/main/java/com/emsminiproject/Employee/management/system/dto/VerifyOtpRequest.java, then coordinates OTP generation/validation in src/main/java/com/emsminiproject/Employee/management/system/service/OtpService.java. OTP generation is isolated at src/main/java/com/emsminiproject/Employee/management/system/util/OtpGenerator.java, while delivery crosses the SMTP boundary through src/main/java/com/emsminiproject/Employee/management/system/service/EmailService.java.
Employee domain workflow
Employee CRUD flows from EmployeeController to src/main/java/com/emsminiproject/Employee/management/system/service/EmployeeService.java, then to src/main/java/com/emsminiproject/Employee/management/system/repository/EmployeeRepository.java. The persisted employee model is src/main/java/com/emsminiproject/Employee/management/system/entity/Employee.java.
This is the principal administrative data path for create, list, lookup, update, and delete operations. Authorization is intended to distinguish admin-wide access from employee self-service access.
Persistence boundary
JPA entities represent the durable application state:
• Accounts, roles, credentials, and likely OTP/verification fields: src/main/java/com/emsminiproject/Employee/management/system/entity/User.java
• Employee records: src/main/java/com/emsminiproject/Employee/management/system/entity/Employee.java
Repositories isolate database queries and persistence: src/main/java/com/emsminiproject/Employee/management/system/repository/UserRepository.java and src/main/java/com/emsminiproject/Employee/management/system/repository/EmployeeRepository.java. MySQL (or another relational JPA-compatible database) is the material infrastructure dependency.
Security and authorization
src/main/java/com/emsminiproject/Employee/management/system/security/SecurityConfig.java defines the Spring Security boundary protecting endpoints and enforcing role-based access. src/main/java/com/emsminiproject/Employee/management/system/configuration/Myconfig.java likely supplies application-level beans/configuration supporting this setup.
The README describes login and role access but identifies JWT and BCrypt as future enhancements; do not assume token-based authentication or encrypted-password implementation without inspecting these classes.
Failure handling and service contracts
src/main/java/com/emsminiproject/Employee/management/system/exception/GlobalException.java centralizes HTTP-facing exception translation. Domain failure states are explicit, including missing users, missing email identity, invalid/expired OTPs, and duplicate verification:
UserNotFoundException.java, EmailIdNotFoundException.java, InvalidOtpException.java, OtpExpiredException.java, and OtpAlreadyVerifiedException.java under src/main/java/com/emsminiproject/Employee/management/system/exception/.
This keeps controllers thin while services enforce onboarding and data-management rules.
Main entry points: OtpService.java OTP Service · UserController.java User Controller · UserRepository.java User Repository · SecurityConfig.java Security Config
Components 18
HTTP API
- Security Config · Protects endpoints and applies role-based access.
src/main/java/com/emsminiproject/Employee/management/system/security/SecurityConfig.java - User Controller · Handles registration, OTP verification, and login endpoints.
src/main/java/com/emsminiproject/Employee/management/system/controller/UserController.java - Employee Controller · Handles employee CRUD endpoints.
src/main/java/com/emsminiproject/Employee/management/system/controller/EmployeeController.java - Registration & OTP DTOs
src/main/java/com/emsminiproject/Employee/management/system/dto/RegisterRequestDTO.java - Global Exception Handler · Converts domain failures to HTTP responses.
src/main/java/com/emsminiproject/Employee/management/system/exception/GlobalException.java
Application Services
- User Service · Persists and manages account onboarding state.
src/main/java/com/emsminiproject/Employee/management/system/service/UserService.java - OTP Service · Coordinates OTP generation and validation.
src/main/java/com/emsminiproject/Employee/management/system/service/OtpService.java - Email Service · Delivers OTP emails through SMTP.
src/main/java/com/emsminiproject/Employee/management/system/service/EmailService.java - OTP Generator
src/main/java/com/emsminiproject/Employee/management/system/util/OtpGenerator.java - Employee Service · Enforces employee CRUD workflow rules.
src/main/java/com/emsminiproject/Employee/management/system/service/EmployeeService.java
Persistence
- User Repository
src/main/java/com/emsminiproject/Employee/management/system/repository/UserRepository.java - Employee Repository
src/main/java/com/emsminiproject/Employee/management/system/repository/EmployeeRepository.java - User Account · Stores account, role, credential, and verification state.
src/main/java/com/emsminiproject/Employee/management/system/entity/User.java - Employee
src/main/java/com/emsminiproject/Employee/management/system/entity/Employee.java - MySQL Database · JPA durable storage.
Other components
- Spring Boot Application · Starts the backend runtime.
src/main/java/com/emsminiproject/Employee/management/system/EmployeeManagementSystemApplication.java - Runtime Properties · Provides database and SMTP settings.
src/main/resources/application.properties - SMTP Server
Connections 21
- Spring Boot Application → Runtime Properties: loads
- Spring Boot Application → Security Config: initializes
- Security Config → User Controller: protects
- Security Config → Employee Controller: authorizes · Applies admin versus employee access.
- User Controller → Registration & OTP DTOs: accepts
- User Controller → User Service: registration
- User Controller → OTP Service: verify/login
- Employee Controller → Employee Service: CRUD
- User Service → User Repository: persists accounts
- OTP Service → OTP Generator: generates
- OTP Service → Email Service: sends OTP
- OTP Service → User Repository: validates activation
- Employee Service → Employee Repository: manages records
- User Repository → User Account: maps
- Employee Repository → Employee: maps
- User Repository → MySQL Database: JPA
- Employee Repository → MySQL Database: JPA
- Email Service → SMTP Server: SMTP
- User Service → Global Exception Handler: domain failures
- OTP Service → Global Exception Handler: OTP failures
- Employee Service → Global Exception Handler: domain failures