This is a full-stack e-commerce web application I built using Spring Boot and modern web technologies. It includes user authentication, a product catalog, shopping cart functionality, and order processing - basically everything you'd expect from an online store!
- Product Catalog: Users can browse and search through different products organized by categories
- User Authentication: People can sign up and log in securely using JWT tokens
- Shopping Cart: Add items to cart, remove them, and keep track of what you want to buy
- Order Management: Complete the checkout process and track your orders
- Responsive Design: Works on both desktop and mobile devices
- RESTful API: Built a proper REST API with all the right HTTP methods and status codes
- JWT Security: Used JSON Web Tokens for secure authentication
- Session Management: Your shopping cart stays even if you close the browser
- Input Validation: Made sure users can't break things with bad input
- Error Handling: When something goes wrong, users get helpful error messages
- Java 17: The main programming language
- Spring Boot 3.3.2: Makes building Java web apps way easier
- Spring Security: Handles all the authentication stuff
- Spring Data JPA: Makes database operations simple
- H2 Database: An in-memory database that's perfect for development
- Maven: Manages dependencies and builds the project
- JWT (JSON Web Tokens): How users stay logged in
- HTML5/CSS3: The basics for structure and styling
- JavaScript (ES6+): Makes the website interactive
- Font Awesome: For nice-looking icons
- CSS Grid/Flexbox: Modern layout techniques for responsive design
Here's how I structured the project - it follows standard Spring Boot conventions:
src/
├── main/
│ ├── java/com/example/ecommerce/
│ │ ├── ECommercePlatformApplication.java
│ │ │
│ │ ├── application/
│ │ │ ├── service/
│ │ │ │ ├── ProductService.java
│ │ │ │ ├── UserService.java
│ │ │ │ ├── CartService.java
│ │ │ │ └── OrderService.java
│ │ │ └── session/
│ │ │ └── CartStoragePort.java
│ │ │
│ │ ├── domain/
│ │ │ ├── model/
│ │ │ │ ├── User.java
│ │ │ │ ├── Product.java
│ │ │ │ ├── Order.java
│ │ │ │ └── OrderItem.java
│ │ │ ├── exception/
│ │ │ │ ├── ProductNotFoundException.java
│ │ │ │ └── InsufficientStockException.java
│ │ │ └── repository/
│ │ │ ├── UserRepository.java
│ │ │ ├── ProductRepository.java
│ │ │ └── OrderRepository.java
│ │ │
│ │ ├── infrastructure/
│ │ │ ├── bootstrap/
│ │ │ │ └── ProductDataInitializer.java
│ │ │ ├── config/
│ │ │ │ └── SecurityConfig.java
│ │ │ ├── security/
│ │ │ │ ├── JwtUtil.java
│ │ │ │ ├── JwtFilter.java
│ │ │ │ └── UserDetailsServiceImpl.java
│ │ │ └── session/
│ │ │ ├── CartStorageFactory.java
│ │ │ └── HttpSessionCartStorageFactory.java
│ │ │
│ │ └── web/
│ │ ├── auth/
│ │ │ ├── AuthController.java
│ │ │ └── dto/
│ │ │ ├── LoginRequestDto.java
│ │ │ ├── RegisterRequestDto.java
│ │ │ └── AuthResponseDto.java
│ │ │
│ │ ├── cart/
│ │ │ ├── CartController.java
│ │ │ └── dto/
│ │ │ └── CartItemDto.java
│ │ │
│ │ ├── order/
│ │ │ ├── CheckoutController.java
│ │ │ ├── OrderController.java
│ │ │ └── dto/
│ │ │ ├── CheckoutRequestDto.java
│ │ │ └── OrderResponseDto.java
│ │ │
│ │ ├── product/
│ │ │ └── ProductController.java
│ │ │
│ │ ├── health/
│ │ │ └── HealthController.java
│ │ │
│ │ └── exception/
│ │ └── GlobalExceptionHandler.java
│ │
│ └── resources/
│ ├── application.properties
│ └── static/
│ ├── html/
│ ├── css/
│ ├── js/
│ ├── assets/
│ └── images/
│
└── test/
└── java/com/example/ecommerce/
├── application/service/
├── domain/model/
├── integration/
└── web/health/
POST /api/auth/register- Sign up new usersPOST /api/auth/login- Log users inPOST /api/auth/password-reset-request- Request password reset (basic implementation)
GET /api/products- Get all the products to display
GET /api/cart- See what's in your cartPOST /api/cart/add- Add something to your cartPOST /api/cart/remove- Remove something from your cartPOST /api/cart/clear- Empty the entire cart
POST /api/checkout- Actually buy the stuff in your cartGET /api/checkout/orders- See your order history
- Java 17 or newer
- Maven 3.6 or newer
- Git (to clone the repo)
-
Get the code
git clone <repository-url> cd ecommerce-platform
-
Build everything
mvn clean install
-
Start the server
mvn spring-boot:run
-
Check it out Open your browser and go to
http://localhost:8080
-
Build the Docker image
docker build -t ecommerce-platform . -
Run it
docker run -p 8080:8080 ecommerce-platform
I used H2 database because it's super easy for development - it runs in memory so you don't need to install anything. You can find the settings in application.properties:
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.h2.console.enabled=trueThe JWT token stuff can be configured here:
jwt.secret=yourSecretKeyHereMakeItAtLeast32CharactersLong
jwt.expiration=86400000server.port=8080- Go to the registration page
- Fill out your info (first name, last name, email, password)
- Log in with what you just created
- The app saves a JWT token in your browser so you stay logged in
- Look at products on the main page
- Use the search bar or click on categories to find stuff
- Click "Add to Cart" on things you want
- Check your cart and adjust quantities if needed
- Hit checkout when you're ready to buy (you'll need to be logged in)
- Complete the checkout process
- You'll see a confirmation page
- Check your order history by clicking on your user icon
- Has an ID, email (has to be unique), and encrypted password
- Stores first name and last name
- Has roles for permissions (like admin vs regular user)
- Connected to their order history
- Basic info like ID, name, and description
- Price stored as BigDecimal (better for money calculations)
- Has a category and image URL
- Tracks how many are in stock
- Includes validation to make sure data is good
- Gets a unique ID and order number
- Links to the user who placed it and when
- Status tracking (PENDING, PAID, SHIPPED, DELIVERED, CANCELLED)
- Stores shipping address and shipping costs
- Contains all the items that were ordered
- Used BCrypt to hash passwords (way more secure than storing plain text)
- JWT tokens for staying logged in across requests
- Protected endpoints check if your token is valid
- Different user roles can access different features
- Checkout requires you to be logged in
- Shopping cart works with browser sessions
- Server checks all input to prevent bad data
- Email format validation
- Password requirements (length, complexity)
- Protection against XSS attacks
mvn testmvn clean package -DskipTestsWhen running locally, you can check out the H2 database at: http://localhost:8080/h2-console
- Switch from H2 to a real database (PostgreSQL or MySQL)
- Use proper JWT secret keys (not the demo ones)
- Set up HTTPS/SSL certificates
- Configure proper logging
- Add monitoring and health checks
export JWT_SECRET=your-production-secret-key
export DATABASE_URL=your-production-database-url
export SERVER_PORT=8080If you want to help improve this project:
- Fork the repository
- Create a new branch for your feature (
git checkout -b feature/cool-new-thing) - Make your changes and commit them (
git commit -am 'Add cool new thing') - Push to your branch (
git push origin feature/cool-new-thing) - Create a Pull Request
This project is open source - feel free to use it for learning or your own projects!
If something isn't working or you have questions, feel free to create an issue in the repository. I'm still learning too, so any feedback is appreciated!