# parksnoopy/sgb_unlimiter architecture

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

- Interactive diagram: https://gitdiagram.com/parksnoopy/sgb_unlimiter
- Repository: https://github.com/parksnoopy/sgb_unlimiter

## Overview

##### Project type and purpose
- From the README (“사지방 제한 해제 프로그램”) and platform support (x86_64 Windows), this is a small Rust-based CLI/tool that lifts or bypasses certain system-level restrictions (likely Windows process or privilege restrictions). It is not a full-stack web app but a system utility.

##### File structure
- Top-level:
- Cargo.toml / .cargo/ / build.rs — Rust project configuration and custom build script
- src/ — all core logic
- src modules:
- config.rs — reading/parsing configuration
- decode.rs — decoding input or encoded policies
- error.rs — unified error types & handling
- privilige.rs — (privilege) Windows privilege elevation logic
- process.rs — process enumeration or manipulation
- state.rs — internal state machine or execution state
- main.rs — orchestrates the above modules
- assets/ — any static payloads or resource files used at runtime

##### README for additional insights
- Minimal README; no explicit architecture notes beyond purpose. No external services.

a. Main components:
1. CLI Entrypoint (main.rs)
2. Config Loader (config.rs)
3. Decoder (decode.rs)
4. Privilege Manager (privilige.rs)
5. Process Controller (process.rs)
6. State Manager (state.rs)
7. Error Handler (error.rs)
8. External OS APIs (Windows Kernel APIs)
9. Assets (assets/)
b. Relationships & data flow:
1. User invokes binary → CLI Entrypoint module
2. Entrypoint calls Config Loader → yields configuration struct
3. Config passed to Decoder → produces decoded settings or rules
4. Entrypoint invokes Privilege Manager → requests elevated rights
5. With elevated rights, Process Controller enumerates/attaches to target processes
6. State Manager tracks current progress and transitions between “unlocked” vs. “locked” states
7. All modules propagate errors to Error Handler → final error reporting/exit code
8. Asset files read by Config Loader or Decoder as needed
9. All OS calls go through Windows API boundary
c. Architectural patterns / design principles:
- Modular decomposition: each major concern isolated in its own module
- Single responsibility per module (config, decode, privilege, etc.)
- Central error-handling abstraction
- Pipeline / sequential flow managed by main.rs
d. Key technologies & libraries:
- Rust (stable channel), Cargo build system
- build.rs for any compile-time codegen or embedding assets
- Windows-specific FFI (winapi or windows-rs crate)

2. Below it, in a vertical pipeline, arrange: Config Loader → Decoder → Privilege Manager → Process Controller → State Manager.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main pipeline
    Entrypoint["CLI Entrypoint\n(main.rs)"]:::rustModules
    ConfigLoader["Config Loader\n(config.rs)"]:::rustModules
    Decoder["Decoder\n(decode.rs)"]:::rustModules
    PrivilegeManager["Privilege Manager\n(privilige.rs)"]:::osModules
    ProcessController["Process Controller\n(process.rs)"]:::osModules
    StateManager["State Manager\n(state.rs)"]:::rustModules

    %% Error handler off to the side
    ErrorHandler["Error Handler\n(error.rs)"]:::error

    %% External dependencies
    WindowsAPI{{"Windows Kernel API"}}:::external
    Assets[(assets/)]:::external
    BuildScript["Build Script\n(build.rs)"]:::external

    %% Pipeline flow
    Entrypoint -->|"load config"| ConfigLoader
    ConfigLoader -->|"parsed config"| Decoder
    Decoder -->|"decoded rules"| PrivilegeManager
    PrivilegeManager -->|"elevate rights"| ProcessController
    ProcessController -->|"manage processes"| StateManager

    %% Error handling dotted connections
    Entrypoint -.->|error| ErrorHandler
    ConfigLoader -.->|error| ErrorHandler
    Decoder -.->|error| ErrorHandler
    PrivilegeManager -.->|error| ErrorHandler
    ProcessController -.->|error| ErrorHandler
    StateManager -.->|error| ErrorHandler

    %% External interactions
    PrivilegeManager -->|"system calls"| WindowsAPI
    ProcessController -->|"system calls"| WindowsAPI
    ConfigLoader -->|"read assets"| Assets
    Decoder -->|"read assets"| Assets

    %% Build script relation
    BuildScript -->|embed assets| Assets

    %% Click Events
    click Entrypoint "https://github.com/parksnoopy/sgb_unlimiter/blob/main/src/main.rs"
    click ConfigLoader "https://github.com/parksnoopy/sgb_unlimiter/blob/main/src/config.rs"
    click Decoder "https://github.com/parksnoopy/sgb_unlimiter/blob/main/src/decode.rs"
    click PrivilegeManager "https://github.com/parksnoopy/sgb_unlimiter/blob/main/src/privilige.rs"
    click ProcessController "https://github.com/parksnoopy/sgb_unlimiter/blob/main/src/process.rs"
    click StateManager "https://github.com/parksnoopy/sgb_unlimiter/blob/main/src/state.rs"
    click ErrorHandler "https://github.com/parksnoopy/sgb_unlimiter/blob/main/src/error.rs"
    click Assets "https://github.com/parksnoopy/sgb_unlimiter/tree/main/assets/"
    click BuildScript "https://github.com/parksnoopy/sgb_unlimiter/blob/main/build.rs"

    %% Styles
    classDef rustModules fill:#D0E8FF,stroke:#000,stroke-width:1px
    classDef osModules fill:#FFD8B0,stroke:#000,stroke-width:1px
    classDef error fill:#FFC0C0,stroke:#000,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#000,stroke-width:1px
```
