# ronin-co/blade architecture

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

- Interactive diagram: https://gitdiagram.com/ronin-co/blade
- Repository: https://github.com/ronin-co/blade

## Overview

##### Project type and purpose
- This is a full-stack React framework/library (“RONIN Blade”) implemented in TypeScript and distributed via Bun.
- Purpose: Provide zero-config instant web apps with built-in React hooks, file-based routing, server/client components, data fetching/mutation, and deployment as a request/response worker plus static assets.

##### File structure
- Top-level:
- `.github/workflows/*` – CI/CD for publishing and validating releases
- `examples/` – two sample apps (“basic” and “advanced”) using Blade
- `private/` – core implementation modules, subdivided into `client/`, `server/`, `shell/`, `universal/`
- `public/` – the public API surfaces clients import (mirrors `private/`)
- `tests/` – fixtures and unit tests
- `package.json`, `bun.lock`, `biome.json`, `tsconfig.json`, `vitest.config.ts` – build/test configuration
- Patterns:
- Monorepo-style separation of core implementation (`private`) from exported API (`public`)
- File-based routing (`private/server/pages`, `examples/*/pages`)
- Clear separation of concerns: client-only code, server-only code, universal utilities
- Shell orchestrator (`private/shell`) handles build, routing, and worker generation

##### Key insights from README
- Built on Bun runtime
- Exposes programmatic APIs via React hooks (server: `use`, client: `useMutation`, universal: `useLocation`, etc.)
- Outputs a request/response worker plus static files for deployment anywhere
- Zero-config file-based routing, automatic REST API generation, built-in Tailwind support
- Data flows synchronously on the server, async behind the scenes, no client data waterfalls

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Build & Tooling"
        DeveloperCLI["Developer CLI"]:::tooling
        ShellOrchestrator["Shell Orchestrator"]:::tooling
        BuildBundler["Build & Bundler"]:::tooling
    end

    subgraph "Core Implementation"
        CoreClientModules["Core Client Modules"]:::client
        CoreServerModules["Core Server Modules"]:::backend
        CoreUniversalModules["Core Universal Modules"]:::universal
    end

    subgraph "Public API Surfaces"
        PublicClientAPI["Public Client API Surface"]:::client
        PublicServerAPI["Public Server API Surface"]:::backend
        PublicUniversalAPI["Public Universal API Surface"]:::universal
    end

    RequestWorker["Request/Response Worker"]:::backend
    StaticAssets["Static Assets"]:::client
    ClientBrowser["Client Browser"]:::client
    RuntimeEnv{{"Runtime Environment"}}:::external
    ExternalDB(("External Database")):::external
    Examples["Examples (basic & advanced)"]:::external

    DeveloperCLI -->|"invoke init/dev"| ShellOrchestrator
    ShellOrchestrator -->|"compile & bundle"| BuildBundler
    BuildBundler -->|"emit worker code"| RequestWorker
    BuildBundler -->|"emit frontend bundles"| StaticAssets
    BuildBundler -->|"generate APIs"| PublicClientAPI
    BuildBundler -->|"generate APIs"| PublicServerAPI
    BuildBundler -->|"generate APIs"| PublicUniversalAPI

    RuntimeEnv -->|"HTTP request"| RequestWorker
    RequestWorker -->|"route & invoke"| CoreServerModules
    CoreServerModules -->|"DB queries"| ExternalDB
    RequestWorker -->|"stream HTML & payload"| ClientBrowser

    ClientBrowser -->|"render & hooks"| CoreClientModules
    ClientBrowser -->|"REST mutation calls"| RequestWorker

    Examples -->|"use public APIs"| PublicClientAPI
    Examples -->|"use public APIs"| PublicServerAPI
    Examples -->|"use public APIs"| PublicUniversalAPI

    click DeveloperCLI "https://github.com/ronin-co/blade/blob/main/package.json"
    click ShellOrchestrator "https://github.com/ronin-co/blade/tree/main/private/shell"
    click BuildBundler "https://github.com/ronin-co/blade/blob/main/bunfig.toml"
    click CoreClientModules "https://github.com/ronin-co/blade/tree/main/private/client"
    click CoreServerModules "https://github.com/ronin-co/blade/tree/main/private/server"
    click CoreUniversalModules "https://github.com/ronin-co/blade/tree/main/private/universal"
    click PublicClientAPI "https://github.com/ronin-co/blade/tree/main/public/client"
    click PublicServerAPI "https://github.com/ronin-co/blade/tree/main/public/server"
    click PublicUniversalAPI "https://github.com/ronin-co/blade/tree/main/public/universal"
    click RequestWorker "https://github.com/ronin-co/blade/tree/main/private/server/worker"
    click StaticAssets "https://github.com/ronin-co/blade/tree/main/private/client/assets"
    click Examples "https://github.com/ronin-co/blade/tree/main/examples/basic"

    classDef tooling fill:#ADD8E6,stroke:#0000FF
    classDef backend fill:#90EE90,stroke:#008000
    classDef client fill:#FFA500,stroke:#FF8C00
    classDef universal fill:#FFD700,stroke:#DAA520
    classDef external fill:#D3D3D3,stroke:#A9A9A9
```
