# makerdao/dss architecture

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

- Interactive diagram: https://gitdiagram.com/makerdao/dss
- Repository: https://github.com/makerdao/dss

## Overview

##### Main Components

a) Core System Components:
- Vat (Core CDP Engine)
- Dai Token Contract
- Price Feeds
- Auction System
- Collateral Adapters
- Authentication System

b) External Components:
- Various Collateral Types
- MKR Token
- Governance Layer

##### Connection Types

- Data flow (→): Show how information moves between components
- Authentication (⇢): Show permission relationships
- Token flow (⇄): Show token movements
- State modifications (↷): Show state changes

##### Key Elements to Highlight

a) Collateral Flow:
- How collateral enters through adapters
- Demonstrate the relationship between external tokens and internal representation

b) Dai Generation:
- CDP creation process
- Dai token issuance flow

c) Risk Management:
- Liquidation triggers
- Auction mechanisms
- MKR token interaction for system debt/surplus

d) Price Feed Integration:
- Oracle input points
- Demonstrate how price updates affect the system

##### Notes Section

A notes section explaining:
- The verification-friendly nature of the core system
- The token-agnostic design
- The modular architecture
- Key security considerations

##### Modular design

Remember to maintain a balance between showing the complexity of the system while keeping it understandable. Use nested components where appropriate to show hierarchical relationships without cluttering the main view.

- Nested components
- Clear labeling
- Export to high-resolution formats

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef external fill:#4CAF50,stroke:#2E7D32,color:white
    classDef oracle fill:#FFC107,stroke:#FFA000,color:black
    classDef auth fill:#F44336,stroke:#D32F2F,color:white
    classDef auction fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef governance fill:#FF9800,stroke:#F57C00,color:white

    %% External Layer
    subgraph External
        UI[User Interface]:::external
        ExtTokens[External Tokens]:::external
        Gov[Governance System]:::governance
        MKR[MKR Token]:::governance
    end

    %% Adapter Layer
    subgraph Adapters
        CollateralAdapters[Collateral Adapters]:::external
        TokenWrappers[Token Wrappers]:::external
    end

    %% Core System
    subgraph CoreSystem
        Vat[Core CDP Engine]:::core
        DaiToken[Dai Token]:::core
        PriceFeeds[Price Feeds]:::oracle
        Auth[Authentication]:::auth
    end

    %% Settlement Layer
    subgraph Settlement
        LiqEngine[Liquidation Engine]:::auction
        Auctions[Auction System]:::auction
        DebtMgmt[Debt Management]:::auction
    end

    %% Connections
    UI --> CollateralAdapters
    ExtTokens --> CollateralAdapters
    CollateralAdapters --> Vat
    TokenWrappers --> Vat
    PriceFeeds --> Vat
    Vat --> DaiToken
    Vat --> LiqEngine
    LiqEngine --> Auctions
    Auctions --> DebtMgmt
    Gov --> Auth
    Auth --> Vat
    MKR --> DebtMgmt

    %% Click Events
    click DaiToken "https://github.com/makerdao/dss/tree/master/lib/ds-token"
    click PriceFeeds "https://github.com/makerdao/dss/tree/master/lib/ds-value"
    click Vat "https://github.com/makerdao/dss/tree/master/src/"

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[External Interfaces]:::external
        L3[Price Feeds]:::oracle
        L4[Authentication]:::auth
        L5[Auction System]:::auction
        L6[Governance]:::governance
    end
```
