# fschuetz04/simcpp20 architecture

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

- Interactive diagram: https://gitdiagram.com/fschuetz04/simcpp20
- Repository: https://github.com/fschuetz04/simcpp20

## Overview

##### Project type and purpose
- SimCpp20 is an open-source, header-only discrete-event simulation framework written in modern C++20.
- Its purpose is to let users define coroutine-based “processes” that yield to a central scheduler, modeling events, resources, and queues over simulated time.

##### File structure
- Top-level files and dirs:
- CMakeLists.txt / CMakeSettings.json: cross-platform build integration
- /fschuetz04/simcpp20: core library headers (awaitable.hpp, event.hpp, process.hpp, promise_type.hpp, resource.hpp, simulation.hpp, store.hpp, value_event.hpp, value_process.hpp)
- examples: sample apps showing clocks, stores, resources, processes
- tests: unit tests for awaitables, resources, stores
- No backend/frontend split—instead it’s a single library plus clients (examples/tests).
- The core is implemented as C++20 coroutines with a custom promise_type and scheduler living in simulation.hpp.

##### README for additional insights
- The README calls out: “processes are defined as coroutines returning simcpp20::process<>,” “requires C++20,” “use CMake with FetchContent.”

##### Detail is key—capture all essential elements
- Lifecycle of a process: spawn → wait → resume → complete
- Internal data structures: priority queue for events, resource queues, store buffers
- Build integration: CMake target fschuetz04::simcpp20 consumed by examples and tests

## Diagram (Mermaid)

```mermaid
graph TB
    %% Clients
    subgraph "Clients"
        Examples["Examples / Client Processes"]:::external
        Tests["Unit Tests"]:::external
    end

    %% Build System
    subgraph "Build System"
        MainCMake["CMakeLists.txt"]:::build
        Settings["CMakeSettings.json"]:::build
        ExCMake["examples/CMakeLists.txt"]:::build
        TestCMake["tests/CMakeLists.txt"]:::build
        LibCMake["include/fschuetz04/simcpp20/CMakeLists.txt"]:::build
    end

    %% Library Core
    subgraph "SimCpp20 Library"
        Simulation["Simulation Engine\n(scheduler + time mgr)"]:::core
        EventQ["Event Queue\n(priority queue)"]:::core
        Process["Process Coroutine"]:::coroutine
        Promise["Promise Type"]:::coroutine
        Awaitables["Awaitables\n(timeout, event, resource, store,\nvalue_event, value_process)"]:::coroutine
        ResourceMgr["Resource Manager"]:::resource
        Store["Store (FIFO queue)"]:::resource
    end

    %% Relationships
    Examples -->|"create simcpp20::simulation"| Simulation
    Tests -->|"link & test library"| Simulation
    MainCMake -->|defines target| Simulation
    LibCMake -->|exports target| Simulation
    ExCMake -->|build examples| Examples
    TestCMake -->|build tests| Tests

    Simulation -->|manages| EventQ
    Simulation -->|"spawn simcpp20::process"| Process
    Simulation -->|"run() → pop events"| EventQ
    Simulation -->|"resume coroutine"| Process

    Process -->|"uses promise_type"| Promise
    Process -->|"co_await actions"| Awaitables

    Awaitables -->|"schedule wake-up"| Simulation
    Awaitables -->|"acquire/release"| ResourceMgr
    Awaitables -->|"get/put"| Store

    ResourceMgr -->|"block/resume"| Process
    Store -->|"block/resume"| Process

    %% Click Events
    click Examples "https://github.com/fschuetz04/simcpp20/tree/main/examples/"
    click Tests "https://github.com/fschuetz04/simcpp20/tree/main/tests/"
    click MainCMake "https://github.com/fschuetz04/simcpp20/blob/main/CMakeLists.txt"
    click Settings "https://github.com/fschuetz04/simcpp20/blob/main/CMakeSettings.json"
    click ExCMake "https://github.com/fschuetz04/simcpp20/blob/main/examples/CMakeLists.txt"
    click TestCMake "https://github.com/fschuetz04/simcpp20/blob/main/tests/CMakeLists.txt"
    click LibCMake "https://github.com/fschuetz04/simcpp20/blob/main/include/fschuetz04/simcpp20/CMakeLists.txt"
    click Simulation "https://github.com/fschuetz04/simcpp20/blob/main/include/fschuetz04/simcpp20/simulation.hpp"
    click Process "https://github.com/fschuetz04/simcpp20/blob/main/include/fschuetz04/simcpp20/process.hpp"
    click Promise "https://github.com/fschuetz04/simcpp20/blob/main/include/fschuetz04/simcpp20/promise_type.hpp"
    click Awaitables "https://github.com/fschuetz04/simcpp20/blob/main/include/fschuetz04/simcpp20/awaitable.hpp"
    click EventQ "https://github.com/fschuetz04/simcpp20/blob/main/include/fschuetz04/simcpp20/event.hpp"
    click ResourceMgr "https://github.com/fschuetz04/simcpp20/blob/main/include/fschuetz04/simcpp20/resource.hpp"
    click Store "https://github.com/fschuetz04/simcpp20/blob/main/include/fschuetz04/simcpp20/store.hpp"
    click Awaitables "https://github.com/fschuetz04/simcpp20/blob/main/include/fschuetz04/simcpp20/value_event.hpp"
    click Awaitables "https://github.com/fschuetz04/simcpp20/blob/main/include/fschuetz04/simcpp20/value_process.hpp"

    %% Styles
    classDef core fill:#BBDEFB,stroke:#42A5F5;
    classDef resource fill:#C8E6C9,stroke:#66BB6A;
    classDef coroutine fill:#FFE0B2,stroke:#FB8C00;
    classDef external fill:#EEEEEE,stroke:#BDBDBD;
    classDef build fill:#F0F4C3,stroke:#CDDC39;
```
