# jdah/archimedes architecture

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

- Interactive diagram: https://gitdiagram.com/jdah/archimedes
- Repository: https://github.com/jdah/archimedes

## Overview

##### And Label Main Components
- Reflection Code Generation (Compile-time)
– Represent the clang plugin located in the “plugin” directory. Note elements like AST traversal, serialization, and code emission (e.g., files like plugin/emit.cpp, plugin/compile.hpp, plugin/invoker.cpp).
– Show how this component is invoked by the clang compiler with specific plugin arguments.
- Core Reflection Library (Headers & Common Logic)
– Illustrate the “include/archimedes” directory and its submodules. These headers form the API clients use for reflection (covering areas such as any, cast, registry, type information, etc.).
– Also include “common” source files (e.g., common/cast.cpp, common/regex.cpp) which provide shared functionality.
- Reflection Runtime Loader
– Identify the “runtime” component (e.g., runtime/archimedes.cpp) responsible for deserializing the generated reflection metadata during program startup using functions such as archimedes::load().
- Supporting Libraries and Dependencies
– Note the “lib” directory dependencies (like lib/fmt and lib/nameof) that support functionality such as formatting and possibly type naming.
- Testing and Examples
– Represent the “test” directory. This verifies all the reflection features and would be beneficial to include as a separate verification/validation component.
- Build and Configuration
– Represent the Makefile and configuration directives from the README that show how to build the plugin, static library, and shared library versions.

##### Relationships and Data Flow
- From the Plugin, show a flow to the reflection metadata (serialized data) that is externally output as an object file.
- Demonstrate how the Reflection Runtime Loader loads this metadata during program initialization.
- Link the Runtime and the API provided by the Header/Core library, indicating that user code (or tests) make calls via the API to query and invoke reflected types and functions.
- That tests validate the end-to-end workflow.

##### Architectural Patterns and Design Principles
- Separation of concerns: compile-time reflection data extraction (via the plugin) is decoupled from the runtime reflection API.
- Use of code generation and serialization to avoid compile-time overhead. The architecture also shows a layered approach with clear API boundaries.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Build and Configuration"]:::config
    B["Clang Compiler/Build Process"]:::compile
    C["Reflection Plugin (AST Traversal & Serialization)"]:::compile
    D["Serialized Reflection Metadata (Object File)"]:::compile
    E["Reflection Runtime Loader (archimedes::load)"]:::runtime
    F["Core Reflection API (Header Files/Common Library)"]:::runtime
    G["Supporting Libraries (fmt, nameof)"]:::support
    H["Test Suite"]:::test

    A -->|"triggers"| B
    B -->|"invokes"| C
    C -->|"generates"| D
    D -->|"loadedBy"| E
    E -->|"populates"| F
    G -->|"supports"| F
    F -->|"queriedBy"| H

    %% Click Events for Reflection Plugin (Compile-time)
    click C "https://github.com/jdah/archimedes/blob/master/plugin/plugin.cpp"
    click C "https://github.com/jdah/archimedes/blob/master/plugin/plugin.hpp"
    click C "https://github.com/jdah/archimedes/blob/master/plugin/emit.cpp"
    click C "https://github.com/jdah/archimedes/blob/master/plugin/emit.hpp"
    click C "https://github.com/jdah/archimedes/blob/master/plugin/compile.hpp"
    click C "https://github.com/jdah/archimedes/blob/master/plugin/invoker.cpp"
    click C "https://github.com/jdah/archimedes/blob/master/plugin/invoker.hpp"
    click C "https://github.com/jdah/archimedes/blob/master/plugin/implicit_function.hpp"
    click C "https://github.com/jdah/archimedes/blob/master/plugin/util.hpp"
    click C "https://github.com/jdah/archimedes/tree/master/plugin/ext"

    %% Click Events for Core Reflection API (Headers & Common Logic)
    click F "https://github.com/jdah/archimedes/tree/master/include/archimedes"
    click F "https://github.com/jdah/archimedes/blob/master/include/archimedes.hpp"
    click F "https://github.com/jdah/archimedes/blob/master/common/any.cpp"
    click F "https://github.com/jdah/archimedes/blob/master/common/cast.cpp"
    click F "https://github.com/jdah/archimedes/blob/master/common/regex.cpp"
    click F "https://github.com/jdah/archimedes/blob/master/common/registry.cpp"

    %% Click Event for Reflection Runtime Loader
    click E "https://github.com/jdah/archimedes/blob/master/runtime/archimedes.cpp"

    %% Click Events for Supporting Libraries
    click G "https://github.com/jdah/archimedes/tree/master/lib/fmt"
    click G "https://github.com/jdah/archimedes/tree/master/lib/nameof"

    %% Click Events for Build and Configuration
    click A "https://github.com/jdah/archimedes/tree/master/Makefile"
    click A "https://github.com/jdah/archimedes/blob/master/README.md"

    %% Click Event for Test Suite
    click H "https://github.com/jdah/archimedes/tree/master/test"

    %% Styles
    classDef compile fill:#add8e6,stroke:#000,stroke-width:2px
    classDef runtime fill:#90ee90,stroke:#000,stroke-width:2px
    classDef test fill:#ffeb99,stroke:#000,stroke-width:2px
    classDef config fill:#f4cccc,stroke:#000,stroke-width:2px
    classDef support fill:#d9ead3,stroke:#000,stroke-width:2px
```
