# abdlrhman08/testnet architecture

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

- Interactive diagram: https://gitdiagram.com/abdlrhman08/testnet
- Repository: https://github.com/abdlrhman08/testnet

## Overview

##### Project Type & Purpose
- This is a full‑stack DevOps dashboard.
- Frontend: React SPA for real‑time log/status display.
- Backend: Rust/Axum server orchestrating tests, exposing REST/WebSocket.
- Worker nodes: Rust “node” binaries running tests.
- net_interface crate provides Protobuf/gRPC layer between orchestrator and workers.
- External dev‑ops tools (e.g., Jenkins, Docker) trigger tests via webhooks.

##### File Structure
- client/ → React application (Vite, JSX, CSS, WebSocket client).
- master/ → Rust Axum server (“main.rs”), scheduler.rs, client.rs (logstream, response).
- net_interface/ → service.proto, build.rs, lib.rs → gRPC interface definitions.
- node/ → Rust test runner (“tester.rs”), main.rs, lib.rs → implements gRPC client/server.
- Top‑level Cargo.toml ties crates together.

##### Core Components to Model
a. Frontend (React SPA)
– Serves HTML/CSS/JS over HTTP.
– Opens WebSocket to backend for real‑time updates.
b. API Gateway / Orchestrator (Axum server in master/)
– HTTP REST endpoints: add projects (via webhook), query status.
– WebSocket endpoint: pushes live logs & status updates to clients.
– Scheduler module: manages test jobs, state, back‑pressure.
– Log streaming module: formats and forwards logs.
c. Network Interface (net_interface crate)
– Protobuf service definitions for RPC between orchestrator & workers.
– gRPC stubs generated at build time.
d. Worker Nodes (node/ crate)
– gRPC server or client (depending on design) listening for test jobs.
– Executes test suites, streams log lines back via gRPC.
– Reports final status.
e. External DevOps Tools
– CI/CD system (e.g., Jenkins, GitHub Actions)
– Docker containers/agents spinning up worker nodes.
– Invoke orchestrator’s REST webhook to kick off tests.

##### Relationships & Data Flows
1. CI/CD → (HTTP POST /webhook) → Orchestrator
2. Orchestrator Scheduler → (gRPC call via net_interface) → Worker Node
3. Worker Node → (gRPC stream) → Orchestrator (log lines & status)
4. Orchestrator → (WebSocket frames) → React Frontend
5. Frontend → (REST fetch) → Orchestrator for historical data/projects

##### Architectural Patterns & Design Principles
- Separation of concerns: UI vs. orchestration vs. network interface vs. execution.
- Asynchronous, event‑driven: Tokio runtime powering WebSocket & gRPC streams.
- Modular crates: master (server), net_interface (API schema), node (executor), client (UI).
- Protocol‑driven interfaces: Protobuf & gRPC ensure language‑agnostic RPC.

##### Technologies & Frameworks to Annotate
- React, Vite, FontAwesome – in frontend.
- Axum, Tokio, Rust std OS primitives – in orchestrator.
- Protobuf & Tonic (or similar) – in net_interface.
- Rust async executables – in worker nodes.
- Docker, Jenkins (or any CI tool) – external pipeline.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External DevOps Tools
    subgraph "External DevOps Tools" 
        direction TB
        CI["CI/CD Pipeline"]:::external
        Docker["Docker Agents"]:::external
    end

    %% Orchestrator Layer
    subgraph "Orchestrator (master/)" 
        direction TB
        HTTP["HTTP REST & WebSocket Handler"]:::backend
        Scheduler["Scheduler Module"]:::backend
        LogStream["Log Streaming Module"]:::backend
        State["In-Memory State"]:::backend
    end

    %% Network Interface Layer
    subgraph "Network Interface (net_interface/)" 
        direction TB
        ProtoDef["service.proto"]:::rpc
        GRPCStub["gRPC Stubs (build.rs → lib.rs)"]:::rpc
    end

    %% Worker Nodes Layer
    subgraph "Worker Node (node/)" 
        direction TB
        Tester["tester.rs"]:::worker
        NodeMain["main.rs"]:::worker
        NodeLib["lib.rs"]:::worker
    end

    %% Frontend Layer
    subgraph "Frontend (client/)" 
        direction TB
        HTML["index.html"]:::frontend
        ViteConfig["vite.config.js"]:::frontend
        MainJSX["main.jsx"]:::frontend
        AppJSX["App.jsx"]:::frontend
        AppCSS["App.css"]:::frontend
        IndexCSS["index.css"]:::frontend
        Assets["assets/"]:::frontend
    end

    %% Connections
    CI -->|"HTTP POST /webhook (REST)"| HTTP
    Docker -->|"spin up nodes"| NodeMain
    HTTP -->|"Scheduler.enqueueJob() (direct call)"| Scheduler
    Scheduler -->|"gRPC call"| ProtoDef
    ProtoDef -->|"uses stubs"| GRPCStub
    GRPCStub -->|"dispatch job"| NodeMain
    NodeMain -->|"runs tests"| Tester
    Tester -->|"gRPC stream logs/status"| LogStream
    LogStream -->|"format & forward"| HTTP
    HTTP -->|"WebSocket frames (WS)"| MainJSX
    MainJSX -->|"REST fetch historical data"| HTTP

    %% Click Events - Frontend
    click HTML "https://github.com/abdlrhman08/testnet/blob/main/client/index.html"
    click ViteConfig "https://github.com/abdlrhman08/testnet/blob/main/client/vite.config.js"
    click MainJSX "https://github.com/abdlrhman08/testnet/blob/main/client/src/main.jsx"
    click AppJSX "https://github.com/abdlrhman08/testnet/blob/main/client/src/App.jsx"
    click AppCSS "https://github.com/abdlrhman08/testnet/blob/main/client/src/App.css"
    click IndexCSS "https://github.com/abdlrhman08/testnet/blob/main/client/src/index.css"
    click Assets "https://github.com/abdlrhman08/testnet/tree/main/client/src/assets/"

    %% Click Events - Orchestrator
    click HTTP "https://github.com/abdlrhman08/testnet/blob/main/master/src/main.rs"
    click Scheduler "https://github.com/abdlrhman08/testnet/blob/main/master/src/scheduler.rs"
    click LogStream "https://github.com/abdlrhman08/testnet/blob/main/master/src/client/logstream.rs"
    click State "https://github.com/abdlrhman08/testnet/blob/main/master/src/lib.rs"
    click HTTP "https://github.com/abdlrhman08/testnet/blob/main/master/src/client.rs"
    click HTTP "https://github.com/abdlrhman08/testnet/blob/main/master/src/client/response.rs"
    click HTTP "https://github.com/abdlrhman08/testnet/blob/main/master/Cargo.toml"

    %% Click Events - Network Interface
    click ProtoDef "https://github.com/abdlrhman08/testnet/blob/main/net_interface/proto/service.proto"
    click GRPCStub "https://github.com/abdlrhman08/testnet/blob/main/net_interface/build.rs"
    click GRPCStub "https://github.com/abdlrhman08/testnet/blob/main/net_interface/src/lib.rs"
    click GRPCStub "https://github.com/abdlrhman08/testnet/blob/main/net_interface/Cargo.toml"

    %% Click Events - Worker Node
    click NodeMain "https://github.com/abdlrhman08/testnet/blob/main/node/src/main.rs"
    click Tester "https://github.com/abdlrhman08/testnet/blob/main/node/src/tester.rs"
    click NodeLib "https://github.com/abdlrhman08/testnet/blob/main/node/src/lib.rs"
    click NodeMain "https://github.com/abdlrhman08/testnet/blob/main/node/Cargo.toml"

    %% Styles
    classDef external fill:#cccccc,stroke:#999999,color:#333333;
    classDef backend fill:#8fd4b8,stroke:#2d6a4f,color:#ffffff;
    classDef rpc fill:#ffa94d,stroke:#b04000,color:#ffffff;
    classDef worker fill:#ffe066,stroke:#b58900,color:#333333;
    classDef frontend fill:#74c0fc,stroke:#1864ab,color:#ffffff;
```
