# decentdao/decent-contracts architecture

> Architecture diagram of the GitHub repository decentdao/decent-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/decentdao/decent-contracts
- Repository: https://github.com/decentdao/decent-contracts

## Overview

##### Project Type & Purpose
- This is a specialized smart contracts repository focused on governance – it implements the Azorius Protocol (a Safe module patterned after Zodiac and inspired by Usul from SekerDAO). Its purpose is to serve as a modular backend for DAOs, handling proposals and delegating voting to various BaseStrategy implementations.
- The project includes deployment scripts for several networks (e.g., mainnet, optimism, polygon, sepolia) and extensive tests. It is intended for use both as a standalone repository and as an npm package, to be consumed by other projects.

##### File Structure
a. Contracts Structure:
- The main logic is under the “contracts” folder. Notice further subdivisions:
- “deployables” – these are the primary deployable contract implementations (Azorius, ERC20, FreezeGuard, etc.).
- “interfaces” – contains interface definitions (for Decent, ERC6551, Hats, Sablier, etc.) that support composability and integration with external protocols.
- “mocks” – mock contracts for testing specific scenarios.
- “singletons” and “utilities” – helper contracts that serve as supporting infrastructure.
b. Deployment and Testing:
- There’s a “deploy” directory containing TypeScript deployment scripts (organized into “core” and “helpers”) that coordinate how contracts are deployed.
- “deployments” holds output artifacts (JSON files) for different networks, which signifies that the project supports multiple blockchain environments.
- “test” directory clearly separates tests for various contracts (deployables, modules, strategies, singletons) ensuring robust verification of functionality.
c. CI/CD and Configuration:
- Configuration files like “hardhat.config.ts”, “package.json”, and several configuration files for linting (.eslintrc.json), formatting (.prettierrc), and node versions show standard development practices.
- GitHub workflows under the “.github/workflows” directory indicate automated testing, syntax checking, and publishing steps.

a. Components to Include:
- Smart Contracts – break these into logical groups:
- Core Governance Module: Azorius contract (central manager) and its associated BaseStrategy implementations (voting modules).
- Deployable Contracts: ERC20Claim, Freeze Voting/Guard contracts, modules (account-abstraction, autonomous-admin, etc.), and strategies contracts.
- Interfaces and Singletons: Representing external connection points and supporting records.
- Deployment Infrastructure:
- Deployment Scripts (“deploy/core” and “deploy/helpers”) that manage the sequence of contract deployments.
- Deployment Artifacts: JSON files under “deployments” for different networks (Base, Mainnet, Optimism, Polygon, Sepolia) capturing deployed addresses, configuration, and input details.
- Testing and CI:
- Test Suites showing how each module is verified.
- GitHub CI workflows and scripts for continuous integration and publishing.
b. Relationships and Data Flow:
- Testing components become “consumers” of the contracts, validating behavior and upgradeability, and can be shown separately linked to the respective contract modules.
- External dependencies such as the Hardhat framework, deployment commands, and verification (Etherscan) can be represented as external services/tools.
c. Architectural Patterns & Design Principles:
- Modular design: The separation into deployables, interfaces, mocks, and singletons shows a modular approach enabling easy swapping or upgrading of contract components.
- Separation of concerns: The clear distinction between deployment logic, contract code, and testing artifacts.
- Extensibility: Provided by interfaces and multiple strategy implementations, which allow DAOs to customize governance features.

- Create adjacent clusters for supporting contracts (interfaces, singletons, deployables) grouped by purpose.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Smart Contracts"
        A["Azorius Contract"]:::smartContracts
        B["VotesERC20 Strategy"]:::smartContracts
        C["LinearERC20Voting Strategy"]:::smartContracts
        D["ERC20Claim Contract"]:::smartContracts
        E["ERC20FreezeVoting Contract"]:::smartContracts
        F["MultisigFreezeGuard Contract"]:::smartContracts
        G["Interfaces"]:::smartContracts
        H["Singleton Contracts"]:::smartContracts
        I["Utilities Contracts"]:::smartContracts
        J["Mock Contracts"]:::smartContracts
    end

    subgraph "Deployment Infrastructure"
        K["Deployment Scripts"]:::deployment
        L["Deployment Artifacts"]:::deployment
    end

    subgraph "Testing/CI"
        M["Test Suites"]:::testing
        N["GitHub Workflows"]:::ci
        O["Hardhat Config"]:::ci
        P["Package Config"]:::ci
    end

    %% Relationships within Smart Contracts
    A -->|"governs"| B
    A -->|"governs"| C

    %% Deployment Scripts deploy contracts and generate artifacts
    K -->|"deploys"| A
    K -->|"deploys"| B
    K -->|"deploys"| C
    K -->|"deploys"| D
    K -->|"deploys"| E
    K -->|"deploys"| F
    K -->|"deploys"| G
    K -->|"deploys"| H
    K -->|"deploys"| I
    K -->|"deploys"| J
    K -->|"generates"| L

    %% CI/CD and Testing relationships
    N -->|"runs"| M
    O -->|"configures"| N
    P -->|"configures"| N
    M -->|"tests"| A
    M -->|"tests"| B
    M -->|"tests"| C
    M -->|"tests"| D
    M -->|"tests"| E
    M -->|"tests"| F

    %% Click Events
    click A "https://github.com/decentdao/decent-contracts/blob/develop/deploy/core/007_deploy_Azorius.ts"
    click B "https://github.com/decentdao/decent-contracts/blob/develop/deploy/core/008_deploy_VotesERC20.ts"
    click C "https://github.com/decentdao/decent-contracts/blob/develop/deploy/core/009_deploy_LinearERC20Voting.ts"
    click D "https://github.com/decentdao/decent-contracts/blob/develop/deploy/core/001_deploy_ERC20Claim.ts"
    click E "https://github.com/decentdao/decent-contracts/blob/develop/deploy/core/003_deploy_ERC20FreezeVoting.ts"
    click F "https://github.com/decentdao/decent-contracts/blob/develop/deploy/core/005_deploy_MultisigFreezeGuard.ts"
    click G "https://github.com/decentdao/decent-contracts/tree/develop/contracts/interfaces"
    click H "https://github.com/decentdao/decent-contracts/tree/develop/contracts/singletons"
    click I "https://github.com/decentdao/decent-contracts/tree/develop/contracts/utilities"
    click J "https://github.com/decentdao/decent-contracts/tree/develop/contracts/mocks"
    click K "https://github.com/decentdao/decent-contracts/tree/develop/deploy"
    click L "https://github.com/decentdao/decent-contracts/tree/develop/deployments"
    click M "https://github.com/decentdao/decent-contracts/tree/develop/test"
    click N "https://github.com/decentdao/decent-contracts/tree/develop/.github/workflows"
    click O "https://github.com/decentdao/decent-contracts/blob/develop/hardhat.config.ts"
    click P "https://github.com/decentdao/decent-contracts/blob/develop/package.json"

    %% Class Definitions for Colors
    classDef smartContracts fill:#ffdddd,stroke:#333,stroke-width:2px;
    classDef deployment fill:#ddffdd,stroke:#333,stroke-width:2px;
    classDef testing fill:#ddddff,stroke:#333,stroke-width:2px;
    classDef ci fill:#ffffdd,stroke:#333,stroke-width:2px;
```
