# fpt-essaady/sysmon-cpp architecture

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

- Interactive diagram: https://gitdiagram.com/fpt-essaady/sysmon-cpp
- Repository: https://github.com/fpt-essaady/sysmon-cpp

## Overview

##### Project type and purpose
- This is a C++-based command-line system monitor (SysMon-cpp) for Linux.
- It reads real‐time metrics (CPU, memory, processes) from /proc, renders them in the terminal and can export to text/CSV.

##### File structure
- Top level:
- .github/ (CI workflow)
- / (public headers: CpuMonitor.h, MemoryMonitor.h, ProcessMonitor.h, SysMon.h)
- src/ (implementation: CpuMonitor.cpp, MemoryMonitor.cpp, ProcessMonitor.cpp, main.cpp)
- tests/ (unit tests, e.g., test_CpuMonitor.cpp)
- CMake build files implied by README
- Patterns:
- Modular OOP: each resource monitor is its own class
- Single binary built via CMake → Make
- Separate unit-test harness

##### README for additional insights
- Confirms modular architecture and CLI interface
- Lists options (--help, --export, --update-interval)
- Usage of C++11+, Linux /proc, CMake, GitHub Actions for CI

##### Be detailed
- Every distinct component (CLI Parser, Controller, each Monitor, Renderer, Exporter, Build, CI, Tests)
- Data flows clearly and annotate any important protocols or file paths (/proc/stat, /proc/meminfo, /proc/[pid]/stat)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Resources
    User["User"]:::external
    OS["Linux /proc"]:::external

    %% Application Components
    CLI["CLI Parser"]:::app
    Ctrl["Controller / Core"]:::app
    subgraph "Monitor Modules"
        CPU["CpuMonitor"]:::app
        MEM["MemoryMonitor"]:::app
        PROC["ProcessMonitor"]:::app
    end
    Renderer["CLI Renderer"]:::app
    Exporter["Data Exporter"]:::app

    %% Build & CI
    subgraph "Build & CI"
        CMake["CMake"]:::build
        Make["Make"]:::build
        Binary["SysMon-cpp Binary"]:::build
        GH["GitHub Actions"]:::build
    end

    %% Test Harness
    subgraph "Test Harness"
        style TestCPU stroke-dasharray: 5 5
        TestCPU["test_CpuMonitor"]:::test
    end

    %% Data Flow
    User -->|"CLI args"| CLI
    CLI -->|"settings"| Ctrl
    Ctrl -->|"poll()"| CPU
    Ctrl -->|"poll()"| MEM
    Ctrl -->|"poll()"| PROC
    CPU -->|"reads /proc/stat"| OS
    MEM -->|"reads /proc/meminfo"| OS
    PROC -->|"reads /proc/[pid]/stat"| OS
    Ctrl -->|"render data"| Renderer
    Ctrl -->|"export data"| Exporter

    %% Build & CI Flow
    CMake --> Make
    Make --> Binary
    GH -->|runs build| Make
    GH -->|runs tests| TestCPU

    %% Click Events
    click CLI "https://github.com/fpt-essaady/sysmon-cpp/blob/main/src/main.cpp"
    click Ctrl "https://github.com/fpt-essaady/sysmon-cpp/blob/main/include/SysMon.h"
    click Ctrl "https://github.com/fpt-essaady/sysmon-cpp/blob/main/src/main.cpp"
    click CPU "https://github.com/fpt-essaady/sysmon-cpp/blob/main/include/CpuMonitor.h"
    click CPU "https://github.com/fpt-essaady/sysmon-cpp/blob/main/src/CpuMonitor.cpp"
    click MEM "https://github.com/fpt-essaady/sysmon-cpp/blob/main/include/MemoryMonitor.h"
    click MEM "https://github.com/fpt-essaady/sysmon-cpp/blob/main/src/MemoryMonitor.cpp"
    click PROC "https://github.com/fpt-essaady/sysmon-cpp/blob/main/include/ProcessMonitor.h"
    click PROC "https://github.com/fpt-essaady/sysmon-cpp/blob/main/src/ProcessMonitor.cpp"
    click Exporter "https://github.com/fpt-essaady/sysmon-cpp/blob/main/include/SysMon.h"
    click Exporter "https://github.com/fpt-essaady/sysmon-cpp/blob/main/src/main.cpp"
    click Renderer "https://github.com/fpt-essaady/sysmon-cpp/blob/main/include/SysMon.h"
    click Renderer "https://github.com/fpt-essaady/sysmon-cpp/blob/main/src/main.cpp"
    click GH "https://github.com/fpt-essaady/sysmon-cpp/tree/main/.github/"
    click TestCPU "https://github.com/fpt-essaady/sysmon-cpp/blob/main/tests/test_CpuMonitor.cpp"

    %% Styles
    classDef app fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef external fill:#90EE90,stroke:#000,stroke-width:1px
    classDef build fill:#FFA500,stroke:#000,stroke-width:1px
    classDef test fill:#FFFFFF,stroke:#000,stroke-width:1px,stroke-dasharray: 5 5
```
