# microcosmx/workspace_microservices architecture

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

- Interactive diagram: https://gitdiagram.com/microcosmx/workspace_microservices
- Repository: https://github.com/microcosmx/workspace_microservices

## Overview

##### Project type and purpose
- This is a large‐scale, containerized ticket‐seller application built with 40+ microservices.
- Each microservice implements a distinct business domain (e.g., user, order, payment, route, travel, contacts, assurance, etc.) and is written in various stacks (Java/Spring Boot, NodeJS/Express, Python/Django, Go/Webgo).
- The application is assembled and deployed via Docker Compose, Docker Swarm, and even Kubernetes YAML manifests.

##### File structure
- Top‐level directories:
- “ts-*-service” (40+ microservices)
- ts-ui-dashboard (Angular/HTML/CSS/JS frontend)
- ts-ui-test (integration tests)
- 1-services-analysis, kubernetes-services (tracing analysis and K8s YAML examples)
- docker-compose.yml + docker-compose-swarm.yml (orchestration)
- ts-service-*.yml (Swarm/K8s stack definitions)
- ms-monitoring-core (shared tracing instrumentation library)
- Each microservice has:
- Dockerfile + pom.xml or respective language manifest
- src/main/java (or equivalent)
- application.yml (Spring Cloud config)
- Supporting infrastructure:
- Config Service (ts-config-service)
- Discovery/eureka (implied by Spring Cloud usage)
- Messaging/async queue (in inside-payment, rest-service-6)
- Monitoring/tracing (ms-monitoring-core instrumentation, Portainer UI)

##### README for additional insights
- Core tech: Java + Spring Boot/Cloud, NodeJS, Python, Go
- Local vs. cluster runtime instructions (docker-compose vs. Docker Swarm/Kubernetes)
- Fault‐injection branches to simulate failure modes

a. Main components
1. API Layer (UI + optional API Gateway)
- ts-ui-dashboard container
- (ts-ui-test as automated client)
2. Service Discovery & Configuration
- ts-config-service (Spring Cloud Config Server)
- Eureka/Consul (Spring Cloud Discovery, not explicit in tree but standard)
3. Business Microservices
- By domain (user, order, payment, route, travel, contacts, etc.)
- Each microservice container registers with Discovery & pulls config
4. Messaging Infrastructure
- RabbitMQ or other broker for async flows (used by inside-payment, rest-service-6)
5. Data Stores
- Separate database per service (PostgreSQL / MySQL containers)
- ts-voucher-service uses SQLite or file‐based DB (db.sql)
6. Monitoring & Tracing
- Zipkin/Jaeger (instrumented by ms-monitoring-core)
- Portainer UI for Docker management

b. Component Interactions
- UI → calls microservices over REST
- Microservices → retrieve configuration from Config Server
- Microservices → register/discover peers via Discovery Server
- Inter‐service calls (order → payment → notification)
- Async flows (inside-payment → message broker → notification)
- Each service persists to its own database
- Tracing data flows to Zipkin/Jaeger via ms-monitoring-core

c. Architectural patterns & principles
- Microservices per bounded context
- Twelve‐factor apps: externalized config, logs
- Service registry and discovery (Spring Cloud)
- API composition by the UI (no monolithic gateway shown)
- Polyglot services containerized with Docker
- Orchestration layers: Docker Compose for local, Swarm or Kubernetes for cluster
- Distributed tracing and centralized configuration

d. Technologies, frameworks, libraries
- Java/Spring Boot, Spring Cloud Config, Discovery
- NodeJS/Express, Python/Django, Go/Webgo
- Docker, Docker Compose, Docker Swarm, Kubernetes YAML
- RabbitMQ (or JMS), asynchronous queues
- Zipkin/Jaeger (ms-monitoring-core)
- Portainer for monitoring containers

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        UI["UI Dashboard"]:::frontend
        UITEST["Automated UI Test Client"]:::frontend
    end

    %% Configuration and Discovery Layer
    subgraph "Config & Discovery"
        direction TB
        CONFIG["Config Service (Spring Cloud Config)"]:::infra
        DISCOVERY["Service Discovery (Eureka/Consul)"]:::infra
    end

    %% Business Services Layer
    subgraph "Business Microservices"
        direction TB
        subgraph "Order Domain"
            ORDER["Order Service"]:::java
            ORDER_DB[(Order DB)]:::db
        end
        subgraph "Payment Domain"
            PAYMENT["Payment Service"]:::java
            INSIDEPAY["Inside-Payment Service"]:::java
            PAYMENT_DB[(Payment DB)]:::db
        end
        subgraph "Travel Domain"
            TRAVEL["Travel Service"]:::nodejs
            TRAVEL_DB[(Travel DB)]:::db
        end
        subgraph "Route Domain"
            ROUTE["Route Service"]:::python
            ROUTE_DB[(Route DB)]:::db
        end
        subgraph "Contacts Domain"
            CONTACTS["Contacts Service"]:::go
            CONTACTS_DB[(Contacts DB)]:::db
        end
        subgraph "Notification & Voucher"
            NOTIF["Notification Service"]:::nodejs
            VOUCHER["Voucher Service"]:::python
            NOTIF_DB[(Notification DB)]:::db
            VOUCHER_DB[(Voucher DB)]:::db
        end
    end

    %% Messaging & Databases Layer
    subgraph "Messaging & Datastores"
        direction TB
        BROKER["Message Broker (RabbitMQ)"]:::infra
    end

    %% Monitoring & Orchestration Layer
    subgraph "Monitoring & Orchestration"
        direction TB
        TRACER["Zipkin/Jaeger Collector"]:::infra
        PORTAINER["Portainer UI"]:::infra
        COMPOSE["Docker Compose"]:::infra
        SWARM["Docker Swarm Stack"]:::infra
        K8S["Kubernetes Manifests"]:::infra
        ANALYSIS["Distributed Tracing Analysis"]:::infra
    end

    %% Connections - UI to Services
    UI -->|"REST calls"| ORDER
    UI -->|"REST calls"| PAYMENT
    UITEST -->|"Integration tests"| UI

    %% Config & Discovery interactions
    CONFIG <--> ORDER
    CONFIG <--> PAYMENT
    CONFIG <--> INSIDEPAY
    CONFIG <--> TRAVEL
    CONFIG <--> ROUTE
    CONFIG <--> CONTACTS
    CONFIG <--> NOTIF
    CONFIG <--> VOUCHER

    DISCOVERY <--> ORDER
    DISCOVERY <--> PAYMENT
    DISCOVERY <--> INSIDEPAY
    DISCOVERY <--> TRAVEL
    DISCOVERY <--> ROUTE
    DISCOVERY <--> CONTACTS
    DISCOVERY <--> NOTIF
    DISCOVERY <--> VOUCHER

    %% Service-to-service sync flows
    ORDER -->|"calls"| PAYMENT
    PAYMENT -->|"calls"| NOTIF

    %% Async flows
    INSIDEPAY -.->|"publishes"| BROKER
    BROKER -.->|"delivers"| NOTIF

    %% Databases
    ORDER --> ORDER_DB
    PAYMENT --> PAYMENT_DB
    INSIDEPAY --> PAYMENT_DB
    TRAVEL --> TRAVEL_DB
    ROUTE --> ROUTE_DB
    CONTACTS --> CONTACTS_DB
    NOTIF --> NOTIF_DB
    VOUCHER --> VOUCHER_DB

    %% Tracing & Monitoring
    ORDER --> TRACER
    PAYMENT --> TRACER
    INSIDEPAY --> TRACER
    TRAVEL --> TRACER
    ROUTE --> TRACER
    CONTACTS --> TRACER
    NOTIF --> TRACER
    VOUCHER --> TRACER
    PORTAINER --> COMPOSE
    PORTAINER --> SWARM
    PORTAINER --> K8S

    %% Orchestration
    COMPOSE --> ORDER
    COMPOSE --> PAYMENT
    COMPOSE --> TRAVEL
    SWARM --> ORDER
    SWARM --> PAYMENT
    SWARM --> TRAVEL
    K8S --> ORDER
    K8S --> PAYMENT
    K8S --> TRAVEL

    %% Click Events
    click UI "https://github.com/microcosmx/workspace_microservices/tree/master/ts-ui-dashboard/"
    click UITEST "https://github.com/microcosmx/workspace_microservices/tree/master/ts-ui-test/"
    click CONFIG "https://github.com/microcosmx/workspace_microservices/tree/master/ts-config-service/"
    click ORDER "https://github.com/microcosmx/workspace_microservices/tree/master/ts-order-service/"
    click PAYMENT "https://github.com/microcosmx/workspace_microservices/tree/master/ts-payment-service/"
    click TRAVEL "https://github.com/microcosmx/workspace_microservices/tree/master/ts-travel-service/"
    click ROUTE "https://github.com/microcosmx/workspace_microservices/tree/master/ts-route-service/"
    click CONTACTS "https://github.com/microcosmx/workspace_microservices/tree/master/ts-contacts-service/"
    click INSIDEPAY "https://github.com/microcosmx/workspace_microservices/tree/master/ts-inside-payment-service/"
    click NOTIF "https://github.com/microcosmx/workspace_microservices/tree/master/ts-notification-service/"
    click VOUCHER "https://github.com/microcosmx/workspace_microservices/tree/master/ts-voucher-service/"
    click BROKER "https://github.com/microcosmx/workspace_microservices/tree/master/rest-service-6/queue/"
    click TRACER "https://github.com/microcosmx/workspace_microservices/tree/master/ms-monitoring-core/"
    click COMPOSE "https://github.com/microcosmx/workspace_microservices/blob/master/docker-compose.yml"
    click SWARM "https://github.com/microcosmx/workspace_microservices/blob/master/docker-compose-swarm.yml"
    click K8S "https://github.com/microcosmx/workspace_microservices/tree/master/kubernetes-services/"
    click ANALYSIS "https://github.com/microcosmx/workspace_microservices/tree/master/1-services-analysis/"

    %% Styles
    classDef java fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef nodejs fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef python fill:#ffffcc,stroke:#333,stroke-width:1px
    classDef go fill:#ffdd99,stroke:#333,stroke-width:1px
    classDef infra fill:#f0f0f0,stroke:#333,stroke-width:1px
    classDef db fill:#ffffff,stroke:#333,stroke-width:1px,stroke-dasharray: 3 3
    class UI,UITEST frontend
    classDef frontend fill:#e6e6e6,stroke:#333,stroke-width:1px,rx:5,ry:5
```
