https://github.com/saadamir1/spring-boot-product-management
Spring Boot CRUD app for managing products, customers, and expiring food items with authentication using JPA, Thymeleaf, and Spring Security.
https://github.com/saadamir1/spring-boot-product-management
crud java jpa maven product-management spring-boot spring-mvc spring-security thymeleaf
Last synced: 4 days ago
JSON representation
Spring Boot CRUD app for managing products, customers, and expiring food items with authentication using JPA, Thymeleaf, and Spring Security.
- Host: GitHub
- URL: https://github.com/saadamir1/spring-boot-product-management
- Owner: saadamir1
- Created: 2025-07-09T13:33:23.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-07-14T16:58:20.000Z (3 months ago)
- Last Synced: 2025-07-28T22:45:17.870Z (3 months ago)
- Topics: crud, java, jpa, maven, product-management, spring-boot, spring-mvc, spring-security, thymeleaf
- Language: HTML
- Homepage:
- Size: 765 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Spring Boot Product Management System
A Spring Boot application for managing products, customers, and food items with expiration tracking. Implements CRUD operations with Spring MVC, JPA/Hibernate, Spring Security, and Thymeleaf templates.
## ๐ Features
- **Product Management**: CRUD operations with SKU tracking, description, category, and pricing
- **Customer Management**: Manage customer information with embedded address using JPA `@Embeddable`
- **Food Expiration Tracking**: Monitor product expiration dates with custom repository queries for expired items
- **User Authentication**: Spring Security with role-based access control
- **REST + Web UI**: RESTful API endpoints (JSON) alongside Thymeleaf-rendered web pages
- **Custom Queries**: JPA repository methods for specific data filtering## ๐ ๏ธ Tech Stack
- **Framework**: Spring Boot 2.4.0
- **Language**: Java 17
- **Database**: H2 (in-memory) / SQLite
- **ORM**: Hibernate JPA
- **Security**: Spring Security
- **Template Engine**: Thymeleaf
- **Build Tool**: Maven## โ ๏ธ Compatibility Notice
This project uses:
- **Spring Boot 2.4.0**
- **Java 17**
- **Maven 3.8+**> โ ๏ธ **Do not use Java 21 or Spring Boot 3+ with this version**.
> It may lead to compatibility issues (e.g., deprecated APIs, failing tests, unsupported plugin goals).> โ If you're using Java 21, either:
> - Downgrade your Java version to 17, or
> - Upgrade Spring Boot and dependencies throughout the project (requires refactoring and test fixes).## ๐งช Known Test Issue
The file `CrudTutorialApplicationTests.java` is **disabled** due to class compatibility issues caused by version mismatches.
If you'd like to enable tests again, ensure Spring Boot and your JDK versions are compatible and refactor accordingly.If you face build errors:
```bash
# Skip tests during build
mvn clean install -DskipTests
```## ๐ Project Structure
```
src/main/java/com/example/CRUDTutorial/
โโโ Controller/ # REST & MVC controllers
โโโ Model/ # JPA entities
โโโ Repository/ # Spring Data JPA repositories
โโโ Service/ # Business logic layer
```## ๐๏ธ Key Entities
**Product**
- SKU, description, category, and price
- Standard CRUD operations**Customer**
- Business information with embedded address
- Uses JPA `@Embeddable` pattern for address fields**FoodItem**
- Product with expiration date
- Custom repository method to find expired items**User**
- Authentication and role management
- Password encryption## ๐ Getting Started
### Prerequisites
- Java 17
- Maven 3.8+### Quick Start
```bash
git clone https://github.com/saadamir1/spring-boot-product-management.git
cd spring-boot-product-management
mvn spring-boot:run
```Access at: `http://localhost:8080`
## ๐ก API Endpoints
### Products
| Method | Endpoint | Description | Response |
|--------|----------|-------------|----------|
| `GET` | `/products/` | List all products | HTML |
| `POST` | `/products/Save` | Create product | Redirect |
| `GET` | `/products/findByID/{id}` | Get product by ID | JSON |
| `GET` | `/products/expiredProducts` | View expired items | HTML |### Customers
| Method | Endpoint | Description | Response |
|--------|----------|-------------|----------|
| `GET` | `/customers/` | List all customers | HTML |
| `POST` | `/customers/saveCustomer` | Create customer | Redirect |
| `GET` | `/customers/findCustomerByID/{id}` | Get customer by ID | JSON |## ๐ฏ Key Implementation Details
### JPA Features Used
- `@Embeddable` for address components (demonstrates value object pattern)
- Custom repository queries using method naming conventions
- Entity relationships and mappings
- Transaction management with `@Transactional`### Architecture
- MVC pattern with Controller-Service-Repository layers
- Spring Data JPA for data access
- Dual interface: Thymeleaf views + JSON REST endpoints
- Dependency injection throughout### Security
- Spring Security with user authentication
- Role-based access control
- Password encryption (BCrypt)
- Custom login pages## ๐ก๏ธ Security Configuration
Basic Spring Security setup with:
- User authentication
- Role management
- Encrypted passwords
- Custom login/logout
- CSRF protection## ๐ Deployment
**Development**:
```bash
mvn spring-boot:run
```**Production**:
```bash
mvn clean package -DskipTests
java -jar target/CRUDTutorial-0.0.1-SNAPSHOT.jar
```## ๐ What This Project Covers
- Spring Boot application setup
- RESTful API design
- JPA/Hibernate ORM usage
- Spring Security basics
- MVC pattern implementation
- Custom repository methods
- Thymeleaf templating
- Embedded entities pattern## ๐ Contact
Saad Amir - saadamir070@gmail.com
Project Link: [https://github.com/saadamir1/spring-boot-product-management](https://github.com/saadamir1/spring-boot-product-management)
---
*A Spring Boot project demonstrating CRUD operations, JPA relationships, custom repository queries, and Spring Security integration.*