# hausdao/baal architecture

> Architecture diagram of the GitHub repository hausdao/baal, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hausdao/baal
- Repository: https://github.com/hausdao/baal

## Overview

##### Main Components

a) Core Smart Contracts Layer:
- Baal (Main DAO Contract)
- Shares (ERC20 Voting Tokens)
- Loot (ERC20 Economic Rights)
- BaalVotes (Voting Logic)

b) Factory Layer:
- BaalSummoner (Primary Factory)
- Higher Order Factories:
- BaalAndVaultSummoner
- BaalAdvTokenSummoner

c) Integration Layer:
- Gnosis Safe Integration
- TributeMinion
- External Interfaces (ERC20, ERC721)

**[User/Client Layer]**
- ↓
**[Factory Layer]**
- ↓
**[Core Contracts Layer] ←→ [Integration Layer]**
- ↓
**[External Services/Protocols]**

##### Key Relationships

a) Deployment Flow:
- Factories → Core Contracts
- Safe Creation/Integration paths

b) Governance Flow:
- Shares → Voting Rights
- Loot → Economic Rights
- Shaman Privileges

c) Integration Points:
- Safe Module connections
- TributeMinion interactions
- External token interactions

##### Implementation Details

Use these symbols and connections:
- Double lines: Inheritance relationships
- Diamonds: Decision points
- Rectangles: Contracts/Components

##### Additional Elements

Annotations for:
- Security boundaries
- Upgrade paths
- External dependencies
- Configuration points
- Event emission points

##### The integration capabilities with external protocols

Keep the abstraction level high enough to show the overall architecture while including sufficient detail to understand the key interactions and security boundaries. Focus on showing how the different components work together to provide the DAO functionality while maintaining security and flexibility.

Remember to include version information and deployment status indicators for different networks, as this project is deployed across multiple chains.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and Classes
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef factory fill:#2ecc71,stroke:#27ae60,color:white
    classDef integration fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    
    %% User Layer
    subgraph UserLayer["User/Client Layer"]
        Client[Client Application]
    end

    %% Factory Layer
    subgraph FactoryLayer["Factory Layer"]
        BaalSummoner["BaalSummoner"]:::factory
        BaalAndVaultSummoner["BaalAndVaultSummoner"]:::factory
        BaalAdvTokenSummoner["BaalAdvTokenSummoner"]:::factory
    end

    %% Core Contracts Layer
    subgraph CoreLayer["Core Contracts Layer"]
        Baal["Baal DAO"]:::core
        Shares["Shares Token"]:::core
        Loot["Loot Token"]:::core
        BaalVotes["Voting Logic"]:::core
    end

    %% Integration Layer
    subgraph IntegrationLayer["Integration Layer"]
        GnosisSafe["Gnosis Safe"]:::integration
        TributeMinion["TributeMinion"]:::integration
        TokenInterfaces["ERC20/ERC721 Interfaces"]:::integration
    end

    %% Security Layer
    subgraph SecurityLayer["Security Layer"]
        Shaman["Shaman Roles"]:::security
        Governor["Governor"]:::security
        Manager["Manager"]:::security
        Admin["Admin"]:::security
    end

    %% External Layer
    subgraph ExternalLayer["External Services"]
        Mainnet["Ethereum Mainnet"]:::external
        L2Networks["L2 Networks"]:::external
    end

    %% Relationships
    Client --> BaalSummoner
    Client --> BaalAndVaultSummoner
    Client --> BaalAdvTokenSummoner
    
    BaalSummoner --> Baal
    BaalAndVaultSummoner --> Baal
    BaalAdvTokenSummoner --> Baal
    
    Baal --> Shares
    Baal --> Loot
    Baal --> BaalVotes
    
    Baal <--> GnosisSafe
    Baal <--> TributeMinion
    Baal <--> TokenInterfaces
    
    SecurityLayer --> Baal
    
    Baal --> Mainnet
    Baal --> L2Networks

    %% Legend
    subgraph Legend
        CoreComp["Core Component"]:::core
        FactoryComp["Factory Component"]:::factory
        IntegrationComp["Integration Component"]:::integration
        SecurityComp["Security Component"]:::security
        ExternalComp["External Service"]:::external
    end

    %% Click Events
    click Baal "https://github.com/HausDAO/Baal/blob/feat/baalZodiac/deployments/mainnet/Baal.json"
    click Shares "https://github.com/HausDAO/Baal/blob/feat/baalZodiac/deployments/mainnet/Shares.json"
    click Loot "https://github.com/HausDAO/Baal/blob/feat/baalZodiac/deployments/mainnet/Loot.json"
    click BaalSummoner "https://github.com/HausDAO/Baal/blob/feat/baalZodiac/deployments/mainnet/BaalSummoner.json"
    click BaalAndVaultSummoner "https://github.com/HausDAO/Baal/blob/feat/baalZodiac/deployments/mainnet/BaalAndVaultSummoner.json"
    click BaalAdvTokenSummoner "https://github.com/HausDAO/Baal/blob/feat/baalZodiac/deployments/mainnet/BaalAdvTokenSummoner.json"
    click TributeMinion "https://github.com/HausDAO/Baal/blob/feat/baalZodiac/deployments/mainnet/TributeMinion.json"
    click GnosisSafe "https://github.com/HausDAO/Baal/blob/feat/baalZodiac/test/BaalSafe.test.ts"
    click BaalVotes "https://github.com/HausDAO/Baal/blob/feat/baalZodiac/src/signVote.ts"
```
