# socialsoftware/microservices-simulator architecture

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

- Interactive diagram: https://gitdiagram.com/socialsoftware/microservices-simulator
- Repository: https://github.com/socialsoftware/microservices-simulator

## Overview

##### Principal system components
- Simulator: This module encapsulates the core Domain-Driven Design (DDD) concepts, including the domain entities (aggregates), event handling, versioning, and the coordination mechanisms for both sagas and TCC. In the file tree, this is located under the “simulator” directory.
- Quizzes Microservice System: This part of the project is a case study implementing the quizzes functionality. It is split into two transactional models:
– Sagas: Found under “applications/quizzes/src/main/java/pt/ulisboa/tecnico/socialsoftware/quizzes/sagas”. It includes aggregates, saga-specific coordination, state management and business logic tests.
– TCC (Transactional Causal Consistency): Found under “applications/quizzes/src/main/java/pt/ulisboa/tecnico/socialsoftware/quizzes/causal”. It includes the domain-specific microservices aggregates, along with TCC-specific coordination and event processing.
- External Testing & Deployment: Docker Compose files (docker-compose.yml), JMeter test cases (in the jmeter directory), and Maven build scripts support deployment, automated testing, and simulating concurrent behavior.

##### Break down internal architectural layers
- Transactional Model Specific Extensions:
– For Sagas: Include additional components that extend the aggregates (e.g., SagaTournament, corresponding event subscription and handling classes). Group these in a “Sagas Coordination/Functionalities” module.
– For TCC: Likewise, show the causal aggregates (e.g., CausalTournament) and the coordination components classed under TCC. Make note of the merge behavior and ordering enforced by transactional causal consistency.
- Simulator Coordination: Show the “simulator” container which coordinates unit-of-work patterns, aggregate persistence, event subscription, and the orchestration of workflows. It also includes the core elements for DDD as well as the transactional extensions.
- Integration & Testing Components: Include a block for JMeter (with test case execution flows for tournaments, update names, add participants, etc.) and a block for Spock/Maven tests.
- Deployment & Infrastructure: Add deployment elements such as Docker Compose and Maven commands, which map to launching specific profiles (sagas, TCC, tests).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Testing & Deployment Cluster
    subgraph "External Testing & Deployment"
        ET1["JMeter Tests"]:::infra
        ET2["Docker Compose"]:::infra
        ET3["Maven Build (Quizzes)"]:::infra
        ET4["Maven Build (Simulator)"]:::infra
    end

    %% Simulator Module
    subgraph "Simulator"
        SIM["Simulator Core & Coordination"]:::sim
    end

    %% Quizzes Microservice System Cluster
    subgraph "Quizzes Microservice System"
        subgraph "Common Domain Aggregates"
            D1["Tournament"]:::domain
            D2["Course"]:::domain
            D3["Question"]:::domain
            D4["Quiz"]:::domain
            D5["Topic"]:::domain
            D6["User"]:::domain
        end
        subgraph "Sagas Implementation"
            SAG["Sagas Coordination & Aggregates"]:::saga
        end
        subgraph "TCC Implementation"
            TCC["TCC Coordination & Aggregates"]:::tcc
        end
    end

    %% Relationships
    %% External Testing triggers Simulator and Quizzes System
    ET1 ---|"triggers"| SIM
    ET1 ---|"triggers"| D1
    ET2 ---|"deploys"| SIM
    ET2 ---|"deploys"| D1
    ET3 ---|"builds"| D1
    ET4 ---|"builds"| SIM

    %% Simulator Coordinating and Managing Workflows
    SIM ---|"coordinates"| SAG
    SIM ---|"coordinates"| TCC
    SIM ---|"manages_unitOfWork"| D1

    %% Domain Aggregates event flow into transactional models
    D1 ---|"eventFlow_Sagas"| SAG
    D2 ---|"eventFlow_Sagas"| SAG
    D3 ---|"eventFlow_Sagas"| SAG
    D4 ---|"eventFlow_Sagas"| SAG
    D5 ---|"eventFlow_Sagas"| SAG
    D6 ---|"eventFlow_Sagas"| SAG

    D1 ---|"eventFlow_TCC"| TCC
    D2 ---|"eventFlow_TCC"| TCC
    D3 ---|"eventFlow_TCC"| TCC
    D4 ---|"eventFlow_TCC"| TCC
    D5 ---|"eventFlow_TCC"| TCC
    D6 ---|"eventFlow_TCC"| TCC

    %% Styles
    classDef domain fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef saga fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef tcc fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef sim fill:#ffd699,stroke:#333,stroke-width:2px;
    classDef infra fill:#99ccff,stroke:#333,stroke-width:2px;

    %% Click Events
    click SIM "https://github.com/socialsoftware/microservices-simulator/tree/master/simulator/src/main/java/pt/ulisboa/tecnico/socialsoftware/ms/"
    click SAG "https://github.com/socialsoftware/microservices-simulator/tree/master/applications/quizzes/src/main/java/pt/ulisboa/tecnico/socialsoftware/quizzes/sagas"
    click TCC "https://github.com/socialsoftware/microservices-simulator/tree/master/applications/quizzes/src/main/java/pt/ulisboa/tecnico/socialsoftware/quizzes/causal"
    click ET1 "https://github.com/socialsoftware/microservices-simulator/tree/master/applications/quizzes/jmeter/tournament/thesis-cases"
    click ET2 "https://github.com/socialsoftware/microservices-simulator/blob/master/docker-compose.yml"
    click ET3 "https://github.com/socialsoftware/microservices-simulator/blob/master/applications/quizzes/pom.xml"
    click ET4 "https://github.com/socialsoftware/microservices-simulator/blob/master/simulator/pom.xml"
```
