Skip to content

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. πŸš€

Notifications You must be signed in to change notification settings

tushar-swarnkar/cafe-management-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

28 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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

πŸ“‚ 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

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

mvn clean install
mvn spring-boot:run

4️⃣ API Testing

Use Postman or any API testing tool to test the endpoints.

About

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. πŸš€

Topics

Resources

Stars

Watchers

Forks

Languages