# empcloud/empmonitor architecture

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

- Interactive diagram: https://gitdiagram.com/empcloud/empmonitor
- Repository: https://github.com/empcloud/empmonitor

## Overview

##### Main Architectural Layers
- Frontend – The “Frontend” directory is a Laravel-based web interface which uses Blade templating. It handles user interactions, dashboard rendering, authentication, reporting views, and integration with third‐party assets (plugins, charts, etc.). This layer sends requests to the backend for operations like attendance processing, report generation, and analytics.
- Backend – In the “Backend” folder you notice several submodules (Agent, Main, Report, and Store). Although they share similar structures (each with its own “index.js”, middleware, routes, controllers, database connections, and utilities) they appear to encapsulate separate business domains:
– Agent: Likely a microservice part that handles monitoring agent functionalities (tracking user activity, screen monitoring, etc.).
– Main: Core functionalities such as authentication, employee information management, and general application logic.
– Report: Dedicated to generating and managing comprehensive performance reports and analytics.
– Store: Possibly responsible for persisting or managing activity data, logs, or transactional records.
- Cross-Platform Desktop Component – The existence of a “QT” folder (with its own README) suggests that a QT-based module exists. This likely functions as either a desktop client or an auxiliary cross-platform component. Make sure to represent it as a separate client interface that may communicate directly with backend services or perhaps even communicate with the local agent.
- Assets & External Libraries – The project heavily utilizes external plugins and libraries (for charts, data tables, UI elements across both frontend and various assets) so you could note that the UI layer integrates with third-party libraries (e.g., ChartJS, OwlCarousel, apexcharts, and many others) for dashboard visualization and interactive elements.

##### Relationships & Data Flow
- Optionally, show that the QT client (if it’s used as a standalone desktop monitoring app) communicates with the backend or directly with the agent on endpoints providing real-time or historical tracking data.
- External integrations (e.g., third-party notification systems, external analytics engines, or API integrations with other HR systems) if desired, to provide a complete picture of data flows.

##### Architectural Patterns and Technologies
- That the backend architecture seems modular or microservices-like. Each submodule (Agent, Main, Report, Store) follows a similar pattern (sources, routes, middleware, utilities) that supports separation of concerns.
- Mention that Node.js is used as the runtime for the backend services.
- That Laravel is used for the web frontend, allowing for a clear separation between UI rendering and business logic.
- That the QT framework is used for the cross-platform component; this demonstrates a desktop application component integrated with a web/mobile system (if applicable).

##### Extra Details to Capture
- Configuration/utility components such as common middleware, helper functions, and Swagger API documentation (note the “swagger.json” files in each module). This will emphasize that each service exposes APIs that are documented and standardized.
- That each module contains specialized routes and models (for admin, employee, reports, activities) which is central to the business logic of EmpMonitor.
- Scalability and security by indicating that enterprise-grade security (with middleware for authentication, auditing, and threat detection) is built into the backend modules.

– A centralized Frontend (Laravel based) that hosts employee dashboards and interfaces.
– A modular Backend composed of multiple Node.js-based services (Agent, Main, Report, and Store) that communicate with each other (if needed) and with various databases.
– A dedicated cross-platform desktop component (QT) that provides additional user interfaces or monitoring capabilities.
– Integration with various databases (MongoDB, MySQL, Redis) along with external libraries for analytics and visualization.

## Diagram (Mermaid)

```mermaid
graph TD
    %% User Interface Layer
    subgraph "User Interface Layer"
        F("Frontend (Laravel Web App)"):::frontend
        AEL("Assets & External Libraries"):::asset
    end

    %% Backend Services Layer
    subgraph "Backend Services"
        AServ("Backend - Agent Service"):::backend
        ADB("Agent DB Config"):::backend_config
        MServ("Backend - Main Service"):::backend
        MDB("Main DB Config"):::backend_config
        RServ("Backend - Report Service"):::backend
        RDB("Report DB Config"):::backend_config
        SServ("Backend - Store Service"):::backend
        SDB("Store DB Config"):::backend_config
    end

    %% Databases Layer
    subgraph "Databases"
        MG("MongoDB"):::database
        MY("MySQL"):::database
        RD("Redis"):::database
    end

    %% Cross-Platform Desktop Component
    QT("QT Client"):::qt

    %% Data Flow between UI and Backend Services
    F -->|"REST_API"| AServ
    F -->|"REST_API"| MServ
    F -->|"REST_API"| RServ
    F -->|"REST_API"| SServ
    F -->|"uses"| AEL

    %% Backend Services to their Database Configurations
    AServ --> ADB
    MServ --> MDB
    RServ --> RDB
    SServ --> SDB

    %% Database Configuration to Databases Connections
    ADB -->|"Query"| MG
    ADB -->|"Query"| MY
    ADB -->|"Query"| RD

    MDB -->|"Query"| MG
    MDB -->|"Query"| MY

    RDB -->|"Query"| MG
    RDB -->|"Query"| MY
    RDB -->|"Query"| RD

    SDB -->|"Query"| MG
    SDB -->|"Query"| MY
    SDB -->|"Query"| RD

    %% QT Client Communication with Backend Agent Service
    QT -->|"DirectAPI"| AServ

    %% Click Events
    click F "https://github.com/empcloud/empmonitor/tree/main/Frontend/"
    click AEL "https://github.com/empcloud/empmonitor/tree/main/Frontend/public/assets/"
    click AServ "https://github.com/empcloud/empmonitor/tree/main/Backend/Agent/"
    click MServ "https://github.com/empcloud/empmonitor/tree/main/Backend/Main/"
    click RServ "https://github.com/empcloud/empmonitor/tree/main/Backend/Report/"
    click SServ "https://github.com/empcloud/empmonitor/tree/main/Backend/Store/"
    click ADB "https://github.com/empcloud/empmonitor/tree/main/Backend/Agent/source/database/"
    click MDB "https://github.com/empcloud/empmonitor/tree/main/Backend/Main/source/config/"
    click RDB "https://github.com/empcloud/empmonitor/tree/main/Backend/Report/source/database/"
    click SDB "https://github.com/empcloud/empmonitor/tree/main/Backend/Store/source/database/"
    click QT "https://github.com/empcloud/empmonitor/tree/main/QT/"

    %% Styles
    classDef frontend fill:#FCE4D6,stroke:#333,stroke-width:2px;
    classDef asset fill:#EBDEF0,stroke:#333,stroke-width:2px;
    classDef backend fill:#D6EAF8,stroke:#333,stroke-width:2px;
    classDef backend_config fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef database fill:#D5F5E3,stroke:#333,stroke-width:2px;
    classDef qt fill:#F9E79F,stroke:#333,stroke-width:2px;
```
