# metamask/core architecture

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

- Interactive diagram: https://gitdiagram.com/metamask/core
- Repository: https://github.com/metamask/core

## Overview

##### Main Components Structure

The system should be organized into these primary layers:

**┌─ Core Infrastructure ─────────────────────┐**
- Base Controller                         │
- JSON RPC Engine                         │
- Controller Utils                        │
- ┘
- ↑
**┌─ Functional Controllers ─────────────────┐**
- Network Controller                     │
- Account Controller                     │
- Transaction Controller                 │
- Assets Controllers                     │
- Permission Controller                  │
- ┘
- ↑
**┌─ Service Controllers ──────────────────────┐**
- ENS Controller                           │
- Gas Fee Controller                       │
- Notification Services Controller         │
- Profile Sync Controller                  │
- ┘

##### Key Relationships to Highlight

a. Core Dependencies:
- BaseController as the foundation that most other controllers extend from
- JSON-RPC Engine as the communication backbone
- Controller Utils as shared utilities

b. Controller Interactions:
- Network Controller's central role in managing blockchain connectivity
- Permission Controller's governance of access rights
- Transaction Controller's dependencies on Gas Fee and Network controllers

##### Important Elements

- Version control integration (GitHub Actions workflow)
- Testing infrastructure connections
- Controller state management flows
- External service integrations

##### Documentation Integration

References to:
- Package documentation locations
- API endpoints
- Configuration requirements
- Testing frameworks

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef core fill:#2374ab,color:white
    classDef functional fill:#2a9d8f,color:white
    classDef service fill:#e76f51,color:white
    classDef utils fill:#4a4e69,color:white

    %% Core Infrastructure Layer
    subgraph Core ["Core Infrastructure"]
        BC["Base Controller"]
        JRE["JSON RPC Engine"]
        CU["Controller Utils"]
    end

    %% Functional Controllers Layer
    subgraph Functional ["Functional Controllers"]
        NC["Network Controller"]
        AC["Account Controller"]
        TC["Transaction Controller"]
        AsC["Assets Controllers"]
        PC["Permission Controller"]
        MM["Message Manager"]
        PolC["Polling Controller"]
        SC["Signature Controller"]
        KC["Keyring Controller"]
    end

    %% Service Controllers Layer
    subgraph Services ["Service Controllers"]
        ENS["ENS Controller"]
        GFC["Gas Fee Controller"]
        NSC["Notification Services"]
        PSC["Profile Sync"]
    end

    %% Relationships
    BC --> NC & AC & TC & AsC & PC & MM & PolC & SC & KC
    JRE --> NC
    CU --> NC & AC & TC & AsC & PC & ENS & GFC & NSC & PSC
    NC --> GFC
    TC --> GFC
    AC --> KC
    PC --> AC

    %% Click Events
    click BC "https://github.com/metamask/core/tree/main/packages/base-controller"
    click JRE "https://github.com/metamask/core/tree/main/packages/json-rpc-engine"
    click CU "https://github.com/metamask/core/tree/main/packages/controller-utils"
    click NC "https://github.com/metamask/core/tree/main/packages/network-controller"
    click AC "https://github.com/metamask/core/tree/main/packages/accounts-controller"
    click TC "https://github.com/metamask/core/tree/main/packages/transaction-controller"
    click AsC "https://github.com/metamask/core/tree/main/packages/assets-controllers"
    click PC "https://github.com/metamask/core/tree/main/packages/permission-controller"
    click ENS "https://github.com/metamask/core/tree/main/packages/ens-controller"
    click GFC "https://github.com/metamask/core/tree/main/packages/gas-fee-controller"
    click NSC "https://github.com/metamask/core/tree/main/packages/notification-services-controller"
    click PSC "https://github.com/metamask/core/tree/main/packages/profile-sync-controller"
    click MM "https://github.com/metamask/core/tree/main/packages/message-manager"
    click PolC "https://github.com/metamask/core/tree/main/packages/polling-controller"
    click SC "https://github.com/metamask/core/tree/main/packages/signature-controller"
    click KC "https://github.com/metamask/core/tree/main/packages/keyring-controller"

    %% Style Applications
    class BC,JRE,CU core
    class NC,AC,TC,AsC,PC,MM,PolC,SC,KC functional
    class ENS,GFC,NSC,PSC service

    %% Legend
    subgraph Legend
        L1["Core Infrastructure"]:::core
        L2["Functional Controllers"]:::functional
        L3["Service Controllers"]:::service
    end
```
