This repository contains the backend implementation of the Cafe Management System built using Java and Spring Boot. It provides a robust API for managing cafe-related operations, including authentication, user management, and data handling. The project follows a well-structured package hierarchy and integrates Spring Security with JWT authentication.
βοΈ User Authentication & Authorization (JWT-based)
βοΈ Secure API Endpoints with Role-Based Access Control
βοΈ Database Integration with MySQL
βοΈ Modular and Clean Code Structure
βοΈ RESTful API Design
βοΈ Sends mail to registered users using JavaMailSender
βοΈ Only Admin can change the user status (active/inactive)
βοΈ All Admins receive an email notification when an admin updates a userβs status
βοΈ Generates a PDF bill for purchased products, including name, category, quantity, price, subtotal & total price
βοΈ PDF bill contains user details (name, contact, email, payment method) and a Thank You note
βοΈ Forgot Password functionality β sends reset password mail to the registered user
- Java
- Spring Boot 3.x
- Spring Security 6
- Maven
- MySQL
- Git & GitHub
- Spring Boot Starter Web β For building RESTful web applications
- Spring Boot Starter Security β For implementing authentication & authorization
- Spring Boot Starter Data JPA β For database interactions using MySQL
- Spring Boot Starter Mail β For sending emails using JavaMailSender
- Spring Boot Starter Thymeleaf β For generating PDF files
- Spring Boot Starter Validation β For handling validation of request data
This project implements JWT (JSON Web Token) authentication using Spring Security.
- The
JWT
package contains utility classes for generating, validating, and parsing JWT tokens. - It ensures secure access to API endpoints by restricting unauthorized requests.
-
JwtUtil.java β Utility class for JWT operations:
- Generates, extracts, and validates JWT tokens to ensure secure authentication.
- Retrieves claims such as username and expiration details from tokens.
- Checks for token expiration and ensures validity.
-
JwtFilter.java β Handles JWT-based authentication:
- Intercepts HTTP requests to extract and validate JWT tokens.
- If the token is valid, sets authentication in the security context.
- Provides methods to check user roles and retrieve the current user.
-
CustomerUserDetailsService.java β Implements user authentication:
- Loads user details from the database during authentication.
- Retrieves and provides user-specific data for security processing.
-
SecurityConfig.java β Configures security settings:
- Defines JWT authentication filter and request authorization rules.
- Manages password encoding, authentication manager, and security filter chain.
/login
β Authenticate and login user/signup
β Register new users/forgot-password
β Sends password reset email using JavaMailSender
- Get dashboard details (categories, products, bills)
/update
β Update user details/change-password
β Change user password
- Get all registered users with their status (active/inactive)
POST
Add new categoryGET
Get all categoriesPUT
Update category
POST
Add new productGET
Get all productsGET
Get products by category (only available products)GET
Get product by IDPUT
Update productPUT
Update product statusDELETE
Delete product by ID
POST
Generate billGET
Get bills by usernamePOST
Get PDF bill by UUIDDELETE
Delete bill by ID (different from UUID)
π inn.cafe
βββ π¦ constants # Contains application-wide constants
βββ π dao # Data Access Objects (Repositories for database interactions)
βββ π JWT # Handles JWT authentication & token management
βββ π¦ POJO # Plain Old Java Objects (Models representing database entities)
βββ π rest # Controller layer (Handles API requests)
βββ βοΈ restImpl # Implementation of REST APIs
βββ π§ service # Service interfaces (Business logic layer)
βββ ποΈ serviceImpl # Implementation of service interfaces
βββ π οΈ utils # Utility classes (Helper methods, validations, etc.)
βββ π¦ wrapper # Custom response wrappers for API responses
π resources
βββ π application.properties # Spring Boot configuration file (Database, JWT settings, etc.)
git clone https://github.com/tushar-swarnkar/cafe-management-system.git
cd cafe-management-system
- Update
application.properties
with your MySQL database credentials.
mvn clean install
mvn spring-boot:run