# sannidhisriram-06/self-healing-microservice architecture

> Architecture diagram of the GitHub repository sannidhisriram-06/self-healing-microservice, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sannidhisriram-06/self-healing-microservice
- Repository: https://github.com/sannidhisriram-06/self-healing-microservice

## Overview

This repository is a Spring Boot microservice and its AWS deployment infrastructure, designed for health-based routing and recovery. The main request path is client → ALB → EC2-hosted container → Spring controller; separate health checks inform traffic routing, container status, and instance replacement, while CPU metrics drive scaling. Terraform defines the cloud resources, and the launch configuration pulls and runs the image from Docker Hub. The workflow and deployment details are documented in the README; sampled Java source confirms the application entry point and root handler.

Main entry points: [`terraform/compute.tf`](https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/terraform/compute.tf) (EC2 instances), [`terraform/alb.tf`](https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/terraform/alb.tf) (Application load balancer), [`Dockerfile`](https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/Dockerfile) (Service container), [`terraform/security.tf`](https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/terraform/security.tf) (Security groups)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_application["Spring Boot app"]
  node_controller["Root controller"]
  node_actuator["Actuator health<br/>[pom.xml]"]
end

subgraph group_runtime["Container Runtime"]
  node_dockerfile["Container definition"]
  node_dockerhub[("Docker Hub")]
  node_container["Service container"]
end

subgraph group_aws["AWS Infrastructure"]
  node_vpc["VPC and subnets<br/>[vpc.tf]"]
  node_security["Security groups<br/>[security.tf]"]
  node_loadbalancer["Application load balancer<br/>[alb.tf]"]
  node_targetgroup["Target group<br/>[alb.tf]"]
  node_instances["EC2 instances<br/>[compute.tf]"]
end

subgraph group_recovery["Health and Recovery"]
  node_autoscaling["Auto Scaling Group<br/>[compute.tf]"]
  node_scalingpolicy["CPU scaling policy<br/>[compute.tf]"]
end

node_client(("HTTP client"))

node_client -->|"sends requests"| node_loadbalancer
node_loadbalancer -->|"forwards traffic"| node_targetgroup
node_targetgroup -->|"routes requests"| node_instances
node_instances -->|"pulls image"| node_dockerhub
node_instances -->|"runs container"| node_container
node_container -->|"runs app"| node_application
node_application -->|"dispatches route"| node_controller
node_controller -->|"returns response"| node_client
node_loadbalancer -->|"checks health"| node_actuator
node_container -->|"polls health"| node_actuator
node_autoscaling -->|"reads health"| node_targetgroup
node_autoscaling -->|"replaces instances"| node_instances
node_autoscaling -->|"applies policy"| node_scalingpolicy
node_vpc -->|"hosts instances"| node_instances
node_security -->|"restricts access"| node_loadbalancer
node_security -->|"restricts access"| node_instances

click node_application "https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/src/main/java/com/sriram/selfhealing/SelfhealingApplication.java"
click node_controller "https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/src/main/java/com/sriram/selfhealing/HelloController.java"
click node_actuator "https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/pom.xml"
click node_dockerfile "https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/Dockerfile"
click node_container "https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/Dockerfile"
click node_vpc "https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/terraform/vpc.tf"
click node_security "https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/terraform/security.tf"
click node_loadbalancer "https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/terraform/alb.tf"
click node_targetgroup "https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/terraform/alb.tf"
click node_instances "https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/terraform/compute.tf"
click node_autoscaling "https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/terraform/compute.tf"
click node_scalingpolicy "https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/terraform/compute.tf"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_application,node_controller,node_actuator,node_client toneBlue
class node_dockerfile,node_dockerhub,node_container toneAmber
class node_vpc,node_security,node_loadbalancer,node_targetgroup,node_instances toneMint
class node_autoscaling,node_scalingpolicy toneRose
```

## Components

### Application

- [Spring Boot app](https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/src/main/java/com/sriram/selfhealing/SelfhealingApplication.java): `src/main/java/com/sriram/selfhealing/SelfhealingApplication.java`
- [Root controller](https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/src/main/java/com/sriram/selfhealing/HelloController.java): `src/main/java/com/sriram/selfhealing/HelloController.java`
- [Actuator health](https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/pom.xml): `pom.xml`

### Container Runtime

- [Container definition](https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/Dockerfile): `Dockerfile`
- **Docker Hub**
- [Service container](https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/Dockerfile): `Dockerfile`

### AWS Infrastructure

- [VPC and subnets](https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/terraform/vpc.tf): `terraform/vpc.tf`
- [Security groups](https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/terraform/security.tf): `terraform/security.tf`
- [Application load balancer](https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/terraform/alb.tf): `terraform/alb.tf`
- [Target group](https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/terraform/alb.tf): `terraform/alb.tf`
- [EC2 instances](https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/terraform/compute.tf): `terraform/compute.tf`

### Health and Recovery

- [Auto Scaling Group](https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/terraform/compute.tf): `terraform/compute.tf`
- [CPU scaling policy](https://github.com/sannidhisriram-06/self-healing-microservice/blob/main/terraform/compute.tf): `terraform/compute.tf`

### Other components

- **HTTP client**

## Connections

- HTTP client → Application load balancer: sends requests
- Application load balancer → Target group: forwards traffic
- Target group → EC2 instances: routes requests
- EC2 instances → Docker Hub: pulls image
- EC2 instances → Service container: runs container
- Service container → Spring Boot app: runs app
- Spring Boot app → Root controller: dispatches route
- Root controller → HTTP client: returns response
- Application load balancer → Actuator health: checks health
- Service container → Actuator health: polls health
- Auto Scaling Group → Target group: reads health
- Auto Scaling Group → EC2 instances: replaces instances
- Auto Scaling Group → CPU scaling policy: applies policy
- VPC and subnets → EC2 instances: hosts instances
- Security groups → Application load balancer: restricts access
- Security groups → EC2 instances: restricts access
