This is a microservices-based online e-commerce application built with Spring Boot, Spring Cloud, and other modern technologies. The application provides a complete e-commerce solution with features like product browsing, cart management, order processing, payment integration, and more.
The application is built using a microservices architecture, which consists of the following services:
- User Service: Manages user profiles, authentication, and authorization
- Product Service: Handles product catalog, categories, and inventory
- Cart Service: Manages e-commerce carts
- Order Service: Processes and tracks orders
- Payment Service: Handles payment processing
- Notification Service: Sends notifications to users
- Auth Service: Manages authentication and authorization with Keycloak integration
- Gateway Service: API Gateway for routing requests to appropriate services
- Config Server: Centralized configuration management
- Discovery Service: Service discovery with Eureka
- Java 24: Latest Java version for optimal performance
- Spring Boot 3.4.2: Modern framework for building Java applications
- Spring Cloud 2024.0.0: Tools for building cloud-native applications
- Spring Security: Authentication and authorization
- Keycloak: Identity and access management
- Kafka: Event-driven communication between services
- Redis: Caching and session management
- PostgreSQL: Primary database for most services
- MongoDB: Alternative database for certain services requiring flexible schema
- Resilience4j: Circuit breaking and fault tolerance
- MapStruct: Object mapping between DTOs and domain models
- Micrometer & Zipkin: Distributed tracing
- ELK Stack: Centralized logging
- Prometheus & Grafana: Monitoring and visualization
- Docker & Docker Compose: Containerization and orchestration
- JUnit & Mockito: Testing framework
This application follows Domain Driven Design principles:
- Bounded Contexts: Each microservice represents a bounded context
- Entities & Value Objects: Core domain objects
- Aggregates: Ensuring data consistency
- Domain Events: Communicating between bounded contexts
- Repositories: Data access abstraction
- Domain Services: Complex business logic spanning multiple entities
Security is implemented using:
- Spring Security: For authentication and authorization
- Keycloak: Identity and Access Management
- JWT: Token-based authentication
- OAuth2: Authorization framework
- Role-Based Access Control: Different access levels for different user roles
- User registration and login
- Profile management
- Address management
- Role-based access control
- Product catalog
- Categories and subcategories
- Product search and filtering
- Product reviews and ratings
- Add products to cart
- View and edit cart
- Checkout process
- Order tracking
- Payment processing
- Inventory management
- Order management
- User management
- Analytics and reporting
- Java 24
- Docker and Docker Compose
- Maven
- Clone the repository
- Start the infrastructure services:
docker-compose up -d - Build the application:
mvn clean install - Start the services in order:
- Config Server
- Discovery Service
- Auth Service
- Other services
Simply run:
docker-compose up -d
This will start all services and required infrastructure.
API documentation is available through Swagger UI at:
http://localhost:9090/swagger-ui.html
- Recommendation Engine: Personalized product recommendations
- Internationalization: Multi-language support
- Multi-tenancy: Support for multiple shops on the same platform
- Advanced Analytics: AI-powered sales predictions
- Mobile App Integration: APIs for mobile applications
- Content Management: Rich content for products
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
The application supports two profiles:
- default: Uses localhost for all service connections (development on local machine)
- dev: Uses Docker container names for service discovery (running in Docker)
You can start the application in two ways:
./start-services.shThis will:
- Start infrastructure services (Postgres, MongoDB, Redis, Kafka) using Docker
- Start all microservices locally with the default profile
- Use local application.properties files for configuration
./start-services.sh devThis will start all services with the dev profile.
./start-services.sh dev trueThis will:
- Start all services (infrastructure and application) using Docker Compose
- Configure them to use the dev profile
./start-services.sh default false trueThis will:
- Start infrastructure services (Postgres, MongoDB, Redis, Kafka) using Docker
- Start the Config Server
- Start all other services configured to use the centralized configuration
You can combine all options:
# Format: ./start-services.sh [profile] [use-docker] [use-config-server]
./start-services.sh dev true trueThis will:
- Start all services using Docker
- Configure them to use the dev profile
- Use the Config Server for configuration
To stop all services:
./stop-services.shIf you started with Docker for all services:
./stop-services.sh true- API Gateway: http://localhost:8765
- Discovery Service Dashboard: http://localhost:8761
- Swagger API Documentation: http://localhost:8765/swagger-ui.html
Each service has its own configuration in:
-
Individual service configuration:
src/main/resources/application.properties- Default configurationsrc/main/resources/application-dev.properties- Docker environment configuration
-
Centralized configuration (Config Server):
config-server/src/main/resources/config/<service-name>.yml- Contains both default and dev profile configurations
The Config Server provides centralized configuration for all services. Each service can load its configuration from the Config Server when spring.cloud.config.enabled=true is set.
To use the Config Server:
- Make sure the Config Server is running:
cd config-server && java -jar target/config-server-0.0.1-SNAPSHOT.jar - Start services with Config Server enabled:
java -Dspring.cloud.config.enabled=true -jar <service-jar>
You can see the configurations at:
- Config Server API: http://localhost:8888//default
- Config Server API (dev profile): http://localhost:8888//dev
To add a new service:
- Create a new Spring Boot project
- Add the necessary dependencies for Spring Cloud
- Create both application.properties and application-dev.properties
- Update the docker-compose.yml file if needed