# naizo01/oss-rewards-agent architecture

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

- Interactive diagram: https://gitdiagram.com/naizo01/oss-rewards-agent
- Repository: https://github.com/naizo01/oss-rewards-agent

## Overview

##### Project Type & Purpose
- The project is an open source platform that connects contributors with open source projects by linking GitHub issues (with attached crypto rewards) and automating reward distribution.
- The README outlines three major areas: a backend (for server logic, GitHub monitoring, and reward automation), smart contracts (for secure reward management, deployed on multiple blockchains), and a frontend (for user interactions and authentication).

##### Analyzing the File Structure
- Top-Level Directories:
– “backend”: Contains Python code (using Flask and Coinbase AgentKit) to implement donor/agent functions, GitHub monitoring, API endpoints, and utilities.
– “contracts”: Contains Solidity contracts (with deployment scripts, Foundry configuration, and ABIs) that implement functions like lock_reward and claimReward.
– “frontend”: Contains a Next.js-based client, TypeScript components, pages (organized with routes for claim, issue, login, etc.), and hooks/libraries that interact with the backend and blockchain elements.
– “solana”: Contains Solana-specific programs and tests (using Anchor and Cargo) which likely offer an alternative or extended blockchain reward mechanism.
– “public”: Holds static resources and documentation images referenced in the README.

- Architectural Hints:
– The backend is organized into agents (each handling different tasks like initializing and running agents, custom actions for blockchain interactions, and database setup).
– The contracts directory uses subdirectories (deployments, scripts, src) indicative of smart contract lifecycle management.
– In the frontend, components and hooks are clearly separated, showing use of modern web technologies (Next.js, Tailwind, TypeScript).

##### Insights From the README
- It explains the matching of contributors to reward-linked issues via GitHub authentication and secure reward claim mechanisms.

##### Essential Elements
– From the frontend to the backend for user requests.
– From the backend to smart contract layers for reward distribution.
– From GitHub (external) to the backend for authentication and PR verification.
– User interface components
– Backend services
– Blockchain/smart contract components
– External integrations
- Configuration components (like environment settings) if they are critical for understanding deployment interactions.

##### Final Advice
- Be detailed – break down each area into as many components as necessary to capture the full picture of interactions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["Frontend - Next.js Client"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE["Backend - Flask API & Agents"]:::backend
        DB["Database (Agent Data)"]:::database
    end

    %% Smart Contracts Layer
    subgraph "Smart Contracts Layer"
        SC["Smart Contracts - Solidity (Arbitrum/Base)"]:::contract
    end

    %% Solana Layer
    subgraph "Solana Layer"
        SOL["Solana Programs - Rust/Anchor Module"]:::solana
    end

    %% External Services
    subgraph "External Services"
        GH["GitHub Authentication & Issue Monitoring"]:::external
        CB["Coinbase AgentKit Integration"]:::external
        BLK["Blockchain Networks"]:::external
    end

    %% Data Flows and Interactions
    FE -->|"APIcalls"| BE
    FE -->|"UserLogin"| GH

    BE -->|"ValidatesPR"| GH
    GH -->|"WebhookEvents"| BE

    BE -->|"Uses"| CB
    BE -->|"StoresData"| DB

    BE -->|"TriggerRewardClaim"| SC
    BE -->|"TriggerRewardClaim"| SOL

    SC -->|"DeployedOn"| BLK
    SOL -->|"DeployedOn"| BLK

    %% Styles
    classDef frontend fill:#ccf,stroke:#333,stroke-width:2px;
    classDef backend fill:#fcf,stroke:#333,stroke-width:2px;
    classDef database fill:#cff,stroke:#333,stroke-width:2px;
    classDef contract fill:#cfc,stroke:#333,stroke-width:2px;
    classDef solana fill:#f9c,stroke:#333,stroke-width:2px;
    classDef external fill:#fcc,stroke:#333,stroke-width:2px;

    %% Click Events
    click FE "https://github.com/naizo01/oss-rewards-agent/tree/main/frontend/"
    click BE "https://github.com/naizo01/oss-rewards-agent/tree/main/backend/"
    click SC "https://github.com/naizo01/oss-rewards-agent/tree/main/contracts/"
    click SOL "https://github.com/naizo01/oss-rewards-agent/tree/main/solana/"
```
