# solana-labs/solana-program-library architecture

> Architecture diagram of the GitHub repository solana-labs/solana-program-library, 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/solana-labs/solana-program-library
- Repository: https://github.com/solana-labs/solana-program-library

## Overview

##### High-Level Architecture Components

a) Core Program Categories:
- Token Programs (token, token-2022, associated-token-account)
- Governance Programs (governance, feature-proposal)
- DeFi Programs (token-lending, token-swap, stake-pool)
- Infrastructure Programs (account-compression, shared-memory, name-service)
- Utility Programs (memo, instruction-padding)

b) Supporting Components:
- Client Libraries (JavaScript/TypeScript SDKs)
- CLI Tools
- Testing Infrastructure
- Documentation System

##### Relationships and Interactions

a) Program Dependencies:
- How programs interact with each other (e.g., token-lending depends on token)
- Shared library dependencies (e.g., math library used by multiple programs)

b) Client Interactions:
- SDK packages to their respective programs
- CLI tools interfacing with programs

##### Specific Design Elements

Use these visual elements:

- Hexagons for on-chain programs
- Rectangles for client libraries
- Rounded rectangles for CLI tools
- Clouds for external interfaces

- Green for audited programs
- Yellow for unaudited programs
- Blue for client libraries
- Purple for infrastructure components

##### Implementation Details

Create sections showing:

a) Program Architecture:
**[Solana Runtime]**

- [SPL Core Programs]
- Token Programs
- Governance Programs
- DeFi Programs

- [Client Libraries]
- JavaScript SDKs
- Rust Crates

- [Development Tools]
- CLI Tools
- Test Framework

b) Deployment Status:
- Deployed programs with version numbers
- Audit status and dates
- Program relationships with Solana runtime

##### Notes Section

Notes about:
- Security considerations
- Deployment requirements
- Version compatibility
- Audit status
- Migration status (for programs moving to separate repos)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Solana Runtime"
        Runtime[Solana Runtime]
    end

    subgraph "SPL Core Programs"
        subgraph "Token Programs"
            Token["Token"]:::audited
            Token2022["Token 2022"]:::audited
            ATA["Associated Token Account"]:::audited
        end

        subgraph "Governance Programs"
            Gov["Governance"]:::unaudited
            FP["Feature Proposal"]:::unaudited
        end

        subgraph "DeFi Programs"
            Lending["Token Lending"]:::unaudited
            Swap["Token Swap"]:::unaudited
            StakePool["Stake Pool"]:::unaudited
        end

        subgraph "Infrastructure Programs"
            Compression["Account Compression"]:::unaudited
            SharedMem["Shared Memory"]:::unaudited
            NameSvc["Name Service"]:::unaudited
        end

        subgraph "Utility Programs"
            Memo["Memo"]:::audited
            Padding["Instruction Padding"]:::unaudited
        end
    end

    subgraph "Client Libraries"
        SwapJS["Token Swap JS SDK"]:::sdk
        LendingJS["Token Lending JS SDK"]:::sdk
        NameSvcJS["Name Service JS SDK"]:::sdk
        CompressSDK["Compression SDK"]:::sdk
    end

    subgraph "Development Tools"
        subgraph "CLI Tools"
            LendingCLI["Lending CLI"]:::tool
            UpgradeCLI["Upgrade CLI"]:::tool
            GovTools["Governance Tools"]:::tool
        end

        subgraph "Testing"
            TestClient["Test Client"]:::testing
            GovTestSDK["Governance Test SDK"]:::testing
            LendingTests["Lending Tests"]:::testing
            SwapTests["Swap Tests"]:::testing
        end

        subgraph "Documentation"
            Docs["Documentation"]:::docs
            DocsStatic["Static Assets"]:::docs
        end
    end

    %% Relationships
    Runtime --> Token
    Runtime --> Token2022
    Runtime --> ATA
    Runtime --> Gov
    Runtime --> Lending
    Runtime --> Swap
    Runtime --> StakePool
    Runtime --> Compression
    Runtime --> SharedMem
    Runtime --> NameSvc
    Runtime --> Memo
    Runtime --> Padding

    Token --> ATA
    Token2022 --> ATA
    Lending --> Token
    Swap --> Token
    StakePool --> Token

    SwapJS --> Swap
    LendingJS --> Lending
    NameSvcJS --> NameSvc
    CompressSDK --> Compression

    LendingCLI --> Lending
    GovTools --> Gov
    UpgradeCLI --> Token2022

    %% Click Events
    click Token "https://github.com/solana-labs/solana-program-library/tree/master/token"
    click Token2022 "https://github.com/solana-labs/solana-program-library/tree/master/token-2022"
    click ATA "https://github.com/solana-labs/solana-program-library/tree/master/associated-token-account"
    click Gov "https://github.com/solana-labs/solana-program-library/tree/master/governance"
    click FP "https://github.com/solana-labs/solana-program-library/tree/master/feature-proposal"
    click Lending "https://github.com/solana-labs/solana-program-library/tree/master/token-lending"
    click Swap "https://github.com/solana-labs/solana-program-library/tree/master/token-swap"
    click StakePool "https://github.com/solana-labs/solana-program-library/tree/master/stake-pool"
    click Compression "https://github.com/solana-labs/solana-program-library/tree/master/account-compression"
    click SharedMem "https://github.com/solana-labs/solana-program-library/tree/master/shared-memory"
    click NameSvc "https://github.com/solana-labs/solana-program-library/tree/master/name-service"
    click Memo "https://github.com/solana-labs/solana-program-library/tree/master/memo"
    click Padding "https://github.com/solana-labs/solana-program-library/tree/master/instruction-padding"
    click SwapJS "https://github.com/solana-labs/solana-program-library/tree/master/token-swap/js"
    click LendingJS "https://github.com/solana-labs/solana-program-library/tree/master/token-lending/js"
    click NameSvcJS "https://github.com/solana-labs/solana-program-library/tree/master/name-service/js"
    click CompressSDK "https://github.com/solana-labs/solana-program-library/tree/master/account-compression/sdk"
    click TestClient "https://github.com/solana-labs/solana-program-library/tree/master/utils/test-client"
    click GovTestSDK "https://github.com/solana-labs/solana-program-library/tree/master/governance/test-sdk"
    click LendingTests "https://github.com/solana-labs/solana-program-library/tree/master/token-lending/program/tests"
    click SwapTests "https://github.com/solana-labs/solana-program-library/tree/master/token-swap/program/tests"
    click Docs "https://github.com/solana-labs/solana-program-library/tree/master/docs"
    click DocsStatic "https://github.com/solana-labs/solana-program-library/tree/master/docs/static"
    click LendingCLI "https://github.com/solana-labs/solana-program-library/tree/master/token-lending/cli"
    click UpgradeCLI "https://github.com/solana-labs/solana-program-library/tree/master/token-upgrade/cli"
    click GovTools "https://github.com/solana-labs/solana-program-library/tree/master/governance/tools"

    %% Styling
    classDef audited fill:#90EE90
    classDef unaudited fill:#FFE5B4
    classDef sdk fill:#ADD8E6
    classDef tool fill:#DDA0DD
    classDef testing fill:#F0E68C
    classDef docs fill:#E6E6FA

    %% Legend
    subgraph Legend
        L1[Audited Program]:::audited
        L2[Unaudited Program]:::unaudited
        L3[SDK/Client Library]:::sdk
        L4[Development Tool]:::tool
        L5[Testing Component]:::testing
        L6[Documentation]:::docs
    end
```
