# da0-da0/dao-contracts architecture

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

- Interactive diagram: https://gitdiagram.com/da0-da0/dao-contracts
- Repository: https://github.com/da0-da0/dao-contracts

## Overview

- Core Module – Represented by the “dao-dao-core” contract (found under contracts/dao-dao-core) which manages the DAO treasury.
- Voting Modules – These span several directories under contracts/voting (e.g., dao-voting-cw20-staked, dao-voting-cw4, dao-voting-cw721-staked, etc.) and are responsible for determining and managing voting power.
- Proposal Modules – Found under contracts/proposal (e.g., dao-proposal-single, dao-proposal-multiple, dao-proposal-condorcet), these modules handle proposal submission and voting processes.
- Pre-Propose Modules – Under contracts/pre-propose, these modules prepare or vet proposals before they move to the main proposal modules.
- Staking & Distribution Modules – Present in contracts/staking, contracts/distribution, and related directories; these handle reward distributions, staking logic, or other fund management features.
- External Contracts – Located in contracts/external, they provide extended functionality like token swaps, NFT staking, and other integrations.
- Libraries & Reusable Packages – The “packages” directory includes helper libraries (e.g., dao-interface, dao-hooks, dao-dao-macros, cw-denom, etc.) which encapsulate common business logic, interfacing, and testing functionality.
- CI and Testing Infrastructure – The “ci” folder (with integration tests and environment bootstrap code) and “scripts” provide automated testing, deployment, and integration management.

##### Relationships and Interactions
– The Core Module (treasury) is central and interacts with all other modules.
– Voting modules send queries and messages to the Core to check balances or update voting power.
– Proposal modules interact with both the voting modules and the Core to validate proposals and execute fund transfers.
– Pre-propose modules act as an intermediary layer before proposals are accepted.

##### Including Key Technologies and Frameworks
- That the project is written in Rust (evidenced by Cargo.toml files) and uses CosmWasm smart contracts.
- Components like “dao-dao-macros”, “dao-interface”, and “dao-hooks” from the packages directory as libraries that standardize interactions across modules.
- External integrations (e.g., bitsong, cw token swaps, NFT-related contracts) which are under the external directory.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Data & Business Logic Layer
    subgraph "Data & Business Logic Layer"
        %% DAO Core Module
        daoCore["DAO Treasury"]
        
        %% Voting Modules
        subgraph "Voting Modules"
            voting1["CW20 Staked Voting"]
            voting2["CW4 Voting"]
            voting3["CW721 Staked Voting"]
            voting4["CW721 Roles Voting"]
            voting5["ONFT Staked Voting"]
            voting6["Token Staked Voting"]
        end

        %% Proposal Modules
        subgraph "Proposal Modules"
            proposal1["Condorcet Proposal"]
            proposal2["Multiple Proposal"]
            proposal3["Single Proposal"]
        end

        %% Pre-Propose Modules
        subgraph "Pre-Propose Modules"
            prepropose1["Approval Multiple Pre-Propose"]
            prepropose2["Approval Single Pre-Propose"]
            prepropose3["Approver Pre-Propose"]
            prepropose4["Multiple Pre-Propose"]
            prepropose5["Single Pre-Propose"]
        end

        %% Staking & Distribution Modules
        subgraph "Staking & Distribution"
            staking["Staking Modules"]
            distribution["Distribution Modules"]
        end
    end

    %% Extension & Integration Layer
    subgraph "Extension & Integration Layer"
        external["External Contracts"]
        libraries["Libraries & Packages"]
    end

    %% CI & Testing Infrastructure Layer
    subgraph "CI & Testing Infrastructure"
        ciInfra["CI"]
        scriptInfra["Deployment Scripts"]
    end

    %% Interactions - Voting Modules to DAO Core
    voting1 -->|"votingQuery"| daoCore
    voting2 -->|"votingQuery"| daoCore
    voting3 -->|"votingQuery"| daoCore
    voting4 -->|"votingQuery"| daoCore
    voting5 -->|"votingQuery"| daoCore
    voting6 -->|"votingQuery"| daoCore

    %% Interactions - Proposal Modules to DAO Core
    proposal1 -->|"proposalExec"| daoCore
    proposal2 -->|"proposalExec"| daoCore
    proposal3 -->|"proposalExec"| daoCore

    %% Interactions - Pre-Propose Modules to Proposal Modules
    prepropose1 -->|"preValidate"| proposal1
    prepropose2 -->|"preValidate"| proposal2
    prepropose3 -->|"preValidate"| proposal3
    prepropose4 -->|"preValidate"| proposal1
    prepropose5 -->|"preValidate"| proposal3

    %% Interactions - Staking & Distribution to DAO Core
    staking -->|"treasuryUpdate"| daoCore
    distribution -->|"treasuryUpdate"| daoCore

    %% Proposal Modules check Voting Modules
    proposal2 -->|"votingCheck"| voting2

    %% External and Libraries integration with DAO Core
    external -->|"integrationCall"| daoCore
    libraries -->|"commonInterface"| daoCore

    %% CI & Testing interactions with core components (from CI)
    ciInfra -->|"runsTests"| daoCore
    ciInfra -->|"runsTests"| voting1
    ciInfra -->|"runsTests"| proposal1
    ciInfra -->|"runsTests"| prepropose1
    ciInfra -->|"runsTests"| staking
    ciInfra -->|"runsTests"| distribution
    ciInfra -->|"runsTests"| external
    ciInfra -->|"runsTests"| libraries

    %% Deployment Scripts interaction with DAO Core
    scriptInfra -->|"deployExec"| daoCore

    %% Styles
    classDef core fill:#C2FABC,stroke:#333,stroke-width:2px;
    classDef voting fill:#FAD19C,stroke:#333,stroke-width:2px;
    classDef proposal fill:#FFF2B2,stroke:#333,stroke-width:2px;
    classDef prepropose fill:#B2D0FF,stroke:#333,stroke-width:2px;
    classDef staking fill:#D1B2FF,stroke:#333,stroke-width:2px;
    classDef external fill:#FFB2B2,stroke:#333,stroke-width:2px;
    classDef libraries fill:#D9D9D9,stroke:#333,stroke-width:2px;
    classDef ci fill:#BFFCC6,stroke:#333,stroke-width:2px;
    classDef scripts fill:#FFEDB2,stroke:#333,stroke-width:2px;

    %% Class assignments
    class daoCore core;
    class voting1,voting2,voting3,voting4,voting5,voting6 voting;
    class proposal1,proposal2,proposal3 proposal;
    class prepropose1,prepropose2,prepropose3,prepropose4,prepropose5 prepropose;
    class staking,distribution staking;
    class external external;
    class libraries libraries;
    class ciInfra ci;
    class scriptInfra scripts;

    %% Click Events for Data & Business Logic Layer Components
    click daoCore "https://github.com/da0-da0/dao-contracts/tree/development/contracts/dao-dao-core"
    click voting1 "https://github.com/da0-da0/dao-contracts/tree/development/contracts/voting/dao-voting-cw20-staked"
    click voting2 "https://github.com/da0-da0/dao-contracts/tree/development/contracts/voting/dao-voting-cw4"
    click voting3 "https://github.com/da0-da0/dao-contracts/tree/development/contracts/voting/dao-voting-cw721-staked"
    click voting4 "https://github.com/da0-da0/dao-contracts/tree/development/contracts/voting/dao-voting-cw721-roles"
    click voting5 "https://github.com/da0-da0/dao-contracts/tree/development/contracts/voting/dao-voting-onft-staked"
    click voting6 "https://github.com/da0-da0/dao-contracts/tree/development/contracts/voting/dao-voting-token-staked"
    click proposal1 "https://github.com/da0-da0/dao-contracts/tree/development/contracts/proposal/dao-proposal-condorcet"
    click proposal2 "https://github.com/da0-da0/dao-contracts/tree/development/contracts/proposal/dao-proposal-multiple"
    click proposal3 "https://github.com/da0-da0/dao-contracts/tree/development/contracts/proposal/dao-proposal-single"
    click prepropose1 "https://github.com/da0-da0/dao-contracts/tree/development/contracts/pre-propose/dao-pre-propose-approval-multiple"
    click prepropose2 "https://github.com/da0-da0/dao-contracts/tree/development/contracts/pre-propose/dao-pre-propose-approval-single"
    click prepropose3 "https://github.com/da0-da0/dao-contracts/tree/development/contracts/pre-propose/dao-pre-propose-approver"
    click prepropose4 "https://github.com/da0-da0/dao-contracts/tree/development/contracts/pre-propose/dao-pre-propose-multiple"
    click prepropose5 "https://github.com/da0-da0/dao-contracts/tree/development/contracts/pre-propose/dao-pre-propose-single"
    click staking "https://github.com/da0-da0/dao-contracts/tree/development/contracts/staking"
    click distribution "https://github.com/da0-da0/dao-contracts/tree/development/contracts/distribution"

    %% Click Events for Extension & Integration Layer Components
    click external "https://github.com/da0-da0/dao-contracts/tree/development/contracts/external"
    click libraries "https://github.com/da0-da0/dao-contracts/tree/development/packages"

    %% Click Events for CI & Testing Infrastructure Components
    click ciInfra "https://github.com/da0-da0/dao-contracts/tree/development/ci"
    click scriptInfra "https://github.com/da0-da0/dao-contracts/tree/development/scripts"
```
