An open API service indexing awesome lists of open source software.

https://github.com/amid68/java_microservice_infrastructure

A complete DevOps pipeline demonstration featuring a Java Spring Boot microservice with automated CI/CD, containerization, and infrastructure as code.
https://github.com/amid68/java_microservice_infrastructure

Last synced: 6 months ago
JSON representation

A complete DevOps pipeline demonstration featuring a Java Spring Boot microservice with automated CI/CD, containerization, and infrastructure as code.

Awesome Lists containing this project

README

          

# Java Microservice Infrastructure

[![Build Status](https://img.shields.io/badge/build-passing-brightgreen)]()
[![Coverage](https://img.shields.io/badge/coverage-85%25-green)]()
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Java Version](https://img.shields.io/badge/Java-17-blue)]()

A production-ready demonstration of modern DevOps practices featuring a Java Spring Boot microservice with complete CI/CD automation, infrastructure as code, and container orchestration.

## ๐Ÿ—๏ธ Architecture Overview

This project demonstrates a complete DevOps pipeline for a user management microservice, showcasing industry best practices for:

- **Continuous Integration/Continuous Deployment (CI/CD)**
- **Infrastructure as Code (IaC)**
- **Container Orchestration**
- **Monitoring and Observability**
- **Security and Compliance**

## ๐Ÿš€ Technology Stack

| Category | Technologies |
|----------|-------------|
| **Application** | Java 17, Spring Boot 3.x, PostgreSQL |
| **Containerization** | Docker, Docker Compose |
| **CI/CD** | Jenkins, GitHub Actions |
| **Infrastructure** | Terraform, AWS (ECS, RDS, VPC) |
| **Monitoring** | Prometheus, Grafana, ELK Stack |
| **Security** | OWASP ZAP, Trivy, SonarQube |

## ๐Ÿ“‹ Features

### Application Features
- โœ… RESTful API for user management
- โœ… JWT-based authentication
- โœ… PostgreSQL database integration
- โœ… Comprehensive test coverage (>85%)
- โœ… OpenAPI 3.0 documentation
- โœ… Health checks and metrics endpoints

### DevOps Features
- โœ… Automated CI/CD pipeline
- โœ… Infrastructure as Code with Terraform
- โœ… Multi-environment deployments (dev/staging/prod)
- โœ… Container security scanning
- โœ… Blue-green deployment strategy
- โœ… Automated rollback capabilities
- โœ… Centralized logging and monitoring

## ๐Ÿƒโ€โ™‚๏ธ Quick Start

### Prerequisites

- Docker and Docker Compose
- AWS CLI configured
- Terraform >= 1.0
- Java 17
- Maven 3.8+

### Local Development

```bash
# Clone the repository
git clone https://github.com/Amid68/java_microservice_infrastructure.git
cd java_microservice_infrastructure

# Start local environment
docker-compose up -d

# Run the application
cd app
./mvnw spring-boot:run

# API will be available at http://localhost:8080
# Swagger UI: http://localhost:8080/swagger-ui.html
```

### Infrastructure Deployment

```bash
# Initialize Terraform
cd infrastructure/terraform/environments/dev
terraform init

# Plan deployment
terraform plan

# Apply infrastructure
terraform apply
```

## ๐Ÿ“Š CI/CD Pipeline

The pipeline includes the following stages:

1. **Code Quality** - Static analysis with SonarQube
2. **Testing** - Unit tests, integration tests, and contract tests
3. **Security Scanning** - Dependency and container vulnerability scans
4. **Build & Package** - Maven build and Docker image creation
5. **Deploy to Staging** - Automated deployment to staging environment
6. **Integration Tests** - End-to-end testing in staging
7. **Production Deployment** - Blue-green deployment with manual approval

## ๐ŸŒ Infrastructure

### AWS Architecture

```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Application โ”‚ โ”‚ Load โ”‚ โ”‚ Database โ”‚
โ”‚ Load Balancer โ”‚โ—„โ”€โ”€โ”€โ”ค Balancer โ”œโ”€โ”€โ”€โ–บโ”‚ (RDS) โ”‚
โ”‚ (ALB) โ”‚ โ”‚ โ”‚ โ”‚ PostgreSQL โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ โ”‚ โ”‚
โ–ผ โ–ผ โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ ECS Cluster โ”‚ โ”‚ VPC & Subnets โ”‚ โ”‚ Security โ”‚
โ”‚ (Fargate) โ”‚ โ”‚ Public/Private โ”‚ โ”‚ Groups โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

### Key Infrastructure Components

- **VPC** with public and private subnets across multiple AZs
- **ECS Fargate** for container orchestration
- **RDS PostgreSQL** with automated backups
- **Application Load Balancer** with SSL termination
- **CloudWatch** for logging and monitoring
- **IAM roles** following least privilege principle

## ๐Ÿ“ˆ Monitoring & Observability

### Metrics & Monitoring
- Application metrics via Micrometer
- Infrastructure monitoring with CloudWatch
- Custom business metrics dashboard
- Automated alerting for critical issues

### Logging
- Centralized logging with ELK stack
- Structured JSON logging
- Log aggregation across all services
- Log retention policies

## ๐Ÿ”’ Security

### Security Measures Implemented
- Container image vulnerability scanning
- Dependency vulnerability checks
- OWASP security testing
- Secrets management with AWS Secrets Manager
- Network security with security groups
- Encrypted data at rest and in transit

## ๐Ÿงช Testing Strategy

### Test Types
- **Unit Tests** - 90%+ coverage requirement
- **Integration Tests** - Database and external service integration
- **Contract Tests** - API contract validation
- **End-to-End Tests** - Full user journey testing
- **Performance Tests** - Load and stress testing

### Test Automation
- Automated test execution in CI pipeline
- Test results reporting and trending
- Quality gates for deployment progression

## ๐Ÿ“ Project Structure

```
โ”œโ”€โ”€ app/ # Java Spring Boot application
โ”œโ”€โ”€ infrastructure/ # Terraform IaC modules
โ”œโ”€โ”€ ci-cd/ # CI/CD pipeline configurations
โ”œโ”€โ”€ monitoring/ # Monitoring and alerting setup
โ”œโ”€โ”€ scripts/ # Automation scripts
โ””โ”€โ”€ docs/ # Project documentation
```

## ๐Ÿ”ง Environment Configuration

| Environment | Purpose | Infrastructure |
|-------------|---------|----------------|
| **Development** | Local development and testing | Docker Compose |
| **Staging** | Pre-production testing | AWS ECS (1 instance) |
| **Production** | Live environment | AWS ECS (3+ instances) |

## ๐Ÿ“š Documentation

- [API Documentation](docs/api-documentation.md)
- [Deployment Guide](docs/deployment-guide.md)
- [Architecture Decision Records](docs/adr/)
- [Runbooks](docs/runbooks/)

## ๐Ÿค Contributing

This project follows standard Git workflow practices:

1. Create feature branch from `main`
2. Implement changes with tests
3. Ensure all CI checks pass
4. Create pull request for review
5. Deploy after approval

## ๐Ÿ“„ License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## ๐Ÿ“ž Contact

For questions about this project's implementation or DevOps practices demonstrated:

- [LinkedIn](https://www.linkedin.com/in/ameed-othman/)
- Email: [othman.ameed@gmail.com]