# aave/aptos-aave-v3 architecture

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

- Interactive diagram: https://gitdiagram.com/aave/aptos-aave-v3
- Repository: https://github.com/aave/aptos-aave-v3

## Overview

##### Project type and purpose
- This is a blockchain-centric monorepo implementing Aave V3 smart-contracts on the Aptos chain, written in Move.
- It includes:
– aave-core: a collection of inter-dependent Move packages (ACL, Pool, Oracle, Tokens, Math, Periphery, Bridge, FlashLoan, etc.)
– apterly: a TypeScript indexer and CLI for simulating and querying a local Aptos testnet
– test-suites: TypeScript e2e/integration tests using clients against deployed contracts
– Makefile and scripts to bootstrap a local Aptos testnet, compile & publish packages, run unit/test suites

##### File structure
- Top-level directories:
– aave-core: Move packages organized by domain (aave-acl, aave-config, aave-math, aave-oracle, aave-pool, aave-tokens, aave-periphery, aave-scripts, etc.)
– apterly: Node.js service (Dockerfile, CLI in index.ts, docker-compose, Postgres init SQL)
– test-suites: TS clients, configs, scripts, Jest tests for end-to-end scenarios
– audits, CI workflows (.github/workflows), lint & formatter configs
- Key files:
– Makefile: orchestrates local-testnet, compile-all, publish-all, test-all, ts-test
– .env.template: environment variables for local testnet and apterly
– package.json/pnpm-lock.yaml: dependencies for root and sub-projects

##### README for additional insights
- Describes two dev flows:
– Local testnet via Makefile + Aptos CLI
– Local testnet + Apterly (Docker Compose)
- Outlines the build-publish-test cycle for smart contracts and TS integration tests

## Diagram (Mermaid)

```mermaid
graph TB
    %% Developer & CI
    subgraph "Developer Machine / CI Pipeline"
        direction TB
        DevMachine["Developer Machine"]:::dev
        Makefile["Makefile"]:::dev
        GitHubActions["GitHub Actions Workflows"]:::dev
    end

    %% Orchestrator & Scripts
    subgraph "Orchestrator & On-chain Scripts"
        direction TB
        AaveScripts["Aave on-chain Scripts"]:::dev
    end

    %% On-chain Components
    subgraph "On-Chain Infrastructure" 
        direction TB
        AptosTestnet["Aptos Local Testnet (Node + Validator)"]:::blockchain
        AptosCLI["Aptos CLI"]:::blockchain
        MoveCompiler["Move Package Compiler"]:::blockchain
        subgraph "Aave Core Move Packages"
            direction TB
            ACL["aave-acl"]:::contract
            Config["aave-config"]:::contract
            Oracle["aave-oracle"]:::contract
            Pool["aave-pool"]:::contract
            Tokens["aave-tokens"]:::contract
            Math["aave-math"]:::contract
            Rate["aave-rate"]:::contract
            Periphery["aave-periphery"]:::contract
            ScriptsPkg["aave-scripts"]:::contract
            ChainlinkFeeds["chainlink-data-feeds"]:::contract
            ChainlinkPlatform["chainlink-platform"]:::contract
        end
    end

    %% Off-chain Indexer
    subgraph "Off-Chain Indexer & Database"
        direction TB
        ApterlyIndexer["Apterly Indexer Service"]:::service
        PostgresDB["Postgres Indexer DB"]:::db
    end

    %% Test Suites
    subgraph "TypeScript Integration Tests"
        direction TB
        TSClients["TS Test Clients"]:::test
        JestTests["Jest Test Runner"]:::test
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Explorer["Aptos Explorer"]:::external
        Chainlink["Chainlink Data Feeds"]:::external
    end

    %% Connections
    DevMachine -->|invokes| Makefile
    DevMachine -->|push to CI| GitHubActions

    Makefile -->|runs scripts| AaveScripts
    Makefile -->|starts| AptosTestnet
    Makefile -->|calls| AptosCLI
    Makefile -->|triggers| MoveCompiler

    MoveCompiler -->|compiles| ACL
    MoveCompiler --> Config
    MoveCompiler --> Oracle
    MoveCompiler --> Pool
    MoveCompiler --> Tokens
    MoveCompiler --> Math
    MoveCompiler --> Rate
    MoveCompiler --> Periphery
    MoveCompiler --> ScriptsPkg
    MoveCompiler --> ChainlinkFeeds
    MoveCompiler --> ChainlinkPlatform

    AptosCLI -->|publishes modules| ACL
    ACL --> AptosTestnet
    Config --> AptosTestnet
    Oracle --> AptosTestnet
    Pool --> AptosTestnet
    Tokens --> AptosTestnet
    Math --> AptosTestnet
    Rate --> AptosTestnet
    Periphery --> AptosTestnet
    ScriptsPkg --> AptosTestnet
    ChainlinkFeeds --> AptosTestnet
    ChainlinkPlatform --> AptosTestnet

    AptosTestnet -->|JSON-RPC / gRPC| ApterlyIndexer
    ApterlyIndexer -->|writes events| PostgresDB

    TSClients -->|send txns/queries| AptosTestnet
    TSClients -->|call API| ApterlyIndexer
    JestTests --> TSClients

    Explorer -->|reads RPC| AptosTestnet
    AptosTestnet -->|on-chain feeds| Chainlink

    %% Click Events
    click Makefile "https://github.com/aave/aptos-aave-v3/tree/main/./Makefile"
    click GitHubActions "https://github.com/aave/aptos-aave-v3/tree/main/./.github/workflows/"
    click AaveScripts "https://github.com/aave/aptos-aave-v3/tree/main/./aave-core/aave-scripts/"
    click AptosTestnet "https://github.com/aave/aptos-aave-v3/blob/main/./apterly/docker-compose.yml"
    click AptosCLI "https://github.com/aave/aptos-aave-v3/tree/main/./Makefile"
    click MoveCompiler "https://github.com/aave/aptos-aave-v3/blob/main/./aave-core/Move.toml"
    click ACL "https://github.com/aave/aptos-aave-v3/tree/main/./aave-core/aave-acl/"
    click Config "https://github.com/aave/aptos-aave-v3/tree/main/./aave-core/aave-config/"
    click Oracle "https://github.com/aave/aptos-aave-v3/tree/main/./aave-core/aave-oracle/"
    click Pool "https://github.com/aave/aptos-aave-v3/tree/main/./aave-core/aave-pool/"
    click Tokens "https://github.com/aave/aptos-aave-v3/tree/main/./aave-core/aave-tokens/"
    click Math "https://github.com/aave/aptos-aave-v3/tree/main/./aave-core/aave-math/"
    click Rate "https://github.com/aave/aptos-aave-v3/tree/main/./aave-core/aave-rate/"
    click Periphery "https://github.com/aave/aptos-aave-v3/tree/main/./aave-core/aave-periphery/"
    click ScriptsPkg "https://github.com/aave/aptos-aave-v3/tree/main/./aave-core/aave-scripts/"
    click ChainlinkFeeds "https://github.com/aave/aptos-aave-v3/tree/main/./aave-core/chainlink-data-feeds/"
    click ChainlinkPlatform "https://github.com/aave/aptos-aave-v3/tree/main/./aave-core/chainlink-platform/"
    click ApterlyIndexer "https://github.com/aave/aptos-aave-v3/blob/main/./apterly/cli/index.ts"
    click ApterlyIndexer "https://github.com/aave/aptos-aave-v3/blob/main/./apterly/entrypoint.sh"
    click ApterlyIndexer "https://github.com/aave/aptos-aave-v3/tree/main/./apterly/Dockerfile"
    click ApterlyIndexer "https://github.com/aave/aptos-aave-v3/blob/main/./apterly/docker-compose.yml"
    click PostgresDB "https://github.com/aave/aptos-aave-v3/blob/main/./apterly/postgres-init/create_indexer_db.sql"
    click TSClients "https://github.com/aave/aptos-aave-v3/tree/main/./test-suites/clients/"
    click JestTests "https://github.com/aave/aptos-aave-v3/blob/main/./test-suites/jest.config.ts"
    click JestTests "https://github.com/aave/aptos-aave-v3/blob/main/./test-suites/package.json"

    %% Styles
    classDef dev fill:#DDDDDD,stroke:#888888,color:#333333;
    classDef blockchain fill:#CCFFCC,stroke:#2D882D,color:#1F3D1F;
    classDef contract fill:#E8F5E9,stroke:#66BB6A,color:#2E7D32;
    classDef service fill:#BBDEFB,stroke:#1976D2,color:#0D47A1;
    classDef db fill:#FFE0B2,stroke:#FB8C00,color:#E65100,shape:cylinder;
    classDef test fill:#E1BEE7,stroke:#8E24AA,color:#4A148C;
    classDef external fill:#FFCCBC,stroke:#D84315,color:#BF360C;
```
