Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tushar-swarnkar/cafe-management-system
A backend service for a Cafe Management System built with Java, Spring Boot, and MySQL. It provides JWT-based authentication, role-based access control, email notifications, and PDF bill generation. The system allows admins to manage users, categories, products, and orders efficiently while ensuring secure access and smooth operations. π
https://github.com/tushar-swarnkar/cafe-management-system
backend-services java jpa-hibernate jwt-authentication jwt-token maven-pom mysql rest-api spring-boot spring-mvc spring-security web-application
Last synced: 3 days ago
JSON representation
A backend service for a Cafe Management System built with Java, Spring Boot, and MySQL. It provides JWT-based authentication, role-based access control, email notifications, and PDF bill generation. The system allows admins to manage users, categories, products, and orders efficiently while ensuring secure access and smooth operations. π
- Host: GitHub
- URL: https://github.com/tushar-swarnkar/cafe-management-system
- Owner: tushar-swarnkar
- Created: 2025-02-02T10:20:07.000Z (8 days ago)
- Default Branch: main
- Last Pushed: 2025-02-06T19:51:34.000Z (4 days ago)
- Last Synced: 2025-02-06T20:34:54.659Z (4 days ago)
- Topics: backend-services, java, jpa-hibernate, jwt-authentication, jwt-token, maven-pom, mysql, rest-api, spring-boot, spring-mvc, spring-security, web-application
- Language: Java
- Homepage:
- Size: 50.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Cafe Management System (Backend)
## π Project Overview
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.## π Features
βοΈ 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## π οΈ Tech Stack
- **Java**
- **Spring Boot 3.x**
- **Spring Security 6**
- **Maven**
- **MySQL**
- **Git & GitHub**### ποΈ Spring Boot Dependencies
- **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## π Authentication & Security
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.### π JWT Package Overview
- **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.## π API ENDPOINT GUIDE
### APIs without security authentication:
- **`/login`** β Authenticate and login user
- **`/signup`** β Register new users
- **`/forgot-password`** β Sends password reset email using JavaMailSender### APIs with security authentication & validation:
#### π DASHBOARD:
- Get **dashboard details** (categories, products, bills)#### π€ USER:
- **`/update`** β Update user details
- **`/change-password`** β Change user password#### π οΈ ADMIN:
- Get all registered users with their status (active/inactive)#### π CATEGORY:
- **`POST`** Add new category
- **`GET`** Get all categories
- **`PUT`** Update category#### π·οΈ PRODUCT:
- **`POST`** Add new product
- **`GET`** Get all products
- **`GET`** Get products by category (only available products)
- **`GET`** Get product by ID
- **`PUT`** Update product
- **`PUT`** Update product status
- **`DELETE`** Delete product by ID#### π§Ύ BILL:
- **`POST`** Generate bill
- **`GET`** Get bills by username
- **`POST`** Get PDF bill by UUID
- **`DELETE`** Delete bill by ID (different from UUID)---
## π Package Structure
```yaml
π 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.)
```## π How to Run the Project
### 1οΈβ£ Clone the Repository
```sh
git clone https://github.com/tushar-swarnkar/cafe-management-system.git
cd cafe-management-system
```### 2οΈβ£ Configure Database
- Update `application.properties` with your **MySQL database credentials**.### 3οΈβ£ Build and Run the Project
```sh
mvn clean install
mvn spring-boot:run
```### 4οΈβ£ API Testing
Use **Postman** or any API testing tool to test the endpoints.
---