# regolith-labs/ore-app architecture

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

- Interactive diagram: https://gitdiagram.com/regolith-labs/ore-app
- Repository: https://github.com/regolith-labs/ore-app

## Overview

##### Project Overview & Purpose
- ORE App is described as “Liquid digital gold,” and it appears to be a full-stack application that has both web and desktop deliverables. It is built using Rust and the Dioxus framework (as indicated by the dioxus-cli usage) and integrates modern web technologies (Tailwind CSS, WASM, JavaScript for wallet interactions).
- The project seems to implement a decentralized/mining application with modules for wallets, mining operations, token management, and more.

##### Key Components to Identify
a. Frontend/UI Layer:
- Located mainly in the src directory (src/main.rs, src/pages, src/components, src/hooks) which contains many UI components, forms, pages, and navigation elements.
- UI is styled using Tailwind CSS; static assets such as fonts, index.html, and tailwind.css reside in the public folder.
- The use of “hooks” (detailed in src/hooks/) and many UI modules suggests a React-like componentized architecture within Dioxus.

b. Shared/Domain Logic Crates:
- The miner-types and miner-web directories each contain their own Cargo.toml files. These likely encapsulate domain-specific types and web-related business logic respectively, allowing reuse across different parts of the application (or variants of deployment such as desktop vs. web).

c. Server/Backend Component:
- The serve directory contains Rust code (serve/src/main.rs) which is probably used to start a development or production server for web delivery.
- It likely serves static files (found in the public folder) and may act as an API endpoint provider.

d. External Services & Integration Layers:
- The src/gateway directory (with submodules such as kamino, meteora, ore, solana, etc.) represents integration with external blockchain networks or related services. This is critical for operations like wallet transactions and mining.
- The wallet-adapter directory (with JavaScript and Webpack configuration) implies that the project leverages a modern wallet adapter for cryptographic operations on the client side.

e. Configuration & Assets:
- The public/config folder (with YAML files for boosts, pools, tokens) and src/config (with corresponding Rust definitions) provide application configuration.
- Build scripts (script/build.sh) and configuration files (Tailwind config, Dioxus.toml, Cargo files) are present to orchestrate both build steps and deployment.

##### Relationships & Interactions
- The UI (components in src/) directly interacts with state hooks (src/hooks) which manage data flow and lifecycle events.
- UI components request services from the gateway modules (src/gateway) that integrate with external services or blockchain networks.
- The shared crates (miner-types and miner-web) provide reusable types and functionality that can be consumed by both the UI layer and the server.
- The wallet integration encapsulated in wallet-adapter and corresponding wallet hooks in src/components/wallet build a bridge between user actions (e.g., signing transactions) and backend logic.
- The serve component (Rust-based server) is responsible for serving static assets (from public/) and handling API/backend requests.

##### Architectural Patterns and Design Principles
- Component-based UI design using Dioxus, with separation between presentation (src/components, src/pages) and business logic (src/hooks, src/gateway).
- Reusability and modularity achieved by splitting common logic into dedicated crates (miner-types, miner-web) and configuration modules.
- Layered architecture: the UI layer, service/gateway layer, and server layer are clearly separated. This allows the system to support multiple delivery forms (desktop and web) and easy integration with external systems.
- Integration with blockchain or external token services via designated gateway modules and wallet-related components.

a. Begin by identifying and labeling all high-level components:

b. Interactions:
- Shared libraries (miner-types and miner-web) with both the Frontend and the Server to show they provide core logic and types.
- Static assets in the Public folder as resources consumed by the UI and served by the server component.

c. Use Visual Aids:
- Clear labels for all modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend/UI Layer
    subgraph "Frontend/UI Layer"
        UI("UI (Dioxus Components)"):::ui
    end

    %% Shared Domain Logic
    subgraph "Shared Domain Logic"
        MT("Miner Types Logic"):::shared
        MW("Miner Web Logic"):::shared
    end

    %% Server/Backend
    subgraph "Server/Backend"
        Server("Rust Server (Serve)"):::server
    end

    %% External Integrations
    subgraph "External Integrations"
        Gateway("Gateway Integrations"):::external
        Wallet("Wallet Adapter"):::external
    end

    %% Assets & Configuration
    subgraph "Assets & Configuration"
        PublicAssets("Public Assets (Tailwind, index.html)"):::config
        AppConfig("App Configuration"):::config
    end

    %% Build Tools
    subgraph "Build Tools"
        BuildScripts("Build Scripts"):::build
    end

    %% Interactions between components
    UI -->|"uses"| MT
    UI -->|"uses"| MW

    Server -->|"shares_logic"| MT
    Server -->|"shares_logic"| MW

    UI -->|"calls"| Gateway
    UI -->|"calls"| Wallet

    Server -->|"serves"| PublicAssets
    UI -->|"loads"| PublicAssets

    UI -->|"reads"| AppConfig
    Server -->|"reads"| AppConfig

    BuildScripts -->|"builds_UI"| UI
    BuildScripts -->|"builds_Server"| Server

    %% Click Events
    click UI "https://github.com/regolith-labs/ore-app/tree/master/src/"
    click MT "https://github.com/regolith-labs/ore-app/tree/master/miner-types/"
    click MW "https://github.com/regolith-labs/ore-app/tree/master/miner-web/"
    click Server "https://github.com/regolith-labs/ore-app/blob/master/serve/src/main.rs"
    click Gateway "https://github.com/regolith-labs/ore-app/tree/master/src/gateway/"
    click Wallet "https://github.com/regolith-labs/ore-app/tree/master/wallet-adapter/"
    click PublicAssets "https://github.com/regolith-labs/ore-app/tree/master/public/"
    click AppConfig "https://github.com/regolith-labs/ore-app/tree/master/src/config/"
    click BuildScripts "https://github.com/regolith-labs/ore-app/blob/master/script/build.sh"

    %% Styles
    classDef ui fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef shared fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef server fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
    classDef external fill:#E1BEE7,stroke:#8E24AA,stroke-width:2px;
    classDef config fill:#FFF9C4,stroke:#F9A825,stroke-width:2px;
    classDef build fill:#D1C4E9,stroke:#512DA8,stroke-width:2px;
```
