# radsammyt/maker architecture

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

- Interactive diagram: https://gitdiagram.com/radsammyt/maker
- Repository: https://github.com/radsammyt/maker

## Overview

##### Project Type and Purpose
- Maker is a command-line build system (CLI tool) for compiling single-source files into binaries.
- It’s implemented in Rust (primary code under `src/`) and includes a legacy C++ version in `legacy_cpp/` for backward‐compatibility or reference.

##### File Structure
- Top-level:
- Cargo.toml / Cargo.lock → Rust dependency/build configuration
- README.md → user docs & behavior
- legacy_cpp/ → legacy C++ implementation with its own build script (premake5.lua)
- src/ → Rust source:
- main.rs → CLI entrypoint
- maker.rs → core logic (config parsing, file discovery, command formatting, process execution)
- The legacy_cpp module: separate subproject using Premake5 to build `main.cpp` and a parsing library (`parsing.hpp`).

##### Extract Key Architecture Notes from the README
- Maker reads one or more source files, finds/merges configuration from a local or global “maker” config file, then compiles each file according to specified compiler commands/formats.
- Supports multiple “config” blocks per language, inline comment flags, and defaults for each file.

##### Main Components
a. CLI Interface (Rust binary)
b. Configuration Manager
c. File Scanner / Source File Enumerator
d. Command Formatter & Macro Processor
e. Process Executor (spawns gcc, tcc, cc, etc.)
f. Output Manager (writes compiled binaries to `bin/`)
g. External Tools (system compilers)
h. Legacy C++ Subproject (optional reference component)

##### Interactions and Data Flow
- User invokes `maker` CLI → main.rs
- CLI → Configuration Manager: locate & parse `maker` files (local or `~/maker`)
- Configuration Manager → File Scanner: discover source files from CLI args
- File Scanner → Command Formatter: apply extension-based and comment-based flags
- Command Formatter → Process Executor: spawn external compiler processes with final command strings
- Process Executor → File System: write compiled binaries into `bin/`

##### Highlighted Architectural Patterns & Principles
- Separation of Concerns: distinct modules for config parsing, scanning, formatting, execution
- Plugin-style configuration: extensible “extension” blocks in a config file
- External process orchestration: isolating compiler invocations from core logic
- Dual implementation: Rust core + legacy C++ reference

##### Relevant Technologies & Frameworks
- Rust (Cargo for build, crates for argument parsing & file I/O)
- C++ and Premake5 for the legacy subproject
- System compilers: gcc, tcc, cc
- Filesystem for config discovery and binary output

##### Checklist
[ ] Annotations for config lookup order and comment-flag processing

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Rust Components
    subgraph "Rust Core" 
        direction TB
        CLI["CLI Interface"]:::rust
        ConfigMgr["Configuration Manager"]:::rust
        FileScanner["File Scanner"]:::rust
        CmdFormatter["Command Formatter & Macro Processor"]:::rust
        ProcExecutor["Process Executor"]:::rust
        OutputMgr["Output Manager"]:::rust
    end

    %% File System and Config Files
    subgraph "File System" 
        direction TB
        LocalConfig["Local maker file"]:::fs
        GlobalConfig["Global ~/maker file"]:::fs
        SourceFiles["Source Files"]:::fs
        BinDir["bin/ (Output Binaries)"]:::fs
    end

    %% External Compilers
    subgraph "External Compilers" 
        direction TB
        GCC["gcc"]:::external
        TCC["tcc"]:::external
        CC["cc"]:::external
    end

    %% Legacy C++ Subproject
    subgraph "Legacy C++ Subproject" 
        direction TB
        LegacyDir["legacy_cpp/"]:::cpp
        Premake["Premake5 Build Script"]:::cpp
        LegacyCLI["C++ CLI Entry (main.cpp)"]:::cpp
        ParsingLib["Parsing Library (parsing.hpp)"]:::cpp
    end

    %% Rust Build Config & Docs
    Cargo["Cargo.toml / Cargo.lock"]:::rust
    README["README.md"]:::fs

    %% Flow
    User["User"]:::external -->|invokes| CLI
    CLI -->|locates/reads| ConfigMgr
    ConfigMgr -->|reads| LocalConfig
    ConfigMgr -->|fallback reads| GlobalConfig
    ConfigMgr -->|provides config| FileScanner
    FileScanner -->|discovers| SourceFiles
    FileScanner -->|passes files| CmdFormatter
    CmdFormatter -->|formats command| ProcExecutor
    ProcExecutor -->|spawns| GCC
    ProcExecutor -->|spawns| TCC
    ProcExecutor -->|spawns| CC
    ProcExecutor -->|writes binary to| OutputMgr
    OutputMgr -->|outputs to| BinDir

    %% Legacy flow (dashed)
    LegacyDir -.-> Premake
    Premake --> LegacyCLI
    LegacyCLI --> ParsingLib

    %% Click Events
    click CLI "https://github.com/radsammyt/maker/blob/main/src/main.rs"
    click ConfigMgr "https://github.com/radsammyt/maker/blob/main/src/maker.rs"
    click FileScanner "https://github.com/radsammyt/maker/blob/main/src/maker.rs"
    click CmdFormatter "https://github.com/radsammyt/maker/blob/main/src/maker.rs"
    click ProcExecutor "https://github.com/radsammyt/maker/blob/main/src/maker.rs"
    click OutputMgr "https://github.com/radsammyt/maker/blob/main/src/maker.rs"
    click Cargo "https://github.com/radsammyt/maker/blob/main/Cargo.toml"
    click README "https://github.com/radsammyt/maker/blob/main/README.md"
    click LegacyDir "https://github.com/radsammyt/maker/tree/main/legacy_cpp/"
    click Premake "https://github.com/radsammyt/maker/blob/main/legacy_cpp/premake5.lua"
    click LegacyCLI "https://github.com/radsammyt/maker/blob/main/legacy_cpp/src/main.cpp"
    click ParsingLib "https://github.com/radsammyt/maker/blob/main/legacy_cpp/src/parsing.hpp"

    %% Styles
    classDef rust fill:#ADD8E6,stroke:#0366d6,color:#000
    classDef cpp fill:#D3D3D3,stroke:#666,color:#000
    classDef external fill:#98FB98,stroke:#228B22,color:#000
    classDef fs fill:#FFDAB9,stroke:#CD853F,color:#000
```
