# fmarques56/rhtest architecture

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

- Interactive diagram: https://gitdiagram.com/fmarques56/rhtest
- Repository: https://github.com/fmarques56/rhtest

## Overview

##### Project type and purpose
- This is a full-stack web application used for teaching/testing (TPs) called RhTest:
– Frontend: Vue.js (apps/rhfront)
– Backend API: Node.js + TypeScript (apps/rhapi)
– Monitoring stack: Prometheus + Grafana + noise exporter (apps/monitoring)
- Docker Compose files spin up both the application (rhfront + rhapi) and the monitoring environment.

##### File structure
- Top-level directories:
– apps/rhfront → Vue 3 + Vite, components, service layer
– apps/rhapi → Express/Koa-style REST API, modules (employee), resource files (JSON, Swagger), unit tests
– apps/monitoring → Prometheus, Grafana, noise exporter
– cours → course materials (not part of runtime)
- Docker artifacts:
– apps/rhfront/Dockerfile, run.sh, build.sh
– apps/rhapi/Dockerfile
– apps/monitoring/noise/Dockerfile + noise.sh
– docker-compose-*.yml orchestrators
- Configuration files: prometheus.yml, datasources.yml, tsconfig.json, vite.config.js, package.json, etc.

##### Extract insights from README
- Purpose: support 4 TPs (requirements, TDD, API tests, functional tests) and a monitoring TP
- App token, Gitpod support, screenshot.

##### Main components & their relationships
a. Clients (Browser, automated tests)
↔ HTTP/HTTPS
b. Frontend (Vue.js app in container “rhfront”)
- Serves UI (index.html, App.vue, components)
- Calls Backend API endpoints via employee.service.js
c. Backend API (Node/TypeScript in container “rhapi”)
- Exposes REST endpoints (employee.controller)
- Business logic (employee.service)
- Data layer (employee.repository reading from salarie.json)
- Serves Swagger UI (resources/swagger.json)
d. Monitoring stack (three containers):
1. noise exporter → synthesizes metrics on /metrics
2. Prometheus → scrapes metrics from rhapi (/metrics if configured) and noise exporter
3. Grafana → dashboards, reads from Prometheus (configured via datasources.yml)
e. Orchestration (Docker Compose):
– docker-compose-rhtest.yml brings up rhfront + rhapi
– docker-compose-monitoring.yml brings up monitoring stack

##### Architectural patterns & design principles
- Layered architecture: UI → API → Data
- Micro-container approach: each service in its own Docker container
- Configuration-as-code: YAML files for Prometheus & Grafana
- Testability: unit tests in rhapi (vitest), Vue components easily testable
- Extensibility: noise exporter simulates metrics, can add real exporters

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Application Composition"
        compApp["docker-compose-rhtest.yml"]:::orchestration
        Browser["Browser / Automated Tests"]:::external
        rhfront["rhfront (Vue.js) :80"]:::frontend
        rhapi["rhapi (Node/TS) :3000"]:::backend
        salarie["salarie.json"]:::storage
        swagger["swagger.json (Swagger UI)"]:::backend
    end

    subgraph "Monitoring Composition"
        compMon["docker-compose-monitoring.yml"]:::orchestration
        noise["noise-exporter :9100"]:::monitor
        prometheus["Prometheus :9090"]:::monitor
        grafana["Grafana :3000"]:::monitor
    end

    Browser -->|"GET UI assets"| rhfront
    rhfront -->|"REST API calls"| rhapi
    rhapi -->|"reads data"| salarie
    rhapi -->|"serves docs"| swagger
    prometheus -->|"scrape /metrics"| rhapi
    prometheus -->|"scrape /metrics"| noise
    grafana -->|"query metrics"| prometheus

    click rhfront "https://github.com/fmarques56/rhtest/tree/master/apps/rhfront"
    click rhapi "https://github.com/fmarques56/rhtest/tree/master/apps/rhapi"
    click noise "https://github.com/fmarques56/rhtest/tree/master/apps/monitoring/noise"
    click prometheus "https://github.com/fmarques56/rhtest/blob/master/apps/monitoring/prometheus/prometheus.yml"
    click grafana "https://github.com/fmarques56/rhtest/blob/master/apps/monitoring/grafana/datasources.yml"
    click salarie "https://github.com/fmarques56/rhtest/blob/master/apps/rhapi/src/resources/salarie.json"
    click swagger "https://github.com/fmarques56/rhtest/blob/master/apps/rhapi/src/resources/swagger.json"
    click compApp "https://github.com/fmarques56/rhtest/blob/master/apps/docker-compose-rhtest.yml"
    click compMon "https://github.com/fmarques56/rhtest/blob/master/apps/docker-compose-monitoring.yml"

    classDef frontend fill:#ADD8E6,stroke:#000
    classDef backend fill:#90EE90,stroke:#000
    classDef monitor fill:#FFA500,stroke:#000
    classDef orchestration fill:#D3D3D3,stroke:#000,stroke-dasharray:5 5
    classDef external fill:#CCCCCC,stroke:#000
    classDef storage fill:#FFFFFF,stroke:#000,stroke-dasharray:2 2
```
