A simple e-commerce platform built with Java, Spring Boot, MySQL, and Thymeleaf. This application supports user registration and login, product catalog browsing, cart management, checkout, review posting, and order receipt generation.
- Java 17+
- Spring Boot
- MySQL (database)
- Thymeleaf (server-side templating)
- Maven (build tool)
- User registration and login
- Product catalog display
- Add to cart, view cart, and update cart
- Checkout with customer details and address validation
- View order receipt upon checkout
- Product and service review functionality
| HTTP Method | Path | Description | Controller |
|---|---|---|---|
| GET | / |
Show landing page | HomeController |
| GET | /home |
Show home page | HomeController |
| GET | /products |
List all products | ProductController |
| GET | /cart |
View cart | CartController |
| POST | /cart/add |
Add a product to cart | CartController |
| POST | /cart/remove |
Remove a product from cart | CartController |
| POST | /cart/checkout |
Proceed to checkout (redirects to /checkout) |
CartController |
| GET | /checkout |
Show checkout page | CheckoutController |
| POST | /checkout |
Submit checkout form, process and save order | CheckoutController |
| GET | /receipt/{orderId} |
Show the receipt page for a specific order | CheckoutController |
| GET | /register |
Display user registration form | UserController |
| POST | /register |
Submit registration data and create new user | UserController |
| GET | /login |
Show user login form | UserController |
| GET | /reviews |
List all product/service reviews | ReviewController |
| Layer | Description | Example Files |
|---|---|---|
| Controller | Handles web requests | CartController.java, ProductController.java, UserController.java |
| Service | Business logic and utilities | CartService.java, ProductService.java, etc. |
| Model | Data models/entities | User.java, Product.java, Cart.java |
| Repository | Spring Data JPA interfaces | UserRepository.java, ProductRepository.java |
| Templates | Front-end views | index.html, products.html, cart.html, register.html |
| Static | CSS, JS, images | static/ folder in resources |
- Java 17 or higher
- Maven 3.x
- MySQL 5.7/8.x
-
Clone the Repository
git clone https://github.com/sarankirthic/ecommerce.git cd ecommerce -
Configure MySQL Database
-
Create a database (e.g.,
ecom_db). -
Update
src/main/resources/application.propertieswith these settings:spring.datasource.url=jdbc:mysql://localhost:3306/ecom_db spring.datasource.username=YOUR_MYSQL_USER spring.datasource.password=YOUR_MYSQL_PASSWORD spring.jpa.hibernate.ddl-auto=update
-
Build and Run the Application
mvn spring-boot:run
-
Open in Browser
Navigate to http://localhost:8001/ for the home page.
- Homepage:
/or/home - Product Catalog:
/products - Cart:
/cart - Checkout:
/checkout - User Registration:
/register - User Login:
/login - View Reviews:
/reviews
PRs are welcome! For major changes, please open an issue first to discuss what you’d like to change.
This project is licensed under the MIT License.