Thanks to visit codestin.com
Credit goes to github.com

Skip to content

devarifkhan/microservices_and_distributed_systems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ—οΈ Microservices & Distributed Systems

A comprehensive microservices architecture built with Spring Boot, featuring service discovery, message queuing, distributed tracing, and containerization.

πŸ›οΈ Architecture Overview

Architecture Diagram

πŸš€ Services

Core Microservices

  • πŸ‘€ Customer Service - Port 8080
  • πŸ›‘οΈ Fraud Detection Service - Port 8081
  • πŸ“§ Notification Service - Port 8082

Infrastructure Services

  • 🎯 Eureka Server - Service Discovery (Port 8761)
  • πŸšͺ API Gateway - Spring Cloud Gateway (Port 8080)
  • βš™οΈ Config Server - Centralized Configuration (Port 8888)

πŸ› οΈ Technology Stack

Component Technology
Framework Spring Boot 2.5.7
Language Java 17
Database PostgreSQL
Message Broker RabbitMQ
Service Discovery Netflix Eureka
API Gateway Spring Cloud Gateway
Containerization Docker
Distributed Tracing Zipkin + Sleuth
Build Tool Maven

πŸ—„οΈ Database Configuration

Database Credentials:
  Username: devarifkhan
  Password: password
  Database: mds
  Port: 5433 (local) / 5432 (docker)

πŸš€ Quick Start

Prerequisites

  • Java 17+
  • Maven 3.6+
  • Docker & Docker Compose
  • PostgreSQL

1. Clone Repository

git clone <repository-url>
cd microservices_and_distributed_systems

2. Build All Services

mvn clean install

3. Start Infrastructure (Docker)

docker-compose up -d postgres rabbitmq zipkin

4. Start Services

# Start Eureka Server
cd eureka-server && mvn spring-boot:run

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

# Start API Gateway
cd apigw && mvn spring-boot:run

# Start Core Services
cd customer && mvn spring-boot:run
cd fraud && mvn spring-boot:run  
cd notification && mvn spring-boot:run

🐳 Docker Deployment

Build Images

mvn clean package -Pbuild-docker-image

Run with Docker Compose

docker-compose up

πŸ“‘ Service Endpoints

Service Local URL Docker URL
Eureka Dashboard http://localhost:8761 http://eureka-server:8761
API Gateway http://localhost:8080 http://apigw:8080
Customer API http://localhost:8080/customer http://customer:8080
Fraud API http://localhost:8080/fraud http://fraud:8081
Zipkin UI http://localhost:9411 http://zipkin:9411

πŸ”§ Configuration Profiles

Each service supports multiple profiles:

  • default - Local development
  • docker - Docker container deployment
  • kube - Kubernetes deployment

πŸ“¨ Message Queue Architecture

RabbitMQ Configuration

Exchanges:
  - internal.exchange (Topic)

Queues:
  - notification.queue

Routing Keys:
  - internal.notification.routing-key

Message Flow

  1. Customer Service β†’ Publishes events β†’ Exchange
  2. Fraud Service β†’ Publishes events β†’ Exchange
  3. Exchange β†’ Routes messages β†’ Notification Queue
  4. Notification Service β†’ Consumes messages β†’ Sends notifications

πŸ” Distributed Tracing

All services integrate with Zipkin via Spring Cloud Sleuth:

  • Automatic trace generation
  • Cross-service correlation
  • Performance monitoring
  • Request flow visualization

πŸ›‘οΈ Security Features

  • API Key Authentication via API Gateway
  • Rate Limiting and throttling
  • SSL/TLS encryption
  • JWT Token validation
  • OAuth 2.0 authorization

πŸ“Š Monitoring & Observability

  • Health Checks - Spring Boot Actuator
  • Metrics Collection - Micrometer
  • Distributed Tracing - Zipkin + Sleuth
  • Centralized Logging - ELK Stack ready

πŸ—οΈ Project Structure

microservices_and_distributed_systems/
β”œβ”€β”€ customer/           # Customer microservice
β”œβ”€β”€ fraud/             # Fraud detection service  
β”œβ”€β”€ notification/      # Notification service
β”œβ”€β”€ eureka-server/     # Service discovery
β”œβ”€β”€ apigw/            # API Gateway
β”œβ”€β”€ clients/          # Shared client libraries
β”œβ”€β”€ amqp/             # Message queue utilities
β”œβ”€β”€ k8s/              # Kubernetes manifests
β”œβ”€β”€ docker-compose.yml # Docker orchestration
└── pom.xml           # Parent POM

πŸ”„ Communication Patterns

Synchronous Communication

  • Customer β†’ Fraud (HTTP REST)
  • API Gateway β†’ All Services (HTTP REST)

Asynchronous Communication

  • Customer β†’ RabbitMQ β†’ Notification
  • Fraud β†’ RabbitMQ β†’ Notification

πŸš€ API Examples

Create Customer

curl -X POST http://localhost:8080/api/v1/customers \
  -H "Content-Type: application/json" \
  -d '{
    "firstName": "John",
    "lastName": "Doe", 
    "email": "[email protected]"
  }'

Check Fraud

curl -X GET http://localhost:8080/api/v1/fraud-check/1

πŸ› Troubleshooting

Common Issues

  1. Port Conflicts

    # Check port usage
    netstat -tulpn | grep :8080
  2. Database Connection

    # Test PostgreSQL connection
    psql -h localhost -p 5433 -U devarifkhan -d mds
  3. Service Discovery

πŸ“ˆ Performance Tuning

JVM Options

-Xms512m -Xmx1024m
-XX:+UseG1GC
-XX:MaxGCPauseMillis=200

Database Optimization

spring:
  datasource:
    hikari:
      maximum-pool-size: 20
      minimum-idle: 5

🀝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

πŸ“„ License

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


⭐ Star this repository if you find it helpful!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors