GitHunt
YO

YOUHAD08/product-springboot-mvc-app

A Spring Boot MVC web application for managing products with secure login, product search, and CRUD functionality using Thymeleaf, Spring Security, and JPA.

๐Ÿ›’ Product-Spring-MVC - Product Management Web App

A complete Spring Boot MVC application that allows users to manage products securely with authentication, using Spring Boot, Spring Security, Thymeleaf, and Spring Data JPA for database interactions.


๐Ÿ”ง Features

  • โœ… User login with Spring Security
  • ๐Ÿ“‹ View list of all products
  • โž• Add a new product (secured)
  • ๐Ÿ”’ Access control with role-based authorization
  • ๐Ÿ–ผ๏ธ Responsive web UI using Thymeleaf templates
  • ๐Ÿ’พ Persistent data storage via JPA (H2/MySQL/PostgreSQL adaptable)

๐Ÿง  Application Architecture

๐Ÿ› ๏ธ Tech Stack

  • Java 17+
  • Spring Boot
  • Spring MVC
  • Spring Data JPA
  • Spring Security
  • Thymeleaf
  • Maven

๐Ÿ“ Project Structure

product-spring-mcv/
โ”‚
โ”œโ”€โ”€ .idea/
โ”œโ”€โ”€ .mvn/
โ”‚
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main/
โ”‚   โ”‚   โ”œโ”€โ”€ java/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ma.youhad.productspringmcv/
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ entities/
โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ Product.java
โ”‚   โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ repository/
โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ ProductRepository.java
โ”‚   โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ security/
โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ SecurityConfig.java
โ”‚   โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ web/
โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ ProductController.java
โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ ProductSpringMcvApplication.java
โ”‚   โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”‚
โ”‚   โ”‚   โ””โ”€โ”€ resources/
โ”‚   โ”‚       โ”œโ”€โ”€ static/
โ”‚   โ”‚       โ””โ”€โ”€ templates/
โ”‚   โ”‚           โ”œโ”€โ”€ layout1.html
โ”‚   โ”‚           โ”œโ”€โ”€ login.html
โ”‚   โ”‚           โ”œโ”€โ”€ new-product.html
โ”‚   โ”‚           โ”œโ”€โ”€ notAuthorized.html
โ”‚   โ”‚           โ””โ”€โ”€ products.html
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ test/
โ”‚
โ”œโ”€โ”€ application.properties
โ”œโ”€โ”€ target/
โ”œโ”€โ”€ .gitattributes
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ HELP.md
โ”œโ”€โ”€ mvnw
โ”œโ”€โ”€ mvnw.cmd
โ”œโ”€โ”€ pom.xml
โ””โ”€โ”€ README.md

๐Ÿ“ธ UI Preview

๐Ÿ” Login Page

Login Page

๐Ÿ›๏ธ Products List

Products List

โž• Add / Update Product Page

Add Product

๐Ÿ” Product Search Feature

Search Product

โš™๏ธ Configuration (application.properties)

spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.h2.console.enabled=true
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update  

๐Ÿ” Security Overview

  • Spring Security is configured in SecurityConfig.java
  • Basic login authentication
  • Only authenticated users (ADMIN) can access protected routes like adding products
  • Default user/password can be customized in config or initialized in code

๐Ÿ“ฆ Dependencies (from pom.xml)

  • Spring Boot Starter Web
  • Spring Boot Starter Thymeleaf
  • Spring Boot Starter Data JPA
  • Spring Boot Starter Security
  • H2 Database (can be replaced with MySQL/PostgreSQL)
  • Spring Boot DevTools

๐Ÿ”Œ Endpoints

URL Description Access
/login Login page Public
/products View product list Authenticated
/products/new Add new product Authenticated
/notAuthorized Shown when user lacks permission Authenticated

โœ… Future Improvements

  • Add user registration and roles (admin/user)
  • Upload product images
  • Improve UI with Bootstrap
  • Add pagination/search features
  • Deploy to cloud (Heroku, AWS, etc.)

โœ… Author

YOUHAD AYOUB