# hanickadot/compile-time-regular-expressions architecture

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

- Interactive diagram: https://gitdiagram.com/hanickadot/compile-time-regular-expressions
- Repository: https://github.com/hanickadot/compile-time-regular-expressions

## Overview

##### Project type and purpose
- From the file tree and README, this is a header-only C++ library (Compile Time Regular Expressions, “ctre”) that provides compile-time regex parsing/matching built on top of a small CT parser library (`ctll`), plus optional Unicode support via `unicode-db`.
- It’s intended as an open-source developer tool/library, consumable via CMake, Conan, or vcpkg, with a single-header distribution.

##### File structure
- Top-level build and packaging:
- CMakeLists.txt, Makefile, conanfile.py, .travis.yml, .github/workflows/tests.yml
- packaging/ (pkgconfig template), .conan/ (Conan recipe and test package)
- Code:
- /ctll (compile-time parser primitives)
- /ctre (regex engine front-end, actions, atoms, operators)
- /unicode-db (Unicode property database interfaces)
- single-header/ (auto-generated amalgamated headers for distribution)
- Docs and examples: docs/ (Sphinx sources), README.md, NOTES.md
- Tests and benchmarks: tests/ (unit tests, regression tests, benchmarks, CI entrypoints)
- CI/build scripts: .github/, .travis.yml, clang-bench.txt, gcc-bench.txt

##### README for additional insights
- Describes core API (ctre::match/search/etc.), supported features, compiler compatibility, single-header generation, installation via CMake/Conan/vcpkg, and testing.
- Emphasizes two layers: `ctll` (generic CT parser toolkit) and `ctre` (regex grammar + evaluation).

a. Main components
- ctll (compile-time parser toolkit)
- ctre core (grammar definitions, action decorators, evaluation engine)
- unicode-db module (optional Unicode property lookup)
- single-header generator (Makefile/CMake script that combines include/ into `single-header/`)
- Build & Packaging:
– CMake targets (`ctre`, `ctre_unicode`, tests)
– Conan recipe (.conan/)
– vcpkg port
- Documentation generator (Sphinx in docs/)
- Tests & Benchmarks (tests/ and benchmark-exec/)
- CI/CD pipelines (.github/workflows/tests.yml, .travis.yml)
b. Relationships & interactions
- ctll is a prerequisite for ctre – ctre includes ctll headers under include/ctll
- ctre optionally depends on unicode-db when Unicode support is enabled
- single-header generator script reads include/ and outputs the amalgamated headers
- Build system orchestrates compilation of test executables, library targets, generation of single-header, and invocation of packaging recipes
- CI runs build, tests, benchmarks, and single-header regeneration on each push/pull request
- Docs pipeline pulls in API comments from include/ and examples in docs/
c. Architectural patterns & design principles
- Header-only library pattern for zero-link-time dependency
- Compile-time parser combinator pattern (in ctll) layered with regex grammar in ctre
- Optional modules (unicode-db) loaded via CMake options or preprocessor macros
- Single-header “amalgamation” for easy distribution
- Polyglot packaging: CMake, Conan, vcpkg
- CI/CD as code (GitHub workflows, Travis, Conan test_package)
d. Key technologies & frameworks
- C++17/C++20 template metaprogramming (CT parser, fixed_string NTTP)
- CMake and Makefile
- Conan (package recipe + test package)
- vcpkg port (externally maintained)
- Sphinx for documentation (reStructuredText)
- GitHub Actions / Travis CI for continuous integration

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Library Code
    subgraph "Library Code"
        direction TB
        CTLL["ctll (Compile-Time Parser Toolkit)"]:::library
        CTRE["ctre Core (Regex Grammar & Evaluation)"]:::library
    end

    %% Optional Modules
    subgraph "Optional Modules"
        direction TB
        UNIDB["unicode-db Module"]:::optional
    end

    %% Single-Header Generation
    subgraph "Single-Header Generation" 
        direction TB
        AMG["Amalgamation Script"]:::build
        SH_OUT["single-header/ (ctre.hpp, ctre-unicode.hpp, unicode-db.hpp)"]:::build
    end

    %% Build & Packaging
    subgraph "Build & Packaging"
        direction TB
        CMAKE["CMakeLists.txt"]:::build
        MAKE["Makefile"]:::build
        CONAN["conanfile.py"]:::build
        CONAN_HELP[".conan/build.py"]:::build
        CONAN_TP[".conan/test_package/"]:::build
        PKGCFG["packaging/pkgconfig.pc.in"]:::build
    end

    %% Documentation
    subgraph "Documentation"
        direction TB
        DOCS["docs/ (Sphinx Sources)"]:::docs
    end

    %% Tests & Benchmarks
    subgraph "Tests & Benchmarks"
        direction TB
        TESTS_CFG["tests/CMakeLists.txt"]:::tests
        TESTS_DIR["tests/"]:::tests
        BMK1["tests/benchmark/"]:::tests
        BMK2["tests/benchmark-exec/"]:::tests
        BMK3["tests/benchmark-range/"]:::tests
    end

    %% CI/CD Pipelines
    subgraph "CI/CD Pipelines"
        direction TB
        GHA[".github/workflows/tests.yml"]:::ci
        TRAVIS[".travis.yml"]:::ci
    end

    %% Relationships
    CTLL -->|"#include"| CTRE
    UNIDB -->|"Optional #include"| CTRE
    AMG -->|"Reads include/ and outputs"| SH_OUT
    CMAKE -->|"Defines targets for"| CTLL
    CMAKE -->|"Defines targets for"| CTRE
    CMAKE -->|"Optional support for"| UNIDB
    CMAKE -->|"Generates"| SH_OUT
    CMAKE -->|"Builds"| TESTS_CFG
    MAKE -->|"Alias for single-header"| AMG
    CONAN -->|"Uses CMakeLists.txt"| CMAKE
    CONAN -->|"Test package uses"| CONAN_TP
    CMAKE -->|"Includes pkg-config template"| PKGCFG
    DOCS -->|"Sources API from"| CTRE
    DOCS -->|"Includes examples from"| DOCS
    TESTS_CFG -->|"Builds tests in"| TESTS_DIR
    TESTS_CFG -->|"Builds benchmarks in"| BMK1
    TESTS_CFG -->|"Builds exec bench in"| BMK2
    TESTS_CFG -->|"Builds range bench in"| BMK3
    GHA -->|"Runs"| CMAKE
    GHA -->|"Runs"| TESTS_CFG
    GHA -->|"Runs"| MAKE
    GHA -->|"Runs"| AMG
    TRAVIS -->|"Runs"| CMAKE
    TRAVIS -->|"Runs"| TESTS_CFG

    %% Click Events
    click CTLL "https://github.com/hanickadot/compile-time-regular-expressions/blob/main/include/ctll.hpp"
    click CTLL "https://github.com/hanickadot/compile-time-regular-expressions/tree/main/include/ctll/"
    click CTRE "https://github.com/hanickadot/compile-time-regular-expressions/blob/main/include/ctre.hpp"
    click CTRE "https://github.com/hanickadot/compile-time-regular-expressions/tree/main/include/ctre/"
    click UNIDB "https://github.com/hanickadot/compile-time-regular-expressions/blob/main/include/unicode-db.hpp"
    click UNIDB "https://github.com/hanickadot/compile-time-regular-expressions/tree/main/include/unicode-db/"
    click UNIDB "https://github.com/hanickadot/compile-time-regular-expressions/blob/main/include/ctre-unicode.hpp"
    click SH_OUT "https://github.com/hanickadot/compile-time-regular-expressions/tree/main/single-header/"
    click AMG "https://github.com/hanickadot/compile-time-regular-expressions/tree/main/Makefile"
    click AMG "https://github.com/hanickadot/compile-time-regular-expressions/blob/main/CMakeLists.txt"
    click CMAKE "https://github.com/hanickadot/compile-time-regular-expressions/blob/main/CMakeLists.txt"
    click MAKE "https://github.com/hanickadot/compile-time-regular-expressions/tree/main/Makefile"
    click CONAN "https://github.com/hanickadot/compile-time-regular-expressions/blob/main/conanfile.py"
    click CONAN_HELP "https://github.com/hanickadot/compile-time-regular-expressions/blob/main/.conan/build.py"
    click CONAN_TP "https://github.com/hanickadot/compile-time-regular-expressions/tree/main/.conan/test_package/"
    click PKGCFG "https://github.com/hanickadot/compile-time-regular-expressions/blob/main/packaging/pkgconfig.pc.in"
    click DOCS "https://github.com/hanickadot/compile-time-regular-expressions/tree/main/docs/"
    click TESTS_CFG "https://github.com/hanickadot/compile-time-regular-expressions/blob/main/tests/CMakeLists.txt"
    click TESTS_DIR "https://github.com/hanickadot/compile-time-regular-expressions/tree/main/tests/"
    click BMK1 "https://github.com/hanickadot/compile-time-regular-expressions/tree/main/tests/benchmark/"
    click BMK2 "https://github.com/hanickadot/compile-time-regular-expressions/tree/main/tests/benchmark-exec/"
    click BMK3 "https://github.com/hanickadot/compile-time-regular-expressions/tree/main/tests/benchmark-range/"
    click GHA "https://github.com/hanickadot/compile-time-regular-expressions/blob/main/.github/workflows/tests.yml"
    click TRAVIS "https://github.com/hanickadot/compile-time-regular-expressions/blob/main/.travis.yml"

    %% Styles
    classDef library fill:#cce5ff,stroke:#004085,color:#004085;
    classDef optional fill:#d4edda,stroke:#155724,color:#155724;
    classDef build fill:#fff3cd,stroke:#856404,color:#856404;
    classDef docs fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
    classDef tests fill:#f8d7da,stroke:#721c24,color:#721c24;
    classDef ci fill:#e2d6f8,stroke:#5a2d82,color:#5a2d82;
```
