# ptit-projects/demo-midterm-dbms architecture

> Architecture diagram of the GitHub repository ptit-projects/demo-midterm-dbms, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ptit-projects/demo-midterm-dbms
- Repository: https://github.com/ptit-projects/demo-midterm-dbms

## Overview

##### Main Dockerized Components
- Frontend Service (fe): Represented by the “fe” directory, this container (likely built with Vite+React) delivers the client-side application.
- Backend Service (epl-web): A Spring Boot application (evident from the Maven structure and numerous controllers, services, repositories, etc.) exposed through its REST/HTTP endpoints.
- Database Service(s): There are strong hints in the project files:
– There is a “clickhouse-init.sql” suggesting a ClickHouse container for handling analytical queries.
– There is a “mysql.yml” file and references like “init.sql” that indicate a MySQL container is in play.
- Monitoring/Tracing Service: The presence of “otel-collector-config.yml” and Spring configuration classes like OtelSpringDocConfig hint at an OpenTelemetry collector service.
- Additional Services: Since there are seven services defined, expect that other containers might include one or more of the following:
– A reverse proxy or load balancer (commonly an NGINX container) to route requests between the frontend and backend.
– A caching or auxiliary service to support session management or performance (for example, a Redis container).
– Possibly a dedicated logging or metrics exporter service.

##### Relationships and Interactions
- From the Backend:
- If caching or additional metrics/logging services are included, show those dependencies clearly with directional flow indicating data (or configuration) movement.

##### Architectural Patterns and Key Technologies
- That the app follows a layered architecture:
– Presentation layer (fe service)
– Business Logic/API layer (epl-web service)
– Data layer (MySQL and ClickHouse)
- Call out the use of Docker Compose to orchestrate container startup and service dependency mapping.
- That Spring Boot’s configuration (in “epl-web/src/main/java/.../config”) underpins many backend concerns like security (SecurityConfig), mapping (ModelMapperConfig), and authentication.
- Make special mention of the OpenTelemetry configuration for distributed tracing which ties into the overall observability pattern.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Docker Compose Services
    A["Reverse Proxy (NGINX)"]:::infra
    B["Frontend (React/Vite)"]:::ui
    C["Backend (Spring Boot)"]:::backend
    D["((MySQL Database))"]:::database
    E["((ClickHouse Database))"]:::database
    F["OpenTelemetry Collector"]:::infra
    G["Redis Cache"]:::infra

    %% Service Interactions
    A -->|"routes"| B
    A -->|"routes"| C
    B -->|"REST_API"| C
    C -->|"queries"| D
    C -->|"analytics"| E
    C -->|"metrics"| F
    F -->|"traces"| C
    C -->|"caches"| G

    %% Click Events for Component Mapping
    click B "https://github.com/ptit-projects/demo-midterm-dbms/tree/main/fe/"
    click C "https://github.com/ptit-projects/demo-midterm-dbms/tree/main/epl-web/"
    click D "https://github.com/ptit-projects/demo-midterm-dbms/blob/main/mysql.yml"
    click E "https://github.com/ptit-projects/demo-midterm-dbms/blob/main/clickhouse-init.sql"
    click F "https://github.com/ptit-projects/demo-midterm-dbms/blob/main/otel-collector-config.yml"
    click F "https://github.com/ptit-projects/demo-midterm-dbms/blob/main/epl-web/src/main/java/vn/ptit/project/epl_web/config/OtelSpringDocConfig.java"

    %% Styles
    classDef ui fill:#bbf,stroke:#333,stroke-width:2px;
    classDef backend fill:#fbb,stroke:#333,stroke-width:2px;
    classDef database fill:#bfb,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5;
    classDef infra fill:#ffb,stroke:#333,stroke-width:2px;
```
