# beautybliss-toml/defi-staking architecture

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

- Interactive diagram: https://gitdiagram.com/beautybliss-toml/defi-staking
- Repository: https://github.com/beautybliss-toml/defi-staking

## Overview

##### Main Components
- On-Chain Program (Smart Contract): Represent the “ohm-fork-defi-staking” program that implements the defi staking logic. Inside this component, include its different modules:
- Meme Coin Staking Module (instructions/meme_coin_staking)
- OHM Staking Module (instructions/ohm_staking)
- Reward Token Staking Module (instructions/reward_token_staking)
- Deployment / Migration Scripts: Include the “migrations” folder (with deploy.ts) to highlight how the program is deployed to the blockchain.
- Client/Integration Layer: Mark the presence of client-side integration elements such as the “package.json”, “tsconfig.json”, and “tests/ohm-fork-defi-staking.ts”, which demonstrate how the system is tested and interacted with from a client perspective.
- Configuration & Build Tools: Note the use of Anchor (via Anchor.toml) and Rust’s Cargo files (Cargo.toml, Cargo.lock, Xargo.toml), pointing to the build and configuration system.

##### Relationships and Interactions
- How each instruction module might interact with on-chain data or state (accounts), which are updated following transactions (implicit data flows within the program).

##### Architectural Patterns and Design Principles
- Modular Decomposition: Emphasize that the different staking strategies are cleanly separated into individual modules. Each module (for meme coin, ohm, and reward staking) is independently managed within the program.
- Clear Separation Between On-Chain Logic and Off-Chain Testing/Deployment: Distinguish components that run on the blockchain (smart contracts) from the client-side and testing scripts.
- Use of Standard Configuration Tools: Note the use of Anchor and Cargo for development, which can be shown as a standardized container/environment for the on-chain program.

##### Relevant Technologies and Frameworks
- Rust and Solana Anchor Framework: Display these as the primary technologies forming the backbone of the program logic.
- TypeScript / Node.js Environment: For the deployment and testing components (indicated by package.json and tsconfig.json).
- Any mention of external documentation (linked in the README) may also be noted to emphasize the project requirements and external dependencies.

##### Final Touches
- Double-check that each file/directory that plays a role in the system is mapped to a corresponding component or role in the architecture, ensuring an accurate representation of data flow and dependencies.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Off-Chain Components"
        subgraph "Client / Integration Layer"
            client1["Client: tests/ohm-fork-defi-staking.ts"]:::offchain
            pkg["Package: package.json"]:::offchain
            tsconf["TS Config: tsconfig.json"]:::offchain
        end
        deploy["Deployment Script: deploy.ts"]:::offchain
        subgraph "Configuration & Build Tools"
            anchor["Anchor.toml"]:::config
            cargo["Cargo.toml"]:::config
            cargolock["Cargo.lock"]:::config
            xargo["Xargo.toml"]:::config
        end
    end

    subgraph "On-Chain Program (Smart Contract)"
        entry["Entry Point: lib.rs"]:::onchain
        meme["Meme Coin Staking Module"]:::onchain
        ohm["OHM Staking Module"]:::onchain
        reward["Reward Token Staking Module"]:::onchain
    end

    %% Off-chain components trigger on-chain operations
    client1 -->|"triggers"| entry
    pkg -->|"initiates"| entry
    tsconf -->|"configures"| entry
    deploy -->|"deploys"| entry
    anchor -->|"builds"| entry
    cargo -->|"builds"| entry
    cargolock -->|"builds"| entry
    xargo -->|"builds"| entry

    %% On-chain program routing to specific staking instructions
    entry -->|"calls"| meme
    entry -->|"calls"| ohm
    entry -->|"calls"| reward

    %% Click Events
    click entry "https://github.com/beautybliss-toml/defi-staking/tree/master/programs/ohm-fork-defi-staking"
    click meme "https://github.com/beautybliss-toml/defi-staking/tree/master/programs/ohm-fork-defi-staking/src/instructions/meme_coin_staking"
    click ohm "https://github.com/beautybliss-toml/defi-staking/tree/master/programs/ohm-fork-defi-staking/src/instructions/ohm_staking"
    click reward "https://github.com/beautybliss-toml/defi-staking/tree/master/programs/ohm-fork-defi-staking/src/instructions/reward_token_staking"
    click deploy "https://github.com/beautybliss-toml/defi-staking/blob/master/migrations/deploy.ts"
    click client1 "https://github.com/beautybliss-toml/defi-staking/blob/master/tests/ohm-fork-defi-staking.ts"
    click pkg "https://github.com/beautybliss-toml/defi-staking/blob/master/package.json"
    click tsconf "https://github.com/beautybliss-toml/defi-staking/blob/master/tsconfig.json"
    click anchor "https://github.com/beautybliss-toml/defi-staking/blob/master/programs/ohm-fork-defi-staking/Anchor.toml"
    click cargo "https://github.com/beautybliss-toml/defi-staking/blob/master/programs/ohm-fork-defi-staking/Cargo.toml"
    click cargolock "https://github.com/beautybliss-toml/defi-staking/blob/master/programs/ohm-fork-defi-staking/Cargo.lock"
    click xargo "https://github.com/beautybliss-toml/defi-staking/blob/master/programs/ohm-fork-defi-staking/Xargo.toml"

    %% Styles
    classDef offchain fill:#ffcc99,stroke:#333,stroke-width:2px,color:#000;
    classDef onchain fill:#add8e6,stroke:#333,stroke-width:2px,color:#000;
    classDef config fill:#90ee90,stroke:#333,stroke-width:2px,color:#000;
```
