Skip to content

jorneycr/Spring-Microservices-Order-System

Repository files navigation

Spring Microservices Order System

Order management system built with Spring Boot, microservices, and hexagonal architecture.

πŸ—οΈ Architecture

This project implements a microservices architecture with the following components:

  • Service Discovery (Eureka): Service registration and discovery
  • API Gateway: Single entry point for all services
  • Config Server: Centralized configuration
  • User Service: User management
  • Product Service: Product management
  • Order Service: Order management

Hexagonal Architecture

Each microservice follows the hexagonal architecture pattern (ports and adapters):

β”œβ”€β”€ domain/              # Pure business logic
β”‚   β”œβ”€β”€ model/          # Entities and Value Objects
β”‚   β”œβ”€β”€ service/        # Domain services
β”‚   └── event/          # Domain events
β”œβ”€β”€ application/        # Use cases
β”‚   β”œβ”€β”€ port/
β”‚   β”‚   β”œβ”€β”€ in/        # Input ports (interfaces)
β”‚   β”‚   └── out/       # Output ports (interfaces)
β”‚   └── service/       # Use case implementation
└── infrastructure/     # Adapters
    β”œβ”€β”€ adapter/
    β”‚   β”œβ”€β”€ in/        # Input adapters (REST, etc.)
    β”‚   └── out/       # Output adapters (DB, messaging)
    └── config/        # Spring configuration

πŸ› οΈ Technologies

  • Java 17
  • Spring Boot 3.2.2
  • Spring Cloud 2023.0.0
  • Oracle Database 21c
  • RabbitMQ 3.12
  • Maven
  • Docker & Docker Compose

πŸ“‹ Prerequisites

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

πŸš€ Quick Start

1. Clone the repository

git clone <repository-url>
cd spring-microservices-order-system

2. Build the project

mvn clean install

3. Start infrastructure with Docker

docker-compose up -d oracle-db rabbitmq

Wait a few minutes for Oracle DB to be fully initialized.

4. Start services

Option A: With Docker Compose (Recommended)

docker-compose up -d

Option B: Manually

# Service Discovery
cd service-discovery
mvn spring-boot:run

# Config Server (in another terminal)
cd config-server
mvn spring-boot:run

# User Service (in another terminal)
cd user-service
mvn spring-boot:run

# Product Service (in another terminal)
cd product-service
mvn spring-boot:run

# Order Service (in another terminal)
cd order-service
mvn spring-boot:run

# API Gateway (in another terminal)
cd api-gateway
mvn spring-boot:run

πŸ”— Endpoints

πŸ“š API Documentation

Once the services are started, access the Swagger documentation:

πŸ§ͺ Testing

Run unit tests

mvn clean test

Run integration tests

mvn clean verify

Code coverage

mvn clean test jacoco:report

Reports are generated in target/site/jacoco/index.html for each module.

πŸ“¦ Project Structure

spring-microservices-order-system/
β”œβ”€β”€ api-gateway/              # Spring Cloud Gateway
β”œβ”€β”€ service-discovery/        # Eureka Server
β”œβ”€β”€ config-server/           # Spring Cloud Config
β”œβ”€β”€ user-service/            # User microservice
β”œβ”€β”€ product-service/         # Product microservice
β”œβ”€β”€ order-service/           # Order microservice
β”œβ”€β”€ common/                  # Shared libraries
β”œβ”€β”€ docker-compose.yml       # Docker configuration
β”œβ”€β”€ pom.xml                  # Parent POM
└── README.md

πŸ”§ Configuration

Oracle Database

Default credentials:

  • Host: localhost:1521
  • SID: XEPDB1
  • User: system
  • Password: Oracle123

RabbitMQ

Default credentials:

  • Host: localhost:5672
  • User: admin
  • Password: admin123

Version Control

The project includes .gitignore files configured in:

  • Project root: Global configuration for the entire monorepo
  • Each microservice: Specific configuration for each module

The .gitignore files exclude:

  • Maven build files (target/, *.class)
  • IDE configuration files (.idea/, *.iml, .vscode/)
  • Logs and temporary files (*.log, *.tmp, *.bak)
  • Local configuration files (application-local.yml)
  • Operating system files (.DS_Store, Thumbs.db)

πŸ› Troubleshooting

Oracle DB won't start

docker-compose logs oracle-db
docker-compose restart oracle-db

Port already in use

# View processes using the port
netstat -ano | findstr :8080

# Change the port in application.yml or stop the process

Services don't register in Eureka

  • Verify that Eureka is running at http://localhost:8761
  • Check service logs
  • Verify eureka.client.serviceUrl.defaultZone configuration

πŸ“ License

This project is licensed under the MIT License.

πŸ‘₯ Contributing

Contributions are welcome. Please:

  1. Fork the project
  2. Create a branch for your feature (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“§ Contact

For questions or suggestions, please open an issue in the repository.

About

Order management system built with Spring Boot, microservices and hexagonal architecture.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors