# sachintha-dev/microservice-local-dev-env architecture

> Architecture diagram of the GitHub repository sachintha-dev/microservice-local-dev-env, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sachintha-dev/microservice-local-dev-env
- Repository: https://github.com/sachintha-dev/microservice-local-dev-env

## Overview

##### Main Components

A. Service Layer
- Three identical microservices (service-1, service-2, service-3)
- Each service contains:
- Auth API module
- Database connections (MongoDB & Prisma)
- RabbitMQ integration
- Middleware components
- Utility services

B. Infrastructure Layer
- Traefik (Reverse Proxy/Load Balancer)
- Observability Stack:
- Prometheus (Metrics)
- Grafana (Visualization)
- Loki (Logging)
- Tempo (Tracing)
- OpenTelemetry Collector
- Supporting Services:
- Dozzle (Log Viewer)
- cAdvisor
- Node Exporter

**┌─ Client Layer ─────────────────────────────┐**

- ┬───────────────────────┘
- ↓
**┌─ Gateway Layer ────────────────────────────┐**
- [Traefik Reverse Proxy]                   │
- ┬───────────┬───────────────────┘
- ↓           ↓
**┌─ Service Layer ──────────────────────────┐**
- ┌─────────┐  ┌─────────┐  ┌─────────┐   │
- Service 1│  │Service 2│  │Service 3│   │
- ┬────┘  └────┬────┘  └────┬────┘   │
- ┼───────────┼───────────┼──────────┘
- ↓           ↓           ↓
**┌─ Data Layer ────────────────────────────┐**
- [MongoDB]        [Prisma]               │
- ┘

**┌─ Observability Layer ──────────────────────┐**
- ┌─────────┐ ┌───────┐ ┌─────┐ ┌────────┐  │
- Prometheus│ │Grafana│ │Loki │ │Tempo   │  │
- ┘ └───────┘ └─────┘ └────────┘  │
- ┘

##### Detailed Component Breakdown

For each microservice, show internal structure:
**┌─ Microservice (1/2/3) ─────────────────┐**
- ┌─────────┐ ┌──────────┐ ┌──────────┐  │
- Auth API │ │Middleware│ │Utils     │  │
- ┘ └──────────┘ └──────────┘  │
- ┌─────────┐ ┌──────────┐              │
- Models   │ │Config    │              │
- ┘ └──────────┘              │
- ┘

##### Data Flow Indicators
- → Request flow
- ⇢ Event flow
- ⇢ Monitoring data flow

##### Additional Elements
- Port numbers for each service
- Environment indicators
- Volume mounts
- Configuration file references

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Layer"]
        Client_App[Client Applications]
    end

    subgraph Gateway["Gateway Layer"]
        Traefik["<img src='https://raw.githubusercontent.com/traefik/traefik/master/docs/content/assets/img/traefik.logo.png' width='40' /> Traefik"]:::infra
    end

    subgraph Services["Service Layer"]
        subgraph Service1["Service 1"]
            Auth1["<img src='https://www.svgrepo.com/show/353818/auth0.svg' width='20' /> Auth API"]:::service
            Middleware1["<img src='https://www.svgrepo.com/show/354107/middleware.svg' width='20' /> Middleware"]:::service
            Utils1["<img src='https://www.svgrepo.com/show/354202/postman.svg' width='20' /> Utils"]:::service
            Models1["<img src='https://www.svgrepo.com/show/373845/mongo.svg' width='20' /> Models"]:::service
            Config1["<img src='https://www.svgrepo.com/show/373427/config.svg' width='20' /> Config"]:::service
            App1["<img src='https://www.svgrepo.com/show/354118/nodejs.svg' width='20' /> Application"]:::service
        end

        subgraph Service2["Service 2"]
            Auth2["<img src='https://www.svgrepo.com/show/353818/auth0.svg' width='20' /> Auth API"]:::service
            Middleware2["<img src='https://www.svgrepo.com/show/354107/middleware.svg' width='20' /> Middleware"]:::service
            Utils2["<img src='https://www.svgrepo.com/show/354202/postman.svg' width='20' /> Utils"]:::service
            Models2["<img src='https://www.svgrepo.com/show/373845/mongo.svg' width='20' /> Models"]:::service
            Config2["<img src='https://www.svgrepo.com/show/373427/config.svg' width='20' /> Config"]:::service
            App2["<img src='https://www.svgrepo.com/show/354118/nodejs.svg' width='20' /> Application"]:::service
        end

        subgraph Service3["Service 3"]
            Auth3["<img src='https://www.svgrepo.com/show/353818/auth0.svg' width='20' /> Auth API"]:::service
            Middleware3["<img src='https://www.svgrepo.com/show/354107/middleware.svg' width='20' /> Middleware"]:::service
            Utils3["<img src='https://www.svgrepo.com/show/354202/postman.svg' width='20' /> Utils"]:::service
            Models3["<img src='https://www.svgrepo.com/show/373845/mongo.svg' width='20' /> Models"]:::service
            Config3["<img src='https://www.svgrepo.com/show/373427/config.svg' width='20' /> Config"]:::service
            App3["<img src='https://www.svgrepo.com/show/354118/nodejs.svg' width='20' /> Application"]:::service
        end
    end

    subgraph Data["Data Layer"]
        MongoDB["<img src='https://www.svgrepo.com/show/373845/mongo.svg' width='40' /> MongoDB"]:::database
        Prisma["<img src='https://www.svgrepo.com/show/354210/prisma.svg' width='40' /> Prisma"]:::database
        RabbitMQ["<img src='https://www.svgrepo.com/show/354250/rabbitmq.svg' width='40' /> RabbitMQ"]:::queue
    end

    subgraph Observability["Observability Layer"]
        Prometheus["<img src='https://raw.githubusercontent.com/prometheus/prometheus/main/documentation/images/prometheus-logo.svg' width='40' /> Prometheus"]:::observability
        Grafana["<img src='https://www.svgrepo.com/show/353829/grafana.svg' width='40' /> Grafana"]:::observability
        Loki["<img src='https://raw.githubusercontent.com/grafana/loki/main/docs/sources/logo.png' width='40' /> Loki"]:::observability
        Tempo["<img src='https://grafana.com/static/img/logos/grafana-tempo.svg' width='40' /> Tempo"]:::observability
        OpenTelemetry["<img src='https://opentelemetry.io/img/logos/opentelemetry-horizontal-color.png' width='40' /> OpenTelemetry"]:::observability
        Dozzle["<img src='https://dozzle.dev/img/logo.svg' width='40' /> Dozzle"]:::support
        cAdvisor["<img src='https://www.svgrepo.com/show/353659/docker.svg' width='40' /> cAdvisor"]:::support
        NodeExporter["<img src='https://prometheus.io/assets/node_exporter_logo.svg' width='40' /> Node Exporter"]:::support
    end

    %% Connections remain the same as in the original diagram
    Service1 <--> Service2
    Service2 <--> Service3
    Service1 <--> Service3
    Client_App --> Traefik
    Traefik --> Service1
    Traefik --> Service2
    Traefik --> Service3

    Auth1 --> App1
    Middleware1 --> App1
    Utils1 --> App1
    Models1 --> App1
    Config1 --> App1
    App1 --> MongoDB
    App1 --> Prisma
    App1 --> RabbitMQ

    Auth2 --> App2
    Middleware2 --> App2
    Utils2 --> App2
    Models2 --> App2
    Config2 --> App2
    App2 --> MongoDB
    App2 --> Prisma
    App2 --> RabbitMQ

    Auth3 --> App3
    Middleware3 --> App3
    Utils3 --> App3
    Models3 --> App3
    Config3 --> App3
    App3 --> MongoDB
    App3 --> Prisma
    App3 --> RabbitMQ

    OpenTelemetry --> Prometheus
    OpenTelemetry --> Loki
    OpenTelemetry --> Tempo
    Prometheus --> Grafana
    Loki --> Grafana
    Tempo --> Grafana

    %% Click events remain the same as in the original diagram
    click Auth1 "https://github.com/Sachintha-dev/Microservice-local-dev-env/tree/main/service-1/src/api/auth"
    click Auth2 "https://github.com/Sachintha-dev/Microservice-local-dev-env/tree/main/service-2/src/api/auth"
    click Auth3 "https://github.com/Sachintha-dev/Microservice-local-dev-env/tree/main/service-3/src/api/auth"
    click MongoDB "https://github.com/Sachintha-dev/Microservice-local-dev-env/blob/main/service-1/src/config/mongodb.ts"
    click Prisma "https://github.com/Sachintha-dev/Microservice-local-dev-env/blob/main/service-1/src/config/prisma.ts"
    click RabbitMQ "https://github.com/Sachintha-dev/Microservice-local-dev-env/blob/main/service-1/src/config/rabbitmq.ts"
    click Middleware1 "https://github.com/Sachintha-dev/Microservice-local-dev-env/tree/main/service-1/src/middlewares/"
    click Middleware2 "https://github.com/Sachintha-dev/Microservice-local-dev-env/tree/main/service-2/src/middlewares/"
    click Middleware3 "https://github.com/Sachintha-dev/Microservice-local-dev-env/tree/main/service-3/src/middlewares/"
    click Utils1 "https://github.com/Sachintha-dev/Microservice-local-dev-env/tree/main/service-1/src/utils/"
    click Utils2 "https://github.com/Sachintha-dev/Microservice-local-dev-env/tree/main/service-2/src/utils/"
    click Utils3 "https://github.com/Sachintha-dev/Microservice-local-dev-env/tree/main/service-3/src/utils/"
    click Prometheus "https://github.com/Sachintha-dev/Microservice-local-dev-env/blob/main/prometheus.yml"
    click Loki "https://github.com/Sachintha-dev/Microservice-local-dev-env/blob/main/loki-config.yml"
    click Tempo "https://github.com/Sachintha-dev/Microservice-local-dev-env/blob/main/tempo-config.yml"
    click OpenTelemetry "https://github.com/Sachintha-dev/Microservice-local-dev-env/blob/main/otel-collector-config.yml"
    click Models1 "https://github.com/Sachintha-dev/Microservice-local-dev-env/tree/main/service-1/src/models/"
    click Models2 "https://github.com/Sachintha-dev/Microservice-local-dev-env/tree/main/service-2/src/models/"
    click Models3 "https://github.com/Sachintha-dev/Microservice-local-dev-env/tree/main/service-3/src/models/"
    click App1 "https://github.com/Sachintha-dev/Microservice-local-dev-env/blob/main/service-1/src/app.ts"
    click App2 "https://github.com/Sachintha-dev/Microservice-local-dev-env/blob/main/service-2/src/app.ts"
    click App3 "https://github.com/Sachintha-dev/Microservice-local-dev-env/blob/main/service-3/src/app.ts"

    classDef service fill:#2374ab
    classDef infra fill:#57a773
    classDef observability fill:#ff8c42
    classDef database fill:#845ec2
    classDef queue fill:#845ec2
    classDef support fill:#cccccc
```
