# yuri-val/symmetric-dashboard architecture

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

- Interactive diagram: https://gitdiagram.com/yuri-val/symmetric-dashboard
- Repository: https://github.com/yuri-val/symmetric-dashboard

## Overview

##### Project Type & Purpose
- This is a full-stack application that splits front-end and back-end concerns. The purpose is to provide a dashboard for real-time monitoring and management of database synchronization (nodes, batches, configuration).
- The README clearly specifies different sections like Dashboard Overview, Node Management, Batch Monitoring, and Configuration, which can be represented as key features/components in the design.

##### Main Components
- Frontend (Client):
- Built with React (using Vite for build tooling).
- Uses Material UI for UI components, React Router for navigation, and Recharts for data visualization.
- Communicates with the server using Axios and is enhanced with TanStack React Query for data fetching/caching.
- Backend (Server):
- A Node.js Express application structured with controllers, services, and repositories.
- Provides RESTful API endpoints (e.g., /health, /api/node/status, /api/node/nodes, /api/engine/config, /api/batch/status) to serve data to the frontend.
- Connects to a SymmetricDS meta database (MySQL) using MySQL2 and manages environment configuration via Dotenv.
- Database:
- The external SymmetricDS meta database, which the server connects to for retrieving node, batch, and configuration data.
- Deployment & Infrastructure:
- Docker and Docker Compose for containerized deployment.
- Nginx is used (as per nginx.conf) to serve the frontend and proxy API requests.
- GitHub workflows & start.sh suggest CI/CD integration along with process management in production (potentially via PM2).

##### Relationships & Interactions
- The Frontend communicates with the Backend using REST API calls.
- The Backend’s layered architecture (controllers → services → repositories) interacts with the Database.
- In production, Nginx acts as a reverse proxy, ensuring that API requests (forwarded from client requests) reach the appropriate server endpoints.
- Docker and Docker Compose manage the containers, indicating that both client and server are built and run as separate microservices (or containers) that interact with each other.

##### Architectural Patterns & Design Principles
- Separation of concerns: The client and server are clearly separated, with the server further divided into controllers, services, and repositories.
- Layered architecture on the backend helps in isolating business logic (services) from data access (repositories).
- Use of environment variables for sensitive configuration emphasizes secure design principles.
- A modular approach on the frontend with dedicated directories for API, components, pages, and context helps maintain readability and extensibility.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Nginx Reverse Proxy
    Nginx["Nginx Reverse Proxy"]:::reverseProxy

    %% Frontend Subgraph
    subgraph "Frontend (React/Vite)"
        FE["Frontend (React/Vite)"]:::frontend
        FE_API["API Layer (Axios & React Query)"]:::frontend
        FE_Dashboard["Dashboard & Visualization Components"]:::frontend
        FE_NodeMgmt["Node Management Components"]:::frontend
        FE_Batch["Batch Monitoring Components"]:::frontend
        FE_Config["Configuration Components"]:::frontend
    end

    %% Backend Subgraph
    subgraph "Backend (Express Server)"
        BE["Backend (Express Server)"]:::backend
        BE_Controller["Controllers"]:::backend
        BE_Service["Services"]:::backend
        BE_Repository["Repositories"]:::backend
        BE_Controller -->|"calls"| BE_Service
        BE_Service -->|"calls"| BE_Repository
    end

    %% External Database
    DB["SymmetricDS Meta Database (MySQL)"]:::database

    %% Deployment and Configuration Nodes
    Docker["Docker & Docker Compose"]:::container
    CI["CI/CD Pipeline"]:::cicd
    Env["Environment Configuration"]:::env

    %% Relationships & Interactions
    Nginx -->|"proxies"| FE
    Nginx -->|"proxies"| BE
    FE_API -->|"RESTAPICalls(Axios)"| BE_Controller
    BE_Repository -->|"DatabaseQueries(MySQL2)"| DB
    CI -->|"buildsDeploys"| Docker
    Docker -->|"containerized"| FE
    Docker -->|"containerized"| BE
    BE -->|"usesConfig"| Env

    %% Click Events
    click FE "https://github.com/yuri-val/symmetric-dashboard/tree/main/client/"
    click FE_API "https://github.com/yuri-val/symmetric-dashboard/tree/main/client/src/api/"
    click FE_Dashboard "https://github.com/yuri-val/symmetric-dashboard/tree/main/client/src/components/dashboard/"
    click FE_NodeMgmt "https://github.com/yuri-val/symmetric-dashboard/tree/main/client/src/components/nodes/"
    click FE_Batch "https://github.com/yuri-val/symmetric-dashboard/tree/main/client/src/components/batches/"
    click FE_Config "https://github.com/yuri-val/symmetric-dashboard/tree/main/client/src/components/configuration/"
    click BE "https://github.com/yuri-val/symmetric-dashboard/tree/main/server/"
    click BE_Controller "https://github.com/yuri-val/symmetric-dashboard/tree/main/server/src/controllers/"
    click BE_Service "https://github.com/yuri-val/symmetric-dashboard/tree/main/server/src/services/"
    click BE_Repository "https://github.com/yuri-val/symmetric-dashboard/tree/main/server/src/repositories/"
    click Nginx "https://github.com/yuri-val/symmetric-dashboard/blob/main/nginx.conf"
    click Docker "https://github.com/yuri-val/symmetric-dashboard/tree/main/Dockerfile"
    click CI "https://github.com/yuri-val/symmetric-dashboard/tree/main/.github/workflows/"
    click Env "https://github.com/yuri-val/symmetric-dashboard/blob/main/server/.env.example"

    %% Styles
    classDef frontend fill:#f9e79f,stroke:#b7950b,stroke-width:2px;
    classDef backend fill:#aed6f1,stroke:#2874a6,stroke-width:2px;
    classDef database fill:#d5f5e3,stroke:#1e8449,stroke-width:2px;
    classDef reverseProxy fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;
    classDef container fill:#fad7a0,stroke:#e67e22,stroke-width:2px;
    classDef cicd fill:#d2b4de,stroke:#8e44ad,stroke-width:2px;
    classDef env fill:#f8c471,stroke:#d35400,stroke-width:2px;
```
