# mudigal-technologies/microservices-sample architecture

> Architecture diagram of the GitHub repository mudigal-technologies/microservices-sample, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mudigal-technologies/microservices-sample
- Repository: https://github.com/mudigal-technologies/microservices-sample

## Overview

##### Main Components

a. Client Layer:
- Web Application (Angular-based frontend)
- Connection to API Gateway

b. API Gateway Layer:
- Netflix Zuul as the API Gateway
- Routing paths (/service-one/**, /service-two/**)

c. Service Layer:
- Service One (Spring Boot microservice)
- Service Two (Spring Boot microservice)
- Each with their respective databases

d. Infrastructure Components:
- Consul (Service Registration & Discovery)
- RabbitMQ (Asynchronous Communication)
- ELK Stack (Elasticsearch, Logstash, Kibana)
- Weave Scope (Monitoring)

**[Client Layer]**
- ↓
**[API Gateway Layer]**
- ↓
**[Service Registry Layer]**
- ↓
**[Service Layer]**
- ↓
**[Data Layer]**

##### Connection Types

- Log streaming (wavy lines)

##### Specific Implementation Details

a. Following flows:
- Service registration flow with Consul
- Service discovery through API Gateway
- RabbitMQ message exchange between services
- Log aggregation flow to ELK stack

b. Key components with their ports:
- API Gateway (8080)
- Consul UI (8500)
- RabbitMQ (15672)
- Kibana (5601)
- Elasticsearch (9200)

##### Additional Elements

Include:
- Docker container boundaries
- Service names and versions
- Database types (MySQL for service-two)
- Key configuration endpoints
- Health check paths
- Swagger API documentation endpoints

##### Notes Section

Callouts for:
- Scalability points
- Resilience patterns
- Security boundaries
- Monitoring points
- Log collection paths

- The microservices architecture pattern
- Service independence
- Asynchronous communication
- Centralized logging
- Service discovery mechanism
- Container-based deployment

Remember to maintain a balance between detail and clarity, focusing on the architectural decisions while avoiding overwhelming implementation details.

This system design should clearly show how the application achieves its microservices goals through service independence, scalability, and resilience, while maintaining observability through the integrated monitoring and logging solutions.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef frontend fill:#4299e1,stroke:#2b6cb0,stroke-width:2px,color:white
    classDef gateway fill:#48bb78,stroke:#2f855a,stroke-width:2px,color:white
    classDef service fill:#38b2ac,stroke:#2c7a7b,stroke-width:2px,color:white
    classDef database fill:#ecc94b,stroke:#b7791f,stroke-width:2px
    classDef infrastructure fill:#a0aec0,stroke:#718096,stroke-width:2px
    classDef messaging fill:#9f7aea,stroke:#6b46c1,stroke-width:2px
    classDef monitoring fill:#ed8936,stroke:#c05621,stroke-width:2px
    
    %% Client Layer
    subgraph ClientLayer
        WebApp["Web Application\n(Angular)"]:::frontend
    end
    click WebApp "https://github.com/mudigal-technologies/microservices-sample/tree/master/web-application/src/app"

    %% API Gateway Layer
    subgraph GatewayLayer
        APIGateway["API Gateway\n(Netflix Zuul):8080"]:::gateway
        GatewayController["Gateway Controller"]:::gateway
    end
    click APIGateway "https://github.com/mudigal-technologies/microservices-sample/blob/master/api-gateway/src/main/java/com/mudigal/ApiGatewayApplication.java"
    click GatewayController "https://github.com/mudigal-technologies/microservices-sample/blob/master/api-gateway/src/main/java/com/mudigal/controller/ApiGatewayMainController.java"

    %% Service Registry Layer
    subgraph RegistryLayer
        Consul["Consul\nService Registry:8500"]:::infrastructure
    end

    %% Service Layer
    subgraph ServiceLayer
        ServiceOne["Service One\n(Spring Boot)"]:::service
        ServiceTwo["Service Two\n(Spring Boot)"]:::service
        S1Queue["Service One\nRabbitMQ Bean"]:::messaging
        S2Queue["Service Two\nRabbitMQ Bean"]:::messaging
        S1Swagger["Service One\nSwagger"]:::service
        S2Swagger["Service Two\nSwagger"]:::service
    end
    click ServiceOne "https://github.com/mudigal-technologies/microservices-sample/blob/master/service-one/src/main/java/com/mudigal/one/ServiceOneApplication.java"
    click ServiceTwo "https://github.com/mudigal-technologies/microservices-sample/blob/master/service-two/src/main/java/com/mudigal/two/ServiceTwoApplication.java"
    click S1Queue "https://github.com/mudigal-technologies/microservices-sample/blob/master/service-one/src/main/java/com/mudigal/one/component/queue/ServiceOneRabbitMQBean.java"
    click S2Queue "https://github.com/mudigal-technologies/microservices-sample/blob/master/service-two/src/main/java/com/mudigal/two/component/queue/ServiceTwoRabbitMQBean.java"
    click S1Swagger "https://github.com/mudigal-technologies/microservices-sample/blob/master/service-one/src/main/java/com/mudigal/one/config/SwaggerConfig.java"
    click S2Swagger "https://github.com/mudigal-technologies/microservices-sample/blob/master/service-two/src/main/java/com/mudigal/two/config/Swagger3Config.java"

    %% Infrastructure Layer
    subgraph InfraLayer
        RabbitMQ["RabbitMQ:15672"]:::messaging
        ELK["ELK Stack"]:::monitoring
        Elasticsearch["Elasticsearch:9200"]:::monitoring
        Logstash["Logstash"]:::monitoring
        Kibana["Kibana:5601"]:::monitoring
        WeaveScope["Weave Scope\nMonitoring"]:::monitoring
    end
    click RabbitMQ "https://github.com/mudigal-technologies/microservices-sample/blob/master/build/docker/docker-compose.yml"

    %% Data Layer
    subgraph DataLayer
        DB1[("Service One DB")]:::database
        DB2[("Service Two DB\n(MySQL)")]:::database
    end

    %% Connections
    WebApp --> APIGateway
    APIGateway --> GatewayController
    GatewayController --> ServiceOne & ServiceTwo
    ServiceOne & ServiceTwo -.-> Consul
    ServiceOne --> S1Queue
    ServiceTwo --> S2Queue
    S1Queue & S2Queue <--> RabbitMQ
    ServiceOne --> DB1
    ServiceTwo --> DB2
    ServiceOne & ServiceTwo --> S1Swagger & S2Swagger
    ServiceOne & ServiceTwo & APIGateway ~~~ Logstash
    Logstash --> Elasticsearch
    Elasticsearch --> Kibana
    
    %% Legend
    subgraph Legend
        L1["Frontend Components"]:::frontend
        L2["Gateway Components"]:::gateway
        L3["Service Components"]:::service
        L4[("Database Components")]:::database
        L5["Infrastructure"]:::infrastructure
        L6["Messaging"]:::messaging
        L7["Monitoring"]:::monitoring
    end
```
