# elkingranja/systoolkit-python architecture

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

- Interactive diagram: https://gitdiagram.com/elkingranja/systoolkit-python
- Repository: https://github.com/elkingranja/systoolkit-python

## Overview

##### Project Type and Purpose
- SysToolKit-Python is a *CLI-based, modular administration, automation, and monitoring toolkit* for Windows and Linux.
- It’s organized as a single, monolithic application that loads discrete “modules” at runtime based on user selection from a text menu.
- Key use cases: system-resource monitoring (CPU, RAM, disk, network), security alerts, backups, user management, scheduled automation, and report generation.

##### File Structure
- **Entry-point**: `main_utf8.py` drives a console menu, reads `config.ini`, and delegates to modules.
- **Modules folder**:
- monitor/
- backup/
- alertas/ (alerts)
- seguridad/ (security)
- users/
- automation/
- logs/
- tools/
- **Config file template**: `config_example.ini` → user copies to `config.ini`.
- **Build scripts**: `build_exe.bat`, `build_exe.sh`, `SysToolKit.spec`, PyInstaller artifacts under `build/` and `dist/`.
- **Standalone helper**: `rootkit_permission_scan.py`, and a stray “Nuevo Documento de texto.txt”.

##### README for Additional Insights
- Confirms Python ≥3.7, CLI menu flow, packaging via PyInstaller.
- Lists core features (monitoring, backups, report generation).
- Mentions external libraries (psutil, fpdf/pdf2docx).

a. **Main Components**
- CLI Frontend (MainController)
- Configuration Manager
- Module Loader / Dispatcher
- Module Groups (each a logical plugin):
- Monitor Services
- Backup Services
- Alerting Services
- Security Services
- User Management Services
- Automation/Scheduler Services
- Log Management Services
- Utility Tools
- Reporting Engine (PDF/HTML generator)
- Logging Subsystem
- Packaging Layer (PyInstaller build)
- External Dependencies: OS APIs, File System, Cron/Task Scheduler, Email/SMTP, Third-party libraries

b. **Relationships & Data Flows**
- User → CLI Frontend → Module Loader
- Module Loader ↔ Configuration Manager (reads thresholds, paths, credentials)
- Each Module ↔ OS APIs (psutil, subprocess, file I/O, user/group APIs)
- Monitoring/Security modules → Logging Subsystem → Log files or real-time alerts
- Backup modules → File System / External Drives
- Automation modules → Cron (Linux) or Task Scheduler (Windows)
- Report Generator ← Modules’ output → PDF/HTML files
- Packaging Layer consumes `main_utf8.py` + modules + dependencies → produces `SysToolKit.exe` or `.pyz`

c. **Architectural Patterns & Principles**
- *Modular/Plugin Architecture*: each functional area lives in its own namespace under `modules/`
- *Separation of Concerns*: CLI, config, business-logic modules, reporting, and packaging are orthogonal.
- *Adapter Pattern*: modules encapsulate OS-specific calls, abstracted behind a common interface.
- *Factory/Dispatcher*: a central loader instantiates modules based on menu selection.

d. **Key Technologies & Frameworks**
- Python ≥3.7
- psutil (resource monitoring)
- fpdf or pdf2docx (reports)
- PyInstaller (packaging)
- ConfigParser (`config.ini`)
- Built-in sched (scheduler) or Windows Task Scheduler via subprocess

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Entry Point & UI
    subgraph "CLI Layer"
        direction TB
        CLI["CLI Frontend\n(MainController)"]:::entry
        Loader["Module Loader\n(Dispatcher)"]:::entry
        Config["Configuration Manager\n(config.ini)"]:::config
    end

    %% Modules
    subgraph "Modules (plugins)"
        direction TB
        subgraph "Monitor Services" 
            direction TB
            MS1["sys_summary.py"]:::monitor
            MS2["network_toolkit.py"]:::monitor
        end
        subgraph "Backup Services"
            direction TB
            BS1["auto_backup.py"]:::backup
            BS2["backup_creator.py"]:::backup
            BS3["restore_backup.py"]:::backup
            BS4["usb_backup.py"]:::backup
        end
        subgraph "Alerting Services"
            direction TB
            AS1["critical_file_watcher.py"]:::alert
            AS2["custom_alert.py"]:::alert
            AS3["disk_health_alert.py"]:::alert
            AS4["process_alert.py"]:::alert
            AS5["usb_alert_config.py"]:::alert
            AS6["user_inactivity_notifier.py"]:::alert
        end
        subgraph "Security Services"
            direction TB
            SS1["auth_fail_monitor.py"]:::security
            SS2["permission_checker.py"]:::security
            SS3["security_summary.py"]:::security
            SS4["user_monitor.py"]:::security
        end
        subgraph "User Management Services"
            direction TB
            US1["crear_creator.py"]:::users
            US2["user_cleaner.py"]:::users
            US3["user_groups.py"]:::users
            US4["user_lister.py"]:::users
        end
        subgraph "Automation/Scheduler Services"
            direction TB
            AT1["auto_update_checker.py"]:::automation
            AT2["scheduled_task_helper.py"]:::automation
            AT3["scheduler.py"]:::automation
            AT4["startup_manager.py"]:::automation
        end
        subgraph "Log Management"
            direction TB
            LM["log_manager.py"]:::logs
        end
        subgraph "Utility Tools"
            direction TB
            UT1["app_installer.py"]:::tools
            UT2["disk_manager.py"]:::tools
            UT3["file_tools.py"]:::tools
        end
    end

    %% Reporting Engine
    Report["Reporting Engine\n(PDF/HTML generator)"]:::report

    %% Packaging Layer
    subgraph "Packaging Layer"
        direction TB
        Spec["SysToolKit.spec"]:::pack
        BE["build_exe.bat/.sh"]:::pack
        Art["build/ (artifacts)"]:::pack
        Dist["dist/SysToolKit.exe/.pyz"]:::pack
    end

    %% Standalone Helper
    Helper["rootkit_permission_scan.py"]:::helper

    %% External Dependencies
    subgraph "External Services & OS"
        direction TB
        OSAPI["OS APIs\n(psutil, subprocess)"]:::external
        FS["File System"]:::external
        SchedulerEXT["Cron/Task Scheduler"]:::external
        SMTP["Email/SMTP"]:::external
        Libs["Third-party libs\n(fpfd/pdf2docx)"]:::external
    end

    %% Flows
    User["User"]:::user -->|selects option| CLI
    CLI -->|"reads config"| Config
    CLI -->|"invokes"| Loader
    Loader -->|"loads settings"| Config
    Loader -->|"dispatches"| MS1 & MS2 & BS1 & BS2 & BS3 & BS4 & AS1 & AS2 & AS3 & AS4 & AS5 & AS6 & SS1 & SS2 & SS3 & SS4 & US1 & US2 & US3 & US4 & AT1 & AT2 & AT3 & AT4 & LM & UT1 & UT2 & UT3

    %% Modules to dependencies
    MS1 & MS2 & SS1 & SS2 & SS3 & SS4 --> OSAPI
    BS1 & BS2 & BS3 & BS4 --> FS
    AT1 & AT2 & AT3 & AT4 --> SchedulerEXT
    AS1 & AS2 & AS3 & AS4 & AS5 & AS6 --> SMTP
    MS1 & MS2 & SS1 & SS2 --> LM
    BS1 & BS2 --> LM
    UT1 & UT2 & UT3 --> FS

    %% Reporting
    MS1 & MS2 & BS1 & AS1 & SS3 --> Report
    Report --> FS

    %% Packaging
    CLI & Loader & Config & MS1 & MS2 & BS1 & BS2 & BS3 & BS4 & AS1 & AS2 & AS3 & AS4 & AS5 & AS6 & SS1 & SS2 & SS3 & SS4 & US1 & US2 & US3 & US4 & AT1 & AT2 & AT3 & AT4 & LM & UT1 & UT2 & UT3 & Spec & BE & Art --> Dist

    %% Helper integration
    Helper --> OSAPI
    Helper --> FS

    %% Click Events
    click CLI "https://github.com/elkingranja/systoolkit-python/blob/main/main_utf8.py"
    click Loader "https://github.com/elkingranja/systoolkit-python/blob/main/main_utf8.py"
    click MS1 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/monitor/sys_summary.py"
    click MS2 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/monitor/network_toolkit.py"
    click BS1 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/backup/auto_backup.py"
    click BS2 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/backup/backup_creator.py"
    click BS3 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/backup/restore_backup.py"
    click BS4 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/backup/usb_backup.py"
    click AS1 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/alertas/critical_file_watcher.py"
    click AS2 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/alertas/custom_alert.py"
    click AS3 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/alertas/disk_health_alert.py"
    click AS4 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/alertas/process_alert.py"
    click AS5 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/alertas/usb_alert_config.py"
    click AS6 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/alertas/user_inactivity_notifier.py"
    click SS1 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/seguridad/auth_fail_monitor.py"
    click SS2 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/seguridad/permission_checker.py"
    click SS3 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/seguridad/security_summary.py"
    click SS4 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/seguridad/user_monitor.py"
    click US1 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/users/crear_creator.py"
    click US2 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/users/user_cleaner.py"
    click US3 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/users/user_groups.py"
    click US4 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/users/user_lister.py"
    click AT1 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/automation/auto_update_checker.py"
    click AT2 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/automation/scheduled_task_helper.py"
    click AT3 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/automation/scheduler.py"
    click AT4 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/automation/startup_manager.py"
    click LM "https://github.com/elkingranja/systoolkit-python/blob/main/modules/logs/log_manager.py"
    click UT1 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/tools/app_installer.py"
    click UT2 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/tools/disk_manager.py"
    click UT3 "https://github.com/elkingranja/systoolkit-python/blob/main/modules/tools/file_tools.py"
    click Spec "https://github.com/elkingranja/systoolkit-python/blob/main/SysToolKit.spec"
    click BE "https://github.com/elkingranja/systoolkit-python/blob/main/build_exe.bat"
    click Art "https://github.com/elkingranja/systoolkit-python/tree/main/build/"
    click Dist "https://github.com/elkingranja/systoolkit-python/blob/main/dist/SysToolKit.exe"
    click Helper "https://github.com/elkingranja/systoolkit-python/blob/main/rootkit_permission_scan.py"

    %% Styles
    classDef entry fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef config fill:#FFD700,stroke:#333,stroke-width:1px
    classDef monitor fill:#FFB6C1,stroke:#333,stroke-width:1px
    classDef backup fill:#FFA07A,stroke:#333,stroke-width:1px
    classDef alert fill:#F4A460,stroke:#333,stroke-width:1px
    classDef security fill:#E6E6FA,stroke:#333,stroke-width:1px
    classDef users fill:#98FB98,stroke:#333,stroke-width:1px
    classDef automation fill:#D8BFD8,stroke:#333,stroke-width:1px
    classDef logs fill:#FFE4B5,stroke:#333,stroke-width:1px
    classDef tools fill:#AFEEEE,stroke:#333,stroke-width:1px
    classDef report fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef pack fill:#90EE90,stroke:#333,stroke-width:1px
    classDef helper fill:#FFDEAD,stroke:#333,stroke-width:1px
    classDef external fill:#DCDCDC,stroke:#333,stroke-width:1px
    classDef user fill:#FFFFFF,stroke:#333,stroke-width:1px
```
