# israpps/romman architecture

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

- Interactive diagram: https://gitdiagram.com/israpps/romman
- Repository: https://github.com/israpps/romman

## Overview

##### Project Type and Purpose
- Romman is a native C++ command‐line tool for creating, extracting, and inspecting PlayStation 2 ROM images (IOPRP files and modules). There is no GUI or network layer; it’s a single executable with a core library and CLI front‐end.

##### File‐Structure Analysis
- Top-level build & config:
- CMakeLists.txt – defines build targets, links sources under src/ with headers under include/
- .github/workflows/ci.yml – CI pipeline for building and testing
- Source code layout:
- / – public headers: ELF parser (ELF.h), ROM abstraction (rom.h), utilities (utils.h), error codes (romman-errno.h), debug, versioning
- src/ – implementation: main.cpp (CLI entry point), rom.cpp (ROM operations), utils.cpp
- This idiom suggests a two‐tier architecture:
- CLI layer (main.cpp + argument parsing + dispatch)
- Core library (rom + ELF + utils + error management)

##### Architectual Patterns & Design Principles
- Single‐executable monolith, layered by responsibility:
- Presentation/CLI layer
- Core library layer with clear API (headers in include/)
- Error‐handling centralized via romman-errno.h
- Build configuration and CI separate from runtime logic

##### Main Components
a. CLI Front‐End
- Parses command‐line flags (`-l`, `-x`, `-g`, `-a`)
- Dispatches to corresponding core functions: list, extract, generate, add
b. Core ROM Manager Library
- rom.cpp/h: high‐level API for reading/writing ROM images
- IOPRP & module handling
- Configuration CSV parser/generator
c. ELF Module Parser
- ELF.h / utils: parses and extracts submodules (handles big/little endian)
d. Utilities
- debug.h: logging support
e. Error Management
- romman-errno.h: defines error codes and error‐to‐message mapping
f. Build & CI Pipeline (external to runtime)
- CMake build graph
- GitHub Actions workflow for continuous integration

##### Relationships & Data Flows
- User CLI → CLI Front‐End → Core Library API
- Core Library ↔ ELF Parser (for module introspection)
- Core Library ↔ Utilities (CRC, date, coloring)
- Core Library ↔ File System (read/write binary ROM, extract modules, write CSV)
- Core Library → Error Manager → CLI Front‐End (error reporting to user)
- Build System (CMake) → compiles src/ + include/ → produces romman executable
- CI Pipeline → triggers CMake build → runs smoke tests (if any)

##### Technologies & Frameworks
- C++17 (assumed from headers/source)
- CMake (build system)
- GitHub Actions (CI)
- CSV parsing: custom, in core library
- Terminal coloring: ANSI codes (Windows 10+ & Unix)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layers and Components
    subgraph "CLI Front-End"
        CLI["CLI Front-End\nsrc/main.cpp\ninclude/main.h"]:::cli
    end

    subgraph "Core ROM Manager Library"
        Core["Core ROM Manager Library\nsrc/rom.cpp\ninclude/rom.h"]:::core
        FileSystem["File System I/O"]:::core
    end

    subgraph "ELF Module Parser"
        ELF["ELF Module Parser\ninclude/ELF.h"]:::core
    end

    subgraph "Utilities & Helpers"
        Utils["Utilities\nsrc/utils.cpp\ninclude/utils.h\ninclude/debug.h\ninclude/version.h"]:::util
        Err["Error Manager\ninclude/romman-errno.h"]:::util
    end

    subgraph "External Infrastructure"
        Build["Build System\nCMakeLists.txt\nmingw-w64-x86_64.cmake"]:::external
        CI["CI Pipeline\n.github/workflows/ci.yml"]:::external
    end

    %% Connections
    CLI -->|"dispatch commands"| Core
    Core -->|"introspect modules"| ELF
    Core -->|"utility calls (CRC, date, color)"| Utils
    Core -->|"file operations (read/write ROM, CSV)"| FileSystem
    Core -->|"return error codes"| Err
    Err -->|"report errors"| CLI

    Build -->|"compiles src/ + include/"| Core
    Build -->|"produces romman executable"| CLI
    CI -->|"triggers build & tests"| Build

    %% Click Events
    click CLI "https://github.com/israpps/romman/blob/main/src/main.cpp"
    click CLI "https://github.com/israpps/romman/blob/main/include/main.h"
    click Core "https://github.com/israpps/romman/blob/main/src/rom.cpp"
    click Core "https://github.com/israpps/romman/blob/main/include/rom.h"
    click ELF "https://github.com/israpps/romman/blob/main/include/ELF.h"
    click Utils "https://github.com/israpps/romman/blob/main/src/utils.cpp"
    click Utils "https://github.com/israpps/romman/blob/main/include/utils.h"
    click Utils "https://github.com/israpps/romman/blob/main/include/debug.h"
    click Err "https://github.com/israpps/romman/blob/main/include/romman-errno.h"
    click Utils "https://github.com/israpps/romman/blob/main/include/version.h"
    click Build "https://github.com/israpps/romman/blob/main/CMakeLists.txt"
    click Build "https://github.com/israpps/romman/blob/main/mingw-w64-x86_64.cmake"
    click CI "https://github.com/israpps/romman/blob/main/.github/workflows/ci.yml"

    %% Styles
    classDef cli fill:#BBDEFB,stroke:#039BE5,color:#000;
    classDef core fill:#C8E6C9,stroke:#388E3C,color:#000;
    classDef util fill:#FFF9C4,stroke:#FBC02D,color:#000;
    classDef external fill:#CFD8DC,stroke:#607D8B,color:#000;
```
