Skip to content

vishtechie07/ecommerce-platform-spring-boot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Ecommerce Platform

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.

πŸš€ Features

  • 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

πŸ› οΈ Technology Stack

Backend

  • 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

Frontend

  • TypeScript - Type-safe JavaScript development
  • HTML5/CSS3 - Modern web standards
  • Vanilla JavaScript - No framework dependencies

πŸ“‹ Prerequisites

  • Java 17 or higher
  • Maven 3.6 or higher
  • Node.js 16 or higher (for TypeScript compilation)

πŸš€ Quick Start

1. Clone the Repository

git clone https://github.com/your-username/ecommerce-platform-spring-boot.git
cd ecommerce-platform

2. Build the Project

mvn clean compile

3. Run the Application

mvn spring-boot:run

The application will start on http://localhost:8086

4. Access the Application

πŸ—„οΈ Database Configuration

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-drop

πŸ” Default Credentials

Admin User:

  • Username: admin
  • Password: admin123
  • Email: admin@shophub.com

πŸ“š API Endpoints

Products

  • GET /api/products - Retrieve all products
  • GET /api/products/{id} - Retrieve product by ID

Cart

  • GET /api/cart - Get current cart
  • POST /api/cart/add - Add item to cart
  • PUT /api/cart/update - Update cart item quantity
  • DELETE /api/cart/remove/{itemId} - Remove item from cart

Checkout

  • POST /api/checkout/process - Process checkout and create order

πŸ—οΈ Project Structure

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

πŸ”§ Development

Adding New Features

  1. Create Entity: Add JPA entity in entity/ package
  2. Create Repository: Extend JpaRepository in repository/ package
  3. Create Service: Implement business logic in service/ package
  4. Create Controller: Add REST endpoints in controller/ package
  5. Update Tests: Add corresponding test cases

Code Style

  • Follow Java naming conventions
  • Use meaningful variable and method names
  • Add comprehensive JavaDoc comments
  • Implement proper error handling
  • Use logging for debugging and monitoring

πŸ§ͺ Testing

Backend Testing

# Run all tests
mvn test

# Run specific test class
mvn test -Dtest=ProductControllerTest

# Run with coverage
mvn jacoco:report

Frontend Testing

# Compile TypeScript
npx tsc

# Run in browser
# Open src/main/resources/static/index.html

πŸš€ Deployment

Production Build

mvn clean package -DskipTests

Docker Deployment

FROM openjdk:17-jre-slim
COPY target/ecommerce-platform-*.jar app.jar
EXPOSE 8086
ENTRYPOINT ["java", "-jar", "/app.jar"]

πŸ“Š Sample Data

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

πŸ” Troubleshooting

Common Issues

  1. Port Already in Use

    • Change port in application.properties
    • Kill existing process: netstat -ano | findstr :8086
  2. Database Connection Issues

    • Verify H2 console is accessible
    • Check application logs for errors
  3. Compilation Errors

    • Ensure Java 17 is installed: java -version
    • Clean and rebuild: mvn clean compile

Logs

Application logs are displayed in the console. Key log levels:

  • INFO: General application flow
  • DEBUG: Detailed debugging information
  • ERROR: Error conditions and exceptions

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ“ž Support

For questions and support:

  • Create an issue in the repository
  • Check the documentation

Built with ❀️ using Spring Boot and modern web technologies

About

A modern, scalable ecommerce platform built with Spring Boot 3.2, featuring RESTful APIs, shopping cart functionality, user management, and TypeScript frontend. Includes H2 database, Spring Security, comprehensive documentation, and sample data initialization for rapid development.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors