Skip to content

binistefano/microservices-starter-kit

Repository files navigation

Microservices Starter Kit

A modern, cloud-native distributed system architecture built with Java 21 and Spring Boot 3.5. This project demonstrates a production-ready microservices foundation featuring Service Discovery, API Gateway Routing, and Inter-service communication using OpenFeign.

Microservices Build Pipeline

Java Spring Boot Spring Cloud Docker

Architecture

The system follows the API Gateway pattern. All external traffic flows through the Gateway, which handles routing to internal services. Services register dynamically with Eureka and communicate synchronously via OpenFeign.

graph TD
    Client[External Client] -->|HTTP:8080| Gateway[API Gateway]
    
    subgraph Infrastructure
        Eureka[Eureka Discovery Server]
    end
    
    subgraph Microservices
        Gateway -->|Routes| User[User Service]
        Gateway -->|Routes| Product[Product Service]
        Gateway -->|Routes| Order[Order Service]
        
        User -.->|Register| Eureka
        Product -.->|Register| Eureka
        Order -.->|Register| Eureka
        Gateway -.->|Fetch Registry| Eureka
        
        Order -->|OpenFeign| Product
    end
Loading

Tech Stack

  • Core: Java 21, Spring Boot 3.5.8
  • Discovery: Netflix Eureka Server
  • Routing: Spring Cloud Gateway (Reactive)
  • Communication: OpenFeign (Declarative REST Client)
  • Database: H2 In-Memory (Simulating independent DBs per service)
  • Tooling: Maven (Multi-Module), Docker, Docker Compose, Lombok

Services

Service Port Description
Discovery Server 8761 Service Registry (Eureka)
API Gateway 8080 Single Entry Point & Routing
User Service 8081 User Management
Product Service 8082 Product Catalog Inventory
Order Service 8083 Order Processing (Calls Product Service)

Getting Started

Prerequisites

  • Java 21 SDK
  • Maven 3.8+
  • Docker (Optional)

Option 1: Run with Docker (Recommended)

This spins up the entire fleet (Registry, Gateway, and all Microservices) in orchestrated containers.

  docker-compose up -d --build

Option 2: Run Locally (Manual)

You must start the services in this specific order to ensure registration works immediately (though they are resilient enough to retry).

  1. Discovery Server:
    mvn spring-boot:run -pl discovery-server
  1. Product Service:
    mvn spring-boot:run -pl product-service
  1. User Service:
    mvn spring-boot:run -pl user-service
  1. Order Service:
    mvn spring-boot:run -pl order-service
  1. API Gateway:
    mvn spring-boot:run -pl api-gateway

API Endpoints (Via Gateway)

All requests should be sent to localhost:8080.

User Service

  • POST /api/users - Create User
  • GET /api/users - List Users

Product Service

  • POST /api/products - Create Product
  • GET /api/products - List Products
  • GET /api/products/{id} - Get Product by ID

Order Service

  • POST /api/orders - Place Order
    • Payload: { "productId": 1, "quantity": 5 }
    • Logic: Verifies product existence and price via OpenFeign before saving.

About

A simple, modern, cloud-native distributed system architecture

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors