Skip to content

ethannchen/springshop2

Repository files navigation

Spring Shop Microservices

A comprehensive e-commerce microservices architecture built with Spring Boot, Spring Cloud, and modern cloud-native technologies.

🏗️ Architecture Overview

This project implements a microservices architecture for an e-commerce platform with the following components:

Core Services

  • Product Service - Manages product catalog and inventory
  • Inventory Service - Handles stock management and availability
  • Order Service - Processes customer orders and orchestrates transactions
  • Notification Service - Sends email notifications for order confirmations

Infrastructure Services

  • Service Discovery - Eureka server for service registration and discovery
  • API Gateway - Spring Cloud Gateway for routing and load balancing
  • Config Server - Centralized configuration management
  • Common Library - Shared DTOs, events, and utilities

External Dependencies

  • MongoDB - Document database for product catalog
  • PostgreSQL - Relational database for orders and inventory
  • Apache Kafka - Event streaming for asynchronous communication
  • Prometheus - Metrics collection and monitoring
  • Grafana - Visualization and alerting

🚀 Technologies Used

  • Java 21 - Programming language
  • Spring Boot 3.4.4 - Application framework
  • Spring Cloud 2024.0.0 - Microservices toolkit
  • Spring Data JPA/MongoDB - Data access layer
  • Spring Cloud Gateway - API gateway
  • Netflix Eureka - Service discovery
  • Apache Kafka - Event streaming
  • Resilience4j - Circuit breaker and fault tolerance
  • MapStruct - Object mapping
  • Docker & Docker Compose - Containerization
  • Prometheus & Grafana - Monitoring and observability

📋 Prerequisites

  • Java 21 or higher
  • Maven 3.8+
  • Docker and Docker Compose
  • Git

🛠️ Getting Started

1. Clone the Repository

cd spring-shop-microservices

2. Environment Setup

Create a .env file in the root directory:

# Database Configuration
MONGO_USERNAME=mongodb
MONGO_PASSWORD=mongodb
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres

# Email Configuration (for notifications)
MAIL_HOST=sandbox.smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=your_username
MAIL_PASSWORD=your_password

# Config Server (optional)
CONFIG_GIT_URI=https://github.com/yourusername/spring-shop-config.git
CONFIG_GIT_BRANCH=main

# Monitoring
GRAFANA_ADMIN_USER=admin
GRAFANA_ADMIN_PASSWORD=admin

3. Build the Application

mvn clean package -DskipTests

4. Start with Docker Compose

docker-compose up -d

This will start all services including:

  • Infrastructure services (MongoDB, PostgreSQL, Kafka, Zookeeper)
  • Application services (all microservices)
  • Monitoring stack (Prometheus, Grafana)

5. Verify Services

Check that all services are running:

docker-compose ps

Access the applications:

📊 Service Ports

Service Port Purpose
API Gateway 8080 Main entry point
Product Service 8081 Product management
Inventory Service 8082 Stock management
Order Service 8083 Order processing
Notification Service 8084 Email notifications
Service Discovery 8761 Eureka server
Config Server 8888 Configuration management
Prometheus 9090 Metrics collection
Grafana 3000 Monitoring dashboard

About

A comprehensive e-commerce microservices architecture

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors