# blessnetwork/javy-bless-plugins architecture

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

- Interactive diagram: https://gitdiagram.com/blessnetwork/javy-bless-plugins
- Repository: https://github.com/blessnetwork/javy-bless-plugins

## Overview

Step 1: Identify the Project Type and Purpose
- This project is a collection of Rust-based plugins built for the Javy runtime. It provides three distinct plugins—BlessLLM, BlessFetch, and BlessCrypto—that enable interactions with large language models, perform HTTP/fetch operations, and leverage crypto functionalities.
- The README reveals that these plugins target both browser and native runtimes and are built using cargo (with a Wasm32 target) and javy CLI commands for initializing and building plugin Wasm modules.

Step 2: Analyze the File Structure
- Key Directories and Files:
– The top-level files (Cargo.toml, Cargo.lock, Makefile, rust-toolchain.toml) confirm this is a Rust project.
– The “src” folder is subdivided into modules: “crypto”, “fetch”, and “llm”. Each has a mod.rs file to establish the module boundaries.
– JavaScript files (e.g., in “src/crypto/crypto.js”, “src/fetch/fetch.js”, and “examples/llm.js”) indicate that some plugin logic or sample code may interface with JavaScript.
– The “.github” directory with CI and release workflows and the Makefile hint at standard build, test, and release automation.

Step 3: Extract Architectural Insights from the README
- The README clarifies how the build process works:
– First, a cargo build (targeted at wasm32-wasip1) compiles the Rust code into a WASM artifact (bless_plugins.wasm).
– Next, the javy CLI is used: javy init-plugin wraps the Wasm to prepare it as a runtime plugin, and javy build compiles JavaScript (from, e.g., examples/llm.js) using the plugin.
- The plugins are intended to extend the Javy runtime, which means they must integrate seamlessly with both browser and native environments.

A. Identify the Main Components
1. Rust Source Modules – Break this out into:
- BlessCrypto module (src/crypto)
- BlessFetch module (src/fetch)
- BlessLLM module (src/llm)
2. Build Pipeline – Represent the transformation process:
- Cargo Build Process: converts Rust source code into a WASM binary (bless_plugins.wasm).
- javy init-plugin: wraps the WASM binary to conform to the plugin interface.
- javy build: consumes sample JavaScript (e.g., examples/llm.js) alongside the plugin to produce a final Wasm module (e.g., bless-llm.wasm).
3. Runtimes and Deployment – Show the environments where the plugins run:
- Browser Runtime
- Native Runtime
4. External Tools & Integrations:
- Javy CLI tool
- Build automation tools (e.g., Makefile, GitHub Actions)

B. Determine Relationships and Interactions
- How the Rust modules (crypto, fetch, llm) feed into the cargo build process to create the initial WASM artifact.
- Final output to both target environments (browser and native) to highlight dual runtime support.

C. Highlight Architectural Patterns and Design Principles
- Modular design: Each functionality (crypto, fetching, LLM) is encapsulated in its own module, promoting separation of concerns.
- Build Pipeline Integration: There is a clear, linear build process that transforms source code into a deployable WASM plugin.
- Compatibility & Extensibility: The use of javy CLI for plugin initialization emphasizes the standardization required for integration with a runtime that supports multiple environments.

D. Include Relevant Technologies and Frameworks
- Rust (cargo, rust-toolchain)
- WebAssembly (Wasm modules)
- javy CLI (plugin initialization and build steps)
- JavaScript (used in examples and potentially for bridging module functionalities)
- CI/CD with GitHub Actions

For this project (Rust-based plugins for the Javy runtime):
– Emphasize the clear separation between the core plugin modules (crypto, fetch, LLM) and the build pipeline that converts source code into a WASM plugin.
– Highlight the role of javy CLI commands which serve as the critical integration point between the native Rust code and the target runtime environments.

- Clear Labels: Each component (Rust Source Modules, Cargo Build Process, javy init-plugin, javy build, Final WASM Plugins, Browser Runtime, Native Runtime) should be distinctly labeled.
– From Rust source modules (crypto, fetch, llm) to “Cargo Build”
– From “Cargo Build” to “javy init-plugin”
– From “javy init-plugin” to “javy build”
– From “javy build” to the final WASM plugin artifacts which integrate with both Browser and Native runtimes.
– Build and integration tools (e.g., ellipses or rounded rectangles).

Step 7: In Summary – Detailed Guidelines for the Principal Software Engineer
1. Start by drawing a block for “Rust Source Code” that includes three sub-blocks: BlessCrypto, BlessFetch, and BlessLLM (reflecting the directory structure in “src”).
5. Finally, branch out from the final plugin output to two separate nodes for “Browser Runtime” and “Native Runtime,” indicating compatibility.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Rust Source Code"
        BC["BlessCrypto"]:::source
        BF["BlessFetch"]:::source
        BL["BlessLLM"]:::source
    end

    subgraph "Build Pipeline"
        CBP["Cargo Build Process"]:::build
        IWP["Initial Wasm Plugin (bless_plugins.wasm)"]:::build
        JI["javy init-plugin"]:::build
        JB["javy build"]:::build
        FWP["Final Wasm Plugin (bless-llm.wasm)"]:::output
        EJS["Example JS"]:::js
    end

    subgraph "Deployment"
        BROWSER["Browser Runtime"]:::deploy
        NATIVE["Native Runtime"]:::deploy
    end

    subgraph "Build Tools"
        MF["Makefile"]:::automation
        GHA["GitHub Actions (.github/workflows)"]:::automation
    end

    %% Connections: Rust Modules to Build Pipeline
    BC -->|"compile"| CBP
    BF -->|"compile"| CBP
    BL -->|"compile"| CBP

    %% Build Pipeline Flow
    CBP -->|"wasm_build"| IWP
    IWP -->|"plugin_wrap"| JI
    JI -->|"js_integration"| JB
    EJS -->|"supplies_js"| JB
    JB -->|"produce"| FWP

    %% Deployment Connections
    FWP -->|"deploy"| BROWSER
    FWP -->|"deploy"| NATIVE

    %% Build Tools Automating Build Process
    MF ---|"automates"| CBP
    GHA ---|"automates"| CBP

    %% Click Events
    click BC "https://github.com/blessnetwork/javy-bless-plugins/tree/main/src/crypto"
    click BF "https://github.com/blessnetwork/javy-bless-plugins/tree/main/src/fetch"
    click BL "https://github.com/blessnetwork/javy-bless-plugins/tree/main/src/llm"
    click EJS "https://github.com/blessnetwork/javy-bless-plugins/blob/main/examples/llm.js"
    click CBP "https://github.com/blessnetwork/javy-bless-plugins/blob/main/Cargo.toml"
    click MF "https://github.com/blessnetwork/javy-bless-plugins/tree/main/Makefile"
    click GHA "https://github.com/blessnetwork/javy-bless-plugins/tree/main/.github/workflows"

    %% Styles
    classDef source fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef build fill:#A3E4D7,stroke:#1D8348,stroke-width:2px;
    classDef output fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef deploy fill:#F5B7B1,stroke:#943126,stroke-width:2px;
    classDef automation fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef js fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
```
