# atreyasuraj/middleware-sdk architecture

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

- Interactive diagram: https://gitdiagram.com/atreyasuraj/middleware-sdk
- Repository: https://github.com/atreyasuraj/middleware-sdk

## Overview

##### Main Components

a. Core Components:
- Shared Library Core (shared_lib)
- Arithmetic Module
- Crypto Module
- Web Bindings (shared_lib_web)
- UniFFI Binding Generator
- Generated Language Bindings
- Python Bindings
- TypeScript/WASM Bindings

##### Specific Elements

Build Process Flow:
**shared_lib (Rust)**
- → uniffi-bindgen → Python Bindings (.py + .dylib)
- → wasm-pack → TypeScript/WASM Bindings

Component Details:
- Technology labels: "Rust", "UniFFI", "wasm-pack"
- File extensions for generated artifacts
- Build tool dependencies

##### Additional Visualization Elements

- Build-time dependencies
- Runtime dependencies
- Generated artifacts
- Core components
- Build tools

##### Implementation Notes

Annotations for:
- Build commands
- Required environment setup
- Language-specific usage examples
- File placement requirements

##### TypeScript/WASM Binding Generation

Use clear boundaries between sections while showing their interconnections.

##### Technical Details to Highlight

- That shared_lib is the source of truth
- That uniffi-bindgen is a separate tool
- Demonstrate the parallel nature of Python and TypeScript binding generation
- Version compatibility notes if applicable

- The separation between core implementation and language bindings
- The automated nature of binding generation
- The different build processes for Python vs. TypeScript
- The runtime usage patterns for each target language

This system design should help developers understand both the build-time architecture and the runtime usage patterns of the generated bindings.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Core Implementation
    subgraph Core
        SharedLib["Shared Library Core"]
        ArithModule["Arithmetic Module"]
        CryptoModule["Crypto Module"]
        SharedLib --> ArithModule
        SharedLib --> CryptoModule
    end

    %% Binding Generation Tools
    UniFfi["UniFFI Binding Generator"]
    WasmPack["wasm-pack"]

    %% Web Bindings
    WebBindings["Web Bindings"]

    %% Generated Bindings
    subgraph PythonBindings
        PyBindings["Python Bindings (.py)"]
        DylibFile["Dynamic Library (.dylib)"]
    end

    subgraph TypeScriptBindings
        TSBindings["TypeScript Definitions (.d.ts)"]
        WasmModule["WASM Module (.wasm)"]
    end

    %% Configurations
    Config["Project Configuration"]
    WebConfig["Web Bindings Configuration"]
    BindgenConfig["Binding Generator Configuration"]

    %% Relationships
    SharedLib --> UniFfi
    SharedLib --> WasmPack
    UniFfi --> PyBindings
    UniFfi --> DylibFile
    WasmPack --> WebBindings
    WebBindings --> TSBindings
    WebBindings --> WasmModule

    %% Click Events
    click SharedLib "https://github.com/atreyasuraj/middleware-sdk/blob/main/shared_lib/src/lib.rs"
    click ArithModule "https://github.com/atreyasuraj/middleware-sdk/blob/main/shared_lib/src/arithmetic.rs"
    click CryptoModule "https://github.com/atreyasuraj/middleware-sdk/blob/main/shared_lib/src/crypto.rs"
    click WebBindings "https://github.com/atreyasuraj/middleware-sdk/blob/main/shared_lib_web/src/lib.rs"
    click UniFfi "https://github.com/atreyasuraj/middleware-sdk/blob/main/uniffi-bindgen/src/main.rs"
    click Config "https://github.com/atreyasuraj/middleware-sdk/blob/main/Cargo.toml"
    click WebConfig "https://github.com/atreyasuraj/middleware-sdk/blob/main/shared_lib_web/Cargo.toml"
    click BindgenConfig "https://github.com/atreyasuraj/middleware-sdk/blob/main/uniffi-bindgen/Cargo.toml"

    %% Styling
    classDef core fill:#f9f,stroke:#333,stroke-width:2px
    classDef tool fill:#bbf,stroke:#333,stroke-width:2px
    classDef binding fill:#bfb,stroke:#333,stroke-width:2px
    classDef config fill:#fbb,stroke:#333,stroke-width:2px

    class SharedLib,ArithModule,CryptoModule core
    class UniFfi,WasmPack tool
    class PyBindings,DylibFile,TSBindings,WasmModule,WebBindings binding
    class Config,WebConfig,BindgenConfig config

    %% Legend
    subgraph Legend
        CoreComp["Core Component"]:::core
        ToolComp["Build Tool"]:::tool
        BindingComp["Generated Binding"]:::binding
        ConfigComp["Configuration"]:::config
    end
```
