A modern, scalable ecommerce platform built with Spring Boot, featuring a RESTful API backend and a responsive frontend. This platform provides comprehensive product management, shopping cart functionality, and checkout processes.
- Product Management: Full CRUD operations for products with categories and inventory tracking
- Shopping Cart: Persistent cart functionality with item management
- User Management: Secure user authentication and authorization
- Checkout Process: Complete order processing workflow
- RESTful API: Well-documented REST endpoints for easy integration
- Database Initialization: Automatic sample data population for development
- Security: Spring Security integration with password encryption
- Frontend: Modern TypeScript-based web interface
- Java 17 - Modern Java features and performance
- Spring Boot 3.2.0 - Rapid application development framework
- Spring Data JPA - Data access layer with Hibernate
- Spring Security - Authentication and authorization
- H2 Database - In-memory database for development
- Maven - Dependency management and build tool
- Lombok - Reduces boilerplate code
- TypeScript - Type-safe JavaScript development
- HTML5/CSS3 - Modern web standards
- Vanilla JavaScript - No framework dependencies
- Java 17 or higher
- Maven 3.6 or higher
- Node.js 16 or higher (for TypeScript compilation)
git clone https://github.com/your-username/ecommerce-platform-spring-boot.git
cd ecommerce-platformmvn clean compilemvn spring-boot:runThe application will start on http://localhost:8086
- Main Application: http://localhost:8086
- H2 Database Console: http://localhost:8086/h2-console
- API Base URL: http://localhost:8086/api
The application uses H2 in-memory database with the following configuration:
# Database
spring.datasource.url=jdbc:h2:mem:ecommercedb
spring.datasource.username=SA
spring.datasource.password=
# H2 Console
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
# JPA
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.hibernate.ddl-auto=create-dropAdmin User:
- Username:
admin - Password:
admin123 - Email:
admin@shophub.com
GET /api/products- Retrieve all productsGET /api/products/{id}- Retrieve product by ID
GET /api/cart- Get current cartPOST /api/cart/add- Add item to cartPUT /api/cart/update- Update cart item quantityDELETE /api/cart/remove/{itemId}- Remove item from cart
POST /api/checkout/process- Process checkout and create order
ecommerce-platform/
βββ src/
β βββ main/
β β βββ java/com/ecommerce/platform/
β β β βββ config/ # Configuration classes
β β β βββ controller/ # REST controllers
β β β βββ dto/ # Data Transfer Objects
β β β βββ entity/ # JPA entities
β β β βββ repository/ # Data access layer
β β β βββ service/ # Business logic
β β β βββ EcommercePlatformApplication.java
β β βββ resources/
β β βββ static/ # Frontend assets
β β βββ application.properties
β βββ test/ # Test resources
βββ pom.xml # Maven configuration
βββ tsconfig.json # TypeScript configuration
βββ README.md # This file
- Create Entity: Add JPA entity in
entity/package - Create Repository: Extend JpaRepository in
repository/package - Create Service: Implement business logic in
service/package - Create Controller: Add REST endpoints in
controller/package - Update Tests: Add corresponding test cases
- Follow Java naming conventions
- Use meaningful variable and method names
- Add comprehensive JavaDoc comments
- Implement proper error handling
- Use logging for debugging and monitoring
# Run all tests
mvn test
# Run specific test class
mvn test -Dtest=ProductControllerTest
# Run with coverage
mvn jacoco:report# Compile TypeScript
npx tsc
# Run in browser
# Open src/main/resources/static/index.htmlmvn clean package -DskipTestsFROM openjdk:17-jre-slim
COPY target/ecommerce-platform-*.jar app.jar
EXPOSE 8086
ENTRYPOINT ["java", "-jar", "/app.jar"]The application automatically populates the database with:
-
20 Sample Products across multiple categories:
- Electronics (10 products)
- Clothing (3 products)
- Sports (3 products)
- Home & Garden (1 product)
- Beauty & Health (2 products)
- Books (1 product)
-
Default Admin User for system administration
-
Port Already in Use
- Change port in
application.properties - Kill existing process:
netstat -ano | findstr :8086
- Change port in
-
Database Connection Issues
- Verify H2 console is accessible
- Check application logs for errors
-
Compilation Errors
- Ensure Java 17 is installed:
java -version - Clean and rebuild:
mvn clean compile
- Ensure Java 17 is installed:
Application logs are displayed in the console. Key log levels:
INFO: General application flowDEBUG: Detailed debugging informationERROR: Error conditions and exceptions
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For questions and support:
- Create an issue in the repository
- Check the documentation
Built with β€οΈ using Spring Boot and modern web technologies