# t9air/klipper_power_resume architecture

> Architecture diagram of the GitHub repository t9air/klipper_power_resume, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/t9air/klipper_power_resume
- Repository: https://github.com/t9air/klipper_power_resume

## Overview

##### Main Components

a) Core System Components:
- Interface Layer (Interface_scripts/)
- Configuration Management (kpr-config/)
- Logging System
- Main Control Script (kpr.sh)

b) External Dependencies:
- Klipper Firmware
- VIRTUAL_SDCARD
- 3D Printer Hardware

##### Data Flow Representation

- User input → Interface scripts
- Interface scripts → Core processing
- Core processing → Logging system
- Core processing → Klipper firmware
- Logging system → Configuration files

##### Component Relationships

Clear connections between:
- Interface scripts and configuration files
- Logging system and G-code processing
- Power resume functionality and printer control

##### Technical Details

- Script execution paths
- Configuration file locations
- Log file management
- G-code modification points
- Recovery procedure flow

Remember to indicate the version control system integration points and the update mechanism (update.sh) as auxiliary components of the system.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef interface fill:#6495ED,stroke:#333,stroke-width:2px
    classDef core fill:#32CD32,stroke:#333,stroke-width:2px
    classDef config fill:#FFD700,stroke:#333,stroke-width:2px
    classDef external fill:#A9A9A9,stroke:#333,stroke-width:2px
    classDef logging fill:#F4A460,stroke:#333,stroke-width:2px
    classDef critical fill:#FF6347,stroke:#333,stroke-width:2px

    %% User Interface Layer
    subgraph Interface
        MENU[Menu Interface]
        GCREATE[Create G-code]
        GEDIT[Edit G-code]
        INSTALL[Installation Manager]
        PRINTER[Printer Selection]
        RESTART[Restart Management]
    end

    %% Core Processing Layer
    subgraph Core
        KPR[Main Control Script]
        UPDATE[Update System]
    end

    %% Configuration Layer
    subgraph Config
        YAML[Configuration YAML]
        LOGGER_CFG[Logger Config]
    end

    %% Logging System
    subgraph Logging
        DYNAMIC[Dynamic Log]
        STATIC[Static Log]
        LOG_SCRIPT[Logging Script]
        UNLOG[Unlog Script]
        FINISHED[Post-Print Processing]
        ADD_LOGS[Add Logs]
    end

    %% External Systems
    subgraph External
        KLIPPER[Klipper Firmware]
        VSDCARD[VIRTUAL_SDCARD]
        PRINTER_HW[3D Printer Hardware]
    end

    %% Relationships
    MENU --> KPR
    GCREATE --> KPR
    GEDIT --> KPR
    INSTALL --> KPR
    PRINTER --> KPR
    RESTART --> KPR

    KPR --> YAML
    KPR --> LOGGER_CFG
    KPR --> LOG_SCRIPT
    KPR --> KLIPPER

    LOG_SCRIPT --> DYNAMIC
    LOG_SCRIPT --> STATIC
    UNLOG --> DYNAMIC
    UNLOG --> STATIC

    KLIPPER --> VSDCARD
    KLIPPER --> PRINTER_HW

    UPDATE --> KPR
    FINISHED --> LOG_SCRIPT
    ADD_LOGS --> LOG_SCRIPT

    %% Click Events
    click MENU "https://github.com/T9Air/Klipper_Power_Resume/blob/main/Interface_scripts/menu.sh"
    click GCREATE "https://github.com/T9Air/Klipper_Power_Resume/blob/main/Interface_scripts/create_gcode.sh"
    click GEDIT "https://github.com/T9Air/Klipper_Power_Resume/blob/main/Interface_scripts/edit_gcode.sh"
    click INSTALL "https://github.com/T9Air/Klipper_Power_Resume/blob/main/Interface_scripts/install.sh"
    click PRINTER "https://github.com/T9Air/Klipper_Power_Resume/blob/main/Interface_scripts/select_printer.sh"
    click RESTART "https://github.com/T9Air/Klipper_Power_Resume/blob/main/Interface_scripts/restart_file.sh"
    click KPR "https://github.com/T9Air/Klipper_Power_Resume/blob/main/kpr.sh"
    click UPDATE "https://github.com/T9Air/Klipper_Power_Resume/blob/main/update.sh"
    click YAML "https://github.com/T9Air/Klipper_Power_Resume/blob/main/config.yaml"
    click LOGGER_CFG "https://github.com/T9Air/Klipper_Power_Resume/blob/main/kpr-config/logger.cfg"
    click DYNAMIC "https://github.com/T9Air/Klipper_Power_Resume/blob/main/kpr-config/dynamic_log.txt"
    click STATIC "https://github.com/T9Air/Klipper_Power_Resume/blob/main/kpr-config/static_log.txt"
    click LOG_SCRIPT "https://github.com/T9Air/Klipper_Power_Resume/blob/main/kpr-config/log.sh"
    click UNLOG "https://github.com/T9Air/Klipper_Power_Resume/blob/main/kpr-config/unlog.sh"
    click FINISHED "https://github.com/T9Air/Klipper_Power_Resume/blob/main/kpr-config/finished.sh"
    click ADD_LOGS "https://github.com/T9Air/Klipper_Power_Resume/blob/main/Interface_scripts/add_logs.sh"

    %% Style Applications
    class MENU,GCREATE,GEDIT,INSTALL,PRINTER,RESTART interface
    class KPR,UPDATE core
    class YAML,LOGGER_CFG config
    class KLIPPER,VSDCARD,PRINTER_HW external
    class DYNAMIC,STATIC,LOG_SCRIPT,UNLOG,FINISHED,ADD_LOGS logging
    class KPR critical
```
