# fragaly/performance-researches architecture

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

- Interactive diagram: https://gitdiagram.com/fragaly/performance-researches
- Repository: https://github.com/fragaly/performance-researches

## Overview

##### Project Type and Purpose
- This repository is an open-source performance research framework. Its goal is to compare the runtime, resource usage, and throughput of several JVM microframeworks (Spring Boot Web, Spring Boot Reactive, Quarkus Reactive, Micronaut Reactive) in both JVM and native images. It orchestrates data generation, database provisioning, microservice deployment, load testing, and metrics collection.

##### File Structure Analysis
- Top-level “modules” for each microframework variant (e.g. spring-boot-web, spring-boot-reactive, quarkus-reactive, micronaut-reactive) each include:
- Source code (`src/main/java/...`) implementing the same transport booking API.
- A Docker Compose to spin up the service + Postgres image.
- A `datagen` module generates and populates the database with synthetic data.
- A `gatling` module contains load-test scenarios against the API.
- `env/database` contains Dockerfiles, init scripts, and Prometheus/Grafana provisioning.
- CI workflows under `.github/workflows` build and test each variant in multiple configurations (JAR, native, docker).

##### Key Architectural Insights from README
- The system uses a single Postgres database container seeded by `datagen`.
- Each microframework module runs as an independent container, exposing identical RESTful endpoints defined by an OpenAPI spec.
- Load is injected via Gatling, and metrics (service + Postgres) are scraped by Prometheus and visualized in Grafana.
- All components run in one Docker network to eliminate network variability.

##### Core Components
a. Datagen Service
- Java Spring Boot application (runs once) → populates Postgres dataset (Users, Transfers, etc.).
b. Postgres Database Container
- Holds the transport booking schema and seeded data. Exposes port 5432 internally.
c. Microframework Service Instances (choose one or show them in parallel)
- Spring Boot Web / Reactive
- Quarkus Reactive
- Micronaut Reactive
- Each container: HTTP REST API (the same set of endpoints) → connects to Postgres via JDBC/R2DBC.
d. Gatling Load Generator
- Runs load scenarios (A2BSimulation) against the service’s public HTTP port. Generates RPS and collects response times.
e. Monitoring Stack
- Prometheus scrapes metrics endpoints from:
- Each microservice (HTTP metrics)
- Postgres exporter
- Grafana visualizes performance dashboards based on Prometheus data.
f. CI/CD Pipelines
- GitHub Actions workflows build, test, and publish artifacts for each framework variant.

##### Relationships and Data Flows
- Datagen → (JDBC) → Postgres
- Microservices → (JDBC/R2DBC) → Postgres
- Gatling → (HTTP) → Microservice API
- Microservices & Postgres → (metrics endpoints) → Prometheus → Grafana
- Source code → (Gradle/Native build) → Docker images → Docker Compose deployment

##### Architectural Patterns and Principles
- Modular microservice per framework variant, each with
- Controller/Handler layer exposing REST endpoints
- Repository layer interacting with the same DB schema
- Containerized isolation: each service + DB + monitoring run in own Docker containers on a private network
- Infrastructure-as-code: Docker Compose files define services, networks, volumes.
- CI-driven reproducibility: GitHub workflows ensure consistent build/test across all variants.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CI/CD Pipeline
    CI["GitHub Actions CI/CD"]:::ci
    CI -->|"build & deploy"| Network

    subgraph "Docker Network" 
        direction TB
        %% Data Generation
        Datagen["Datagen Service"]:::app
        Datagen -->|"JDBC populate"| DB

        %% Database
        DB[(Postgres DB)]:::infra

        %% Microservices Group
        subgraph "Microservices (Compare Variants)"
            direction TB
            SBW["Spring Boot Web Service"]:::app
            SBW -->|"JDBC/R2DBC"| DB

            SBR["Spring Boot Reactive Service"]:::app
            SBR -->|"JDBC/R2DBC"| DB

            SBRN["Spring Boot Reactive Native Service"]:::app
            SBRN -->|"JDBC/R2DBC"| DB

            SBWN["Spring Boot Web Native Service"]:::app
            SBWN -->|"JDBC/R2DBC"| DB

            QR["Quarkus Reactive Service"]:::app
            QR -->|"JDBC/R2DBC"| DB

            MN["Micronaut Reactive Service"]:::app
            MN -->|"JDBC/R2DBC"| DB
        end

        %% Load Testing
        Gatling["Gatling Load Tester"]:::load
        Gatling -->|"HTTP Load"| SBW
        Gatling -->|"HTTP Load"| SBR
        Gatling -->|"HTTP Load"| SBRN
        Gatling -->|"HTTP Load"| SBWN
        Gatling -->|"HTTP Load"| QR
        Gatling -->|"HTTP Load"| MN

        %% Monitoring Stack
        Prometheus["Prometheus"]:::infra
        Grafana["Grafana"]:::infra

        SBW -->|"metrics scrape"| Prometheus
        SBR -->|"metrics scrape"| Prometheus
        SBRN -->|"metrics scrape"| Prometheus
        SBWN -->|"metrics scrape"| Prometheus
        QR -->|"metrics scrape"| Prometheus
        MN -->|"metrics scrape"| Prometheus
        DB -->|"metrics export"| Prometheus

        Prometheus -->|"dashboard data"| Grafana

        %% API Spec
        OpenAPI["OpenAPI Spec"]:::doc
        OpenAPI -.-> SBW
        OpenAPI -.-> SBR
        OpenAPI -.-> SBRN
        OpenAPI -.-> SBWN
        OpenAPI -.-> QR
        OpenAPI -.-> MN
    end

    %% Legend
    subgraph Legend
        direction TB
        A1["App Components"]:::app
        A2["Infrastructure"]:::infra
        A3["CI/CD"]:::ci
        A4["Load Testing"]:::load
        A5["Docs/API"]:::doc
    end

    %% Click Events
    click Datagen "https://github.com/fragaly/performance-researches/blob/main/datagen/src/main/java/by/vk/datagen/DatagenApplication.java"
    click DB "https://github.com/fragaly/performance-researches/blob/main/env/database/docker/docker-compose.yml"
    click SBW "https://github.com/fragaly/performance-researches/blob/main/spring-boot-web/src/main/java/by/vk/springbootweb/SpringBootWebApplication.java"
    click SBW "https://github.com/fragaly/performance-researches/blob/main/spring-boot-web/docker/docker-compose.yml"
    click SBR "https://github.com/fragaly/performance-researches/blob/main/spring-boot-reactive/src/main/java/by/vk/springbootreactive/SpringBootReactiveApplication.java"
    click SBR "https://github.com/fragaly/performance-researches/blob/main/spring-boot-reactive/docker/docker-compose.yml"
    click SBRN "https://github.com/fragaly/performance-researches/blob/main/spring-boot-reactive-native/src/main/java/by/vk/springbootreactivenative/SpringBootReactiveNativeApplication.java"
    click SBRN "https://github.com/fragaly/performance-researches/blob/main/spring-boot-reactive-native/docker/docker-compose.yml"
    click SBWN "https://github.com/fragaly/performance-researches/blob/main/spring-boot-web-native/src/main/java/by/vk/springbootwebnative/SpringBootWebNativeApplication.java"
    click SBWN "https://github.com/fragaly/performance-researches/blob/main/spring-boot-web-native/docker/docker-compose.yml"
    click QR "https://github.com/fragaly/performance-researches/blob/main/quarkus-reactive/docker/docker-compose.yml"
    click MN "https://github.com/fragaly/performance-researches/blob/main/micronaut-reactive/src/main/java/by/vk/Application.java"
    click MN "https://github.com/fragaly/performance-researches/blob/main/micronaut-reactive/docker/docker-compose.yml"
    click Gatling "https://github.com/fragaly/performance-researches/blob/main/gatling/src/gatling/java/by/vk/scenario/a2b/A2BSimulation.java"
    click Prometheus "https://github.com/fragaly/performance-researches/blob/main/env/database/docker/prometheus/prometheus.yml"
    click Grafana "https://github.com/fragaly/performance-researches/blob/main/env/database/docker/grafana/provisioning/datasources/datasources.yml"
    click OpenAPI "https://github.com/fragaly/performance-researches/blob/main/env/api/a2b.yaml"
    click CI "https://github.com/fragaly/performance-researches/blob/main/.github/workflows/spring-boot-web.yml"
    click CI "https://github.com/fragaly/performance-researches/blob/main/.github/workflows/spring-boot-web-native.yml"
    click CI "https://github.com/fragaly/performance-researches/blob/main/.github/workflows/spring-boot-reactive.yml"
    click CI "https://github.com/fragaly/performance-researches/blob/main/.github/workflows/spring-boot-reactive-native.yml"
    click CI "https://github.com/fragaly/performance-researches/blob/main/.github/workflows/quarkus-reactive-native.yml"
    click CI "https://github.com/fragaly/performance-researches/blob/main/.github/workflows/micronaut-reactive-native.yml"

    %% Styles
    classDef app fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef infra fill:#DFFFE0,stroke:#22863a,color:#22863a;
    classDef ci fill:#FFE8A0,stroke:#d73a49,color:#d73a49;
    classDef load fill:#FFD0A0,stroke:#cb2431,color:#cb2431;
    classDef doc fill:#F0F0F0,stroke:#6a737d,color:#6a737d;
```
