# evronm/marketdao architecture

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

## Overview

##### Main Components

a) Smart Contract Layer:
- Core DAO Contract (ERC-1155 based)
- Governance Token Management
- Voting Token Management
- Election System
- Proposal System

b) Interaction Layer:
- User Interface Components
- Web3 Integration
- Transaction Management

##### Key Relationships to Highlight

a) Token Flow:
- Governance Token Distribution
- Voting Token Emission
- Token Trading Mechanisms

b) Governance Flow:
- Proposal Creation
- Support Gathering
- Election Triggering
- Voting Process
- Result Implementation

##### Specific Implementation Details

**[User Interface Layer]**
- ↕
**[Web3 Integration Layer]**
- ↕
**[Smart Contract Layer]**

**[Tokens] [Elections] [Proposals]**
- ↓
**[Storage Layer]**

##### Important Elements

a) Smart Contract Components:
- ERC-1155 Token Contract (core)
- Election Manager
- Proposal Manager
- Token Distribution System
- Voting Mechanism

b) Process Flows:
- Token Distribution Flow
- Proposal Creation → Support Gathering → Election Trigger
- Voting Token Distribution → Trading → Voting → Reset
- Election Results → Implementation

c) State Management:
- Token Balances
- Active Elections
- Pending Proposals
- Voting Records

##### Key Parameters to Highlight

A parameter configuration section showing:
- DAO Name
- Support Threshold
- Election Quorum Percentage
- Proposal Parameters
- Election Timing Parameters

##### Future Extensibility

- Multiple Choice Elections
- Constitutional Framework
- Staking Mechanism
- Enhanced Proposal Support System

Remember to emphasize the market-driven aspects of the governance system, particularly the unique feature of tradeable voting tokens, as this is a key differentiator of this DAO implementation.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI["User Interface Layer"]
        WebUI[Web Interface]:::ui
        Web3Int[Web3 Integration]:::ui
    end

    subgraph SCL["Smart Contract Layer"]
        CoreDAO[Core DAO Contract]:::contract
        TokenMgmt[Token Management]:::contract
        ElecSys[Election System]:::contract
        PropSys[Proposal System]:::contract
    end

    subgraph Components["Component Layer"]
        ERC1155[ERC-1155 Token]:::token
        ElecMgr[Election Manager]:::governance
        PropMgr[Proposal Manager]:::governance
        VoteMech[Voting Mechanism]:::governance
    end

    subgraph State["State Management"]
        TokenBal[Token Balances]:::storage
        ActiveElec[Active Elections]:::storage
        PendProp[Pending Proposals]:::storage
        VoteRec[Voting Records]:::storage
    end

    subgraph Future["Future Extensions"]
        MultiChoice[Multiple Choice Elections]:::future
        Constitution[Constitutional Framework]:::future
        Staking[Staking Mechanism]:::future
        EnhancedProp[Enhanced Proposal System]:::future
    end

    %% Relationships
    WebUI --> Web3Int
    Web3Int --> CoreDAO
    CoreDAO --> TokenMgmt
    CoreDAO --> ElecSys
    CoreDAO --> PropSys
    
    TokenMgmt --> ERC1155
    ElecSys --> ElecMgr
    PropSys --> PropMgr
    ElecMgr --> VoteMech
    PropMgr --> VoteMech

    ERC1155 --> TokenBal
    ElecMgr --> ActiveElec
    PropMgr --> PendProp
    VoteMech --> VoteRec

    %% Click Events
    click WebUI "https://github.com/evronm/marketDAO/blob/main/index.html"
    click CoreDAO "https://github.com/evronm/marketDAO/tree/main/src"
    click TokenMgmt "https://github.com/evronm/marketDAO/tree/main/src"
    click ElecSys "https://github.com/evronm/marketDAO/tree/main/src"
    click PropSys "https://github.com/evronm/marketDAO/tree/main/src"
    click ERC1155 "https://github.com/evronm/marketDAO/tree/main/lib/openzeppelin-contracts"
    click TokenBal "https://github.com/evronm/marketDAO/tree/main/out"
    click ActiveElec "https://github.com/evronm/marketDAO/tree/main/out"
    click PendProp "https://github.com/evronm/marketDAO/tree/main/out"
    click VoteRec "https://github.com/evronm/marketDAO/tree/main/broadcast"

    %% Styling
    classDef ui fill:#4B89DC,stroke:#2E5C99,stroke-width:2px
    classDef contract fill:#37BC9B,stroke:#1F8C6B,stroke-width:2px
    classDef token fill:#967ADC,stroke:#6B4FB8,stroke-width:2px
    classDef governance fill:#F6BB42,stroke:#D39C23,stroke-width:2px
    classDef storage fill:#DA4453,stroke:#B02937,stroke-width:2px
    classDef future fill:#AAB2BD,stroke:#656D78,stroke-width:2px,stroke-dasharray: 5 5

    %% Legend
    subgraph Legend
        UI_L[User Interface]:::ui
        Contract_L[Smart Contracts]:::contract
        Token_L[Token Components]:::token
        Gov_L[Governance]:::governance
        Storage_L[Storage]:::storage
        Future_L[Future Features]:::future
    end
```
