Skip to content

Chandu0501/spring-boot-microservices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot Microservices Architecture

A production-ready microservices application demonstrating modern backend architecture patterns with Java 17, Spring Boot 3, Docker, and Kubernetes.

Java Spring Boot Docker Kubernetes CI/CD

Architecture Overview

                                    +------------------+
                                    |   Config Server  |
                                    |   (Port 8888)    |
                                    +--------+---------+
                                             |
+----------+    +---------------+    +-------v--------+    +------------------+
|  Client  +--->+ API Gateway   +--->+ Service        +--->+ Order Service    |
|          |    | (Port 8080)   |    | Discovery      |    | (Port 8081)      |
+----------+    +-------+-------+    | (Eureka 8761)  |    +--------+---------+
                        |            +-------+---------+             |
                        |                    |              +--------v---------+
                        |                    +------------->+ Inventory Service|
                        |                    |              | (Port 8082)      |
                        |                    |              +------------------+
                        |                    |
                        |                    +------------->+ Notification Svc |
                        |                                   | (Port 8083)      |
                        |                                   +------------------+
                        |
                        +---> PostgreSQL | MongoDB | Redis | Kafka

Services

Service Description Port Tech
API Gateway Routes requests, rate limiting, authentication 8080 Spring Cloud Gateway
Service Discovery Service registration and discovery 8761 Netflix Eureka
Config Server Centralized configuration management 8888 Spring Cloud Config
Order Service Order creation, processing, and management 8081 Spring Boot, PostgreSQL, Kafka
Inventory Service Stock management, availability checks 8082 Spring Boot, MySQL, Redis
Notification Service Event-driven notifications (email, SMS) 8083 Spring Boot, Kafka

Key Features

  • Microservices Architecture - Loosely coupled services with clear domain boundaries
  • API Gateway - Centralized routing, rate limiting, JWT authentication
  • Service Discovery - Dynamic service registration with Netflix Eureka
  • Centralized Configuration - Spring Cloud Config Server with Git-backed configs
  • Event-Driven Communication - Kafka for asynchronous inter-service messaging
  • Circuit Breaker - Resilience4j for fault tolerance and fallback mechanisms
  • Distributed Tracing - Zipkin and Micrometer for request tracing across services
  • Database per Service - PostgreSQL, MySQL, MongoDB for polyglot persistence
  • Caching - Redis for inventory lookups and session management
  • Containerized - Docker Compose for local development, Kubernetes for production
  • CI/CD - GitHub Actions with automated testing, scanning, and deployment
  • Testing - JUnit 5, Mockito, Testcontainers for integration tests

Tech Stack

  • Language: Java 17
  • Framework: Spring Boot 3.2, Spring Cloud 2023.x
  • Databases: PostgreSQL, MySQL, MongoDB, Redis
  • Messaging: Apache Kafka
  • Testing: JUnit 5, Mockito, Testcontainers
  • Build: Maven
  • Containerization: Docker, Docker Compose
  • Orchestration: Kubernetes, Helm Charts
  • CI/CD: GitHub Actions
  • Monitoring: Prometheus, Grafana, Zipkin

Getting Started

Prerequisites

  • Java 17+
  • Maven 3.8+
  • Docker & Docker Compose

Run Locally with Docker Compose

# Clone the repository
git clone https://github.com/Chandu0501/spring-boot-microservices.git
cd spring-boot-microservices

# Start all services
docker-compose up -d

# Verify services are running
curl http://localhost:8761  # Eureka Dashboard
curl http://localhost:8080/api/orders  # API Gateway -> Order Service

Run Individual Services

# Start Config Server first
cd config-server && mvn spring-boot:run

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

# Start business services
cd order-service && mvn spring-boot:run
cd inventory-service && mvn spring-boot:run

Run Tests

# Run all tests
mvn clean test

# Run with coverage report
mvn clean verify jacoco:report

API Endpoints

Order Service

Method Endpoint Description
POST /api/orders Create a new order
GET /api/orders/{id} Get order by ID
GET /api/orders List all orders (paginated)
PUT /api/orders/{id}/status Update order status
DELETE /api/orders/{id} Cancel an order

Inventory Service

Method Endpoint Description
GET /api/inventory/{sku} Check stock availability
PUT /api/inventory/{sku} Update stock quantity
POST /api/inventory Add new inventory item
GET /api/inventory/low-stock Get low stock alerts

Deployment

Kubernetes (Production)

# Apply Kubernetes manifests
kubectl apply -f k8s/namespace.yaml
kubectl apply -f k8s/configmaps/
kubectl apply -f k8s/deployments/
kubectl apply -f k8s/services/

Project Structure

spring-boot-microservices/
├── api-gateway/              # API Gateway (Spring Cloud Gateway)
├── service-discovery/        # Eureka Server
├── config-server/            # Spring Cloud Config
├── order-service/            # Order management microservice
├── inventory-service/        # Inventory management microservice
├── notification-service/     # Event-driven notification service
├── docker-compose.yml        # Local development environment
├── k8s/                      # Kubernetes deployment manifests
└── .github/workflows/        # CI/CD pipeline definitions

Monitoring

Access monitoring tools after deployment:

Author

Sai Chandu Vallaboju

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors