# patrulek/modernrx architecture

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

- Interactive diagram: https://gitdiagram.com/patrulek/modernrx
- Repository: https://github.com/patrulek/modernrx

## Overview

##### Main Components

a) Core Components:
- Hasher System (Main Interface)
- Virtual Machine
- Dataset Generator
- Cryptographic Components (AES, Blake2b, Argon2d)
- JIT Compiler System
- Memory Management System

b) Supporting Components:
- Hardware Abstraction Layer
- Threading System
- Instruction Set Handlers (AVX512, AVX2, SSE)

**Top Level (Interface Layer):**
- [Hasher Interface]

**Middle Level (Core Processing):**
- [Virtual Machine] ←→ [JIT Compiler]
- [Dataset Generator]

**Bottom Level (Foundation):**
- [Cryptographic Primitives]
- [Hardware Abstraction]
- [Memory Management]

##### Specific Implementation Details

- Hardware-specific optimizations (AVX512, AES)
- Threading model for parallel processing
- Memory management system (virtual memory, heap allocation)

##### Additional Elements

Annotations for:
- Performance-critical paths
- Hardware requirements
- Threading boundaries
- Memory access patterns

Create distinct sections for:
a) Runtime Flow:
- Input processing
- Hash computation
- Output generation

b) Initialization Flow:
- Dataset generation
- JIT compilation
- Resource allocation

##### Technical Details to Highlight

- Interaction between the BytecodeCompiler and VirtualMachine
- Dataset generation pipeline
- Demonstrate the parallel processing model
- Memory management strategies

##### Notes Section

A notes section describing:
- Hardware requirements (AVX512F, AVX512VL, AVX512DQ, AES)
- Critical performance paths
- Memory requirements
- Threading model

Remember to emphasize:
- The self-contained nature of the implementation
- Modern C++ features usage
- Performance optimization paths
- Hardware-specific implementations

This will create a comprehensive system design that accurately represents the project's architecture while maintaining clarity and usefulness for development purposes.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef core fill:#2374f7,color:white
    classDef crypto fill:#2ecc71,color:white
    classDef hardware fill:#f1c40f,color:black
    classDef support fill:#95a5a6,color:white
    classDef critical fill:#e74c3c,color:white

    %% Interface Layer
    subgraph Interface
        Hasher["Hasher System"]:::core
    end

    %% Core Processing Layer
    subgraph CoreProcessing
        VM["Virtual Machine"]:::core
        JIT["JIT Compiler"]:::core
        Dataset["Dataset Generator"]:::core
        Superscalar["Superscalar Execution"]:::core
    end

    %% Foundation Layer
    subgraph Cryptography
        AES["AES"]:::crypto
        Blake2b["Blake2b"]:::crypto
        Argon2d["Argon2d"]:::crypto
    end

    subgraph HardwareAbstraction
        CPU["CPU Info"]:::hardware
        Intrinsics["Intrinsics"]:::hardware
        InstructionSets["Instruction Sets"]:::hardware
    end

    subgraph MemoryManagement
        VirtualMem["Virtual Memory"]:::support
        HeapArray["Heap Array"]:::support
        AlignedAlloc["Aligned Allocator"]:::support
    end

    subgraph Threading
        ThreadSystem["Threading System"]:::support
    end

    %% Relationships
    Hasher --> VM
    Hasher --> Dataset
    VM <--> JIT
    VM --> Superscalar
    Dataset --> Argon2d
    Dataset --> Blake2b
    
    VM --> AES
    VM --> Blake2b
    VM --> VirtualMem
    
    JIT --> InstructionSets
    JIT --> CPU
    
    InstructionSets --> Intrinsics
    
    Dataset --> ThreadSystem
    VM --> ThreadSystem
    
    VirtualMem --> AlignedAlloc
    HeapArray --> AlignedAlloc

    %% Click events
    click Hasher "https://github.com/patrulek/modernRX/blob/master/modernRX/hasher.hpp"
    click VM "https://github.com/patrulek/modernRX/blob/master/modernRX/virtualmachine.hpp"
    click JIT "https://github.com/patrulek/modernRX/blob/master/modernRX/bytecodecompiler.hpp"
    click Dataset "https://github.com/patrulek/modernRX/blob/master/modernRX/dataset.hpp"
    click Superscalar "https://github.com/patrulek/modernRX/blob/master/modernRX/superscalar.hpp"
    click AES "https://github.com/patrulek/modernRX/blob/master/modernRX/aes.hpp"
    click Blake2b "https://github.com/patrulek/modernRX/blob/master/modernRX/blake2b.hpp"
    click Argon2d "https://github.com/patrulek/modernRX/blob/master/modernRX/argon2d.hpp"
    click CPU "https://github.com/patrulek/modernRX/blob/master/modernRX/cpuinfo.hpp"
    click Intrinsics "https://github.com/patrulek/modernRX/blob/master/modernRX/intrinsics.hpp"
    click InstructionSets "https://github.com/patrulek/modernRX/blob/master/modernRX/avx512.hpp"
    click VirtualMem "https://github.com/patrulek/modernRX/blob/master/modernRX/virtualmem.hpp"
    click HeapArray "https://github.com/patrulek/modernRX/blob/master/modernRX/heaparray.hpp"
    click AlignedAlloc "https://github.com/patrulek/modernRX/blob/master/modernRX/alignedallocator.hpp"
    click ThreadSystem "https://github.com/patrulek/modernRX/blob/master/modernRX/thread.hpp"

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Cryptographic"]:::crypto
        L3["Hardware"]:::hardware
        L4["Support Systems"]:::support
    end
```
