Thanks to visit codestin.com
Credit goes to github.com

Skip to content

πŸ›’ A feature-rich E-commerce platform built with a Modular Monolith architecture, showcasing scalable design and robust testing.

Notifications You must be signed in to change notification settings

IWKMS99/E-commerce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

48 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Advanced E-commerce Platform: A Modular Monolith

Java CI with Gradle

This project serves as a comprehensive blueprint for building modern, scalable, and maintainable backend systems. It's a fully functional e-commerce platform MVP meticulously designed with a modular monolith architecture. This pragmatic approach offers the development velocity of a traditional monolith while laying a solid foundation for a future-proof, seamless evolution into a microservices-based system.

The platform implements the entire customer lifecycle, from user authentication and product browsing to order processing and payment simulation, all while ensuring data integrity and high performance through a thoughtful technology stack.


High-Level Architecture


✨ Key Features & Concepts Demonstrated

  • Event-Driven Core: Modules communicate asynchronously via an internal Spring ApplicationEventBus. This decouples domains (e.g., Order service doesn't know about Inventory stock logic) and eliminates runtime dependencies.
  • Optimized Data Persistence: A strategic use of PostgreSQL for transactional, relational data (users, orders) and Redis for high-throughput, ephemeral data (shopping carts), ensuring both data integrity and performance.
  • Robust Security Model: End-to-end security with Spring Security, featuring JWT-based authentication and role-based authorization (USER/ADMIN) to protect sensitive endpoints.
  • Production-Grade Testing Strategy: A multi-layered testing approach ensures reliability:
    • Unit Tests (Mockito) for isolated business logic.
    • Integration Tests (MockMvc) for the API layer.
    • Data-Layer Tests (Testcontainers) for true-to-production database interactions.
    • Full Context Integration Tests to verify the event-driven flows across modules.
  • Automated & Reliable Development Pipeline: A complete CI/CD workflow using GitHub Actions automatically builds the project, runs the entire test suite, and provides immediate feedback, ensuring that the main branch is always stable.
  • Database Lifecycle Management: Schema changes are managed, versioned, and applied automatically and safely using Flyway.

πŸ› οΈ Technology Stack

Category Technology / Library Purpose
Core Framework Java 21, Spring Boot 3.5 Foundation for the entire application.
Data & Persistence Spring Data JPA, Hibernate, PostgreSQL Relational data storage and ORM.
In-Memory & Cache Spring Data Redis, Redis High-performance storage for user carts.
Security Spring Security, JSON Web Tokens (jjwt) Authentication, authorization, and securing API endpoints.
Database Mgmt Flyway Version-controlled database migrations.
API & Web Spring Web (MVC), RESTful Principles Exposing the application's functionality via a clean API.
DevOps & CI/CD Docker, Docker Compose, GitHub Actions Containerization, local environment setup, and automated CI pipeline.
Testing JUnit 5, Mockito, Testcontainers, MockMvc Ensuring code quality and reliability at all levels.
Utilities Lombok, MapStruct Reducing boilerplate code for entities and DTO mapping.

πŸš€ Getting Started

Prerequisites

  • Java 21 (or higher)
  • Docker & Docker Compose
  • An API client like Postman or curl.

Local Setup

  1. Clone the repository:

    git clone https://github.com/iwkms99/E-commerceMicroservicesPlatform.git
    cd E-commerceMicroservicesPlatform
  2. Launch infrastructure: This single command starts PostgreSQL and Redis containers with all the necessary configurations.

    docker-compose up -d
  3. Run the application: You can run the app from your favorite IDE by executing the main method in EcommerceApplication.java or via the Gradle wrapper.

    ./gradlew bootRun

    The server will start on http://localhost:8080.

Quick Test Drive with curl

  1. Register a user:

    curl -X POST http://localhost:8080/api/v1/users/register \
    -H "Content-Type: application/json" \
    -d '{"email":"[email protected]", "password":"password123", "firstName":"Test", "lastName":"User"}'
  2. Log in to get a token:

    TOKEN=$(curl -s -X POST http://localhost:8080/api/v1/auth/login \
    -H "Content-Type: application/json" \
    -d '{"email":"[email protected]", "password":"password123"}' | jq -r .token)
    
    echo "Your JWT is: $TOKEN"

    (Requires jq to be installed. Otherwise, copy the token manually from the response.)

  3. Get your user details using the token:

    curl -X GET http://localhost:8080/api/v1/users/me \
    -H "Authorization: Bearer $TOKEN"

πŸ—ΊοΈ Project Roadmap (Future Work)

This project provides a solid foundation. Here are some potential next steps to evolve it further:

  • Implement Compensating Transactions (Saga Pattern): Enhance reliability by creating compensating actions for failed events (e.g., automatically refunding a payment if stock reservation fails).
  • Extract First Microservice: Choose a module (e.g., User or Catalog) and extract it into a standalone Spring Boot service, replacing internal calls with REST or message queue communication.
  • Introduce a Message Broker: Replace the internal Spring Event Bus with a robust message broker like RabbitMQ or Kafka to prepare for a distributed environment.
  • Add Advanced Catalog Features: Implement full-text search with Elasticsearch and add filtering/pagination.
  • Containerize the Application: Write a Dockerfile for the application itself and orchestrate the entire stack with a production-ready docker-compose.yml.

This project was developed as a deep dive into modern software architecture and best practices. Feel free to explore, fork, and use it as a reference for your own work.

About

πŸ›’ A feature-rich E-commerce platform built with a Modular Monolith architecture, showcasing scalable design and robust testing.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages