# olokreaz/cthpp architecture

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

- Interactive diagram: https://gitdiagram.com/olokreaz/cthpp
- Repository: https://github.com/olokreaz/cthpp

## Overview

##### Project type and purpose
- CTH++ is an open-source command-line tool (CLI) for generating C++ configuration headers at compile-time.
- It parses JSON config files and, using constexpr, emits a .hpp file containing all config values as typed constants.

##### File structure
- Top level:
- CMakeLists.txt – build entry point
- src/ – core implementation
– main.cpp: CLI entry point
– program_options.hpp: argument-parsing definitions
- third-party/libfiglet – submodule used to render ASCII art logo
- .clang-format, .gitignore, LICENSE, NOTICE – project metadata
- No “frontend”/“backend” split; this is a single binary tool.
- CMake integration indicates a build-time component.

##### README for additional insights
- Describes CLI options, JSON schema, and sample generated header.
– CLI parsing
– JSON loading
– Internal config AST/model
– Header code generation
– File output

##### Elements
- Processing modules in another
- Output (generated .hpp) in a distinct style
- External dependency (libfiglet) and build system (CMake) in a third style

##### Final recommendations
- Be detailed: break “Code Generator” into subcomponents if necessary (e.g., namespace emitter, value emitter).
- Compile-time vs. runtime actions (most is compile-time).
- Notes on configuration options (debug vs. release, namespace overrides).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Inputs"
        CLI["CLI Args"]:::input
        JSON["JSON Config File"]:::input
    end

    subgraph "Processing Pipeline"
        Parser["CLI Parser"]:::process
        Loader["JSON Loader/Parser"]:::process
        AST["Config AST/Model"]:::process
        Generator["Code Generator"]:::process
        Writer["File Writer"]:::process
    end

    subgraph "External"
        Figlet["libfiglet"]:::external
        CMake["CMake Build System"]:::external
    end

    subgraph "Output"
        Header["Generated Header (.hpp)"]:::output
    end

    CLI -->|"invokes"| Parser
    JSON -->|"reads file"| Loader
    Parser -->|"passes file path"| Loader
    Loader -->|"produces AST"| AST
    AST -->|"feeds"| Generator
    Generator -->|"emits code"| Writer
    Writer -->|"writes .hpp"| Header
    Parser -->|"renders logo"| Figlet
    CMake -->|"builds modules"| Parser
    CMake -->|"builds modules"| Loader
    CMake -->|"builds modules"| AST
    CMake -->|"builds modules"| Generator
    CMake -->|"builds modules"| Writer

    click Parser "https://github.com/olokreaz/cthpp/blob/master/src/main.cpp"
    click Parser "https://github.com/olokreaz/cthpp/blob/master/src/program_options.hpp"
    click Loader "https://github.com/olokreaz/cthpp/blob/master/src/main.cpp"
    click AST "https://github.com/olokreaz/cthpp/blob/master/src/main.cpp"
    click Generator "https://github.com/olokreaz/cthpp/blob/master/src/main.cpp"
    click Writer "https://github.com/olokreaz/cthpp/blob/master/src/main.cpp"
    click Figlet "https://github.com/olokreaz/cthpp/tree/master/third-party/libfiglet"
    click CMake "https://github.com/olokreaz/cthpp/blob/master/CMakeLists.txt"

    classDef input fill:#b3d9ff,stroke:#000,color:#000;
    classDef process fill:#ccffcc,stroke:#000,color:#000;
    classDef output fill:#ffffcc,stroke:#000,color:#000;
    classDef external fill:#e6e6e6,stroke:#000,color:#000;
```
