# hackdays-io/toban architecture

> Architecture diagram of the GitHub repository hackdays-io/toban, 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/hackdays-io/toban
- Repository: https://github.com/hackdays-io/toban

## Overview

##### Main Components
- Frontend Application: Located in pkgs/frontend. This includes the user interface built with a modern JavaScript framework and routing (pages, components) and integrations with wallet services and blockchain APIs.
- Smart Contracts: Found in pkgs/contract. This contains Solidity (or similar) contracts that implement core logic (BigBang, FractionToken, Hats, Splits, modules, etc.). It also includes deployment scripts, upgrade scripts, and testing.
- CLI Tool: In pkgs/cli. Provides command-line commands to interact with smart contracts, process deployments, and manage other tasks related to the blockchain.
- Documentation/Whitepaper Site: Under pkgs/document (and docs folder at the root). This is built with Docusaurus and includes guides, how-to documents, and other developer/user resources.

##### Relationships and Interactions
- The Frontend interacts directly with the smart contracts. It uses wallet integrations (pkgs/frontend/hooks/useWallet.ts) to perform transactions (e.g., registering contributions and rewards distribution).
- The CLI tool provides a developer-facing interface for executing commands that interact with both smart contracts and potentially external services. It wraps around modules and services that handle tasks like deployment, contract upgrades, or wallet interactions.
- There are deployment pipelines defined through GitHub workflows (inside .github/workflows) that build, test, and deploy parts of the system. These CI/CD components ensure consistency in the deployment process.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The system clearly splits user interface, smart contract logic, indexing, and tooling functionalities.
- Integration of External Blockchain Services: Use of environment variables indicates a design that integrates multiple external services (wallets, IPFS, blockchain networks, etc.) making the system event-driven and decentralized.
- CI/CD Pipeline Integration: The use of GitHub workflows and other configuration files (lefthook.yaml, pnpm-workspace.yaml) shows an emphasis on automated testing, deployment, and quality checks.

##### Relevant Technologies, Frameworks, and Libraries
- Frontend: Vite, Remix, React, GraphQL, and GraphQL code generation; CSS and emotion for styling.
- Smart Contracts: Hardhat (with its configuration present), Solidity (contracts, OpenZeppelin libraries), and deployment helpers.
- CLI: TypeScript-based CLI that likely interacts with blockchain via modules and services built using libraries like viem.
- Documentation: Docusaurus configuration and custom React components.
- External integrations include services like Pinata, Goldsky, Alchemy, ENS, etc.

## Diagram (Mermaid)

```mermaid
flowchart TD
    CICDPipeline("CI/CD Pipeline"):::cd
    FrontendUI(("Frontend UI")):::frontend
    SmartContracts["Smart Contracts"]:::backend
    CLITool{CLI Tool}:::cli
    SubgraphIndexer["Subgraph Indexer"]:::backend
    DocumentationSite(("Documentation Site")):::doc

    subgraph "External Services"
        ExternalWallet["Wallet Services"]:::external
        ExternalIPFS["IPFS/Pinata"]:::external
        ExternalBlockchain["Blockchain Providers"]:::external
        ExternalENS["ENS"]:::external
    end

    %% CI/CD triggers deployment
    CICDPipeline -->|"deploys"| FrontendUI
    CICDPipeline -->|"deploys"| SmartContracts
    CICDPipeline -->|"deploys"| SubgraphIndexer

    %% Frontend interactions
    FrontendUI -->|"walletTx"| SmartContracts
    FrontendUI <-->|"queryData"| SubgraphIndexer

    %% Smart Contracts interactions
    SmartContracts -->|"emitEvents"| SubgraphIndexer
    CLITool <-->|"manageContracts"| SmartContracts

    %% External integrations with Frontend and Smart Contracts
    ExternalWallet -->|"integrates"| FrontendUI
    ExternalWallet -->|"integrates"| SmartContracts
    ExternalIPFS -->|"integrates"| FrontendUI
    ExternalIPFS -->|"integrates"| SmartContracts
    ExternalBlockchain -->|"integrates"| SmartContracts
    ExternalBlockchain -->|"integrates"| FrontendUI
    ExternalENS -->|"integrates"| SmartContracts

    %% Documentation as informational resource
    DocumentationSite -.->|"docs"| FrontendUI

    %% Click Events
    click FrontendUI "https://github.com/hackdays-io/toban/tree/main/pkgs/frontend"
    click SmartContracts "https://github.com/hackdays-io/toban/tree/main/pkgs/contract"
    click CLITool "https://github.com/hackdays-io/toban/tree/main/pkgs/cli"
    click SubgraphIndexer "https://github.com/hackdays-io/toban/tree/main/pkgs/subgraph"
    click DocumentationSite "https://github.com/hackdays-io/toban/tree/main/pkgs/document"
    click CICDPipeline "https://github.com/hackdays-io/toban/tree/main/.github/workflows"

    %% Styles
    classDef frontend fill:#ffcccc,stroke:#990000,stroke-width:2px;
    classDef backend fill:#ccffcc,stroke:#006600,stroke-width:2px;
    classDef cli fill:#ffffcc,stroke:#999900,stroke-width:2px;
    classDef cd fill:#cce5ff,stroke:#003366,stroke-width:2px;
    classDef doc fill:#ffebcc,stroke:#cc6600,stroke-width:2px;
    classDef external fill:#e6ccff,stroke:#6600cc,stroke-width:2px;
```
