# cityofzion/neon-js architecture

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

## Overview

##### Main Components

a) Core Components (Primary Layer):
- Wallet Management (wallet/)
- Smart Contract Interface (sc/)
- Transaction Handling (tx/)
- RPC Client (rpc/)
- Utility Functions (u/)

b) Extension Modules (Secondary Layer):
- NEON-API: API integration services
- NEON-LEDGER: Ledger hardware wallet integration
- NEON-URI: URI scheme handling
- NEON-JS: Main entry point and facade

##### External Integration Points
- NEO Blockchain (show as external system)
- Browser/Node.js Runtime
- Hardware Wallets
- RPC Nodes

##### Detailed Component Breakdown

For each major component, include sub-components:

**NEON-CORE**
- Wallet
- Account Management
- NEP2 Encryption
- Multi-sig Support
- Smart Contract
- Script Builder
- Contract Templates
- NEP17 Support
- Transactions
- Builder
- Signing
- Validation
- RPC
- Client Implementation
- Protocol Handlers

##### Integration Points

Connections to:
- NEO N3 Network
- Browser/Node.js APIs
- External Services

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External
        NEO[NEO N3 Network]:::external
        Browser[Browser/Node.js Runtime]:::external
        Hardware[Hardware Wallets]:::external
        RPC[RPC Nodes]:::external
    end

    subgraph Core["NEON-CORE"]
        WM[Wallet Management]:::core
        SCI[Smart Contract Interface]:::core
        TH[Transaction Handling]:::core
        RPCC[RPC Client]:::core
        UF[Utility Functions]:::core

        subgraph WalletComponents
            AM[Account Management]:::subcomp
            NEP2[NEP2 Encryption]:::subcomp
            MS[Multi-sig Support]:::subcomp
        end

        subgraph SCComponents
            SB[Script Builder]:::subcomp
            CT[Contract Templates]:::subcomp
            NEP17[NEP17 Support]:::subcomp
            CM[Contract Manifest]:::subcomp
        end

        subgraph TXComponents
            TB[Transaction Builder]:::subcomp
            TS[Transaction Signing]:::subcomp
            TV[Transaction Validation]:::subcomp
            TC[Transaction Components]:::subcomp
        end
    end

    subgraph Extensions
        NAPI[NEON-API]:::ext
        NLEDGER[NEON-LEDGER]:::ext
        NURI[NEON-URI]:::ext
        NJS[NEON-JS]:::ext
    end

    %% Core Component Relationships
    WM --> AM
    WM --> NEP2
    WM --> MS
    SCI --> SB
    SCI --> CT
    SCI --> NEP17
    SCI --> CM
    TH --> TB
    TH --> TS
    TH --> TV
    TH --> TC

    %% Extension Relationships
    NJS --> WM
    NJS --> SCI
    NJS --> TH
    NJS --> RPCC
    NJS --> UF
    NAPI --> RPCC
    NLEDGER --> WM
    NURI --> WM

    %% External Relationships
    RPCC -.-> RPC
    NLEDGER -.-> Hardware
    NJS -.-> Browser
    NAPI -.-> NEO

    %% Click Events
    click WM "https://github.com/CityOfZion/neon-js/tree/master/packages/neon-core/src/wallet/"
    click SCI "https://github.com/CityOfZion/neon-js/tree/master/packages/neon-core/src/sc/"
    click TH "https://github.com/CityOfZion/neon-js/tree/master/packages/neon-core/src/tx/"
    click RPCC "https://github.com/CityOfZion/neon-js/tree/master/packages/neon-core/src/rpc/"
    click UF "https://github.com/CityOfZion/neon-js/tree/master/packages/neon-core/src/u/"
    click NAPI "https://github.com/CityOfZion/neon-js/tree/master/packages/neon-api/src/"
    click NLEDGER "https://github.com/CityOfZion/neon-js/tree/master/packages/neon-ledger/src/"
    click NURI "https://github.com/CityOfZion/neon-js/tree/master/packages/neon-uri/src/"
    click NJS "https://github.com/CityOfZion/neon-js/tree/master/packages/neon-js/src/"
    click CT "https://github.com/CityOfZion/neon-js/tree/master/packages/neon-core/src/sc/contracts/templates/"
    click CM "https://github.com/CityOfZion/neon-js/tree/master/packages/neon-core/src/sc/manifest/"
    click NEP17 "https://github.com/CityOfZion/neon-js/blob/master/packages/neon-core/src/sc/contracts/Nep17Contract.ts"
    click TB "https://github.com/CityOfZion/neon-js/blob/master/packages/neon-api/src/transaction/TransactionBuilder.ts"
    click TC "https://github.com/CityOfZion/neon-js/tree/master/packages/neon-core/src/tx/components/"

    %% Styling
    classDef core fill:#2374ab,stroke:#000,stroke-width:2px,color:#fff
    classDef ext fill:#57a773,stroke:#000,stroke-width:2px,color:#fff
    classDef external fill:#7d7d7d,stroke:#000,stroke-width:2px,color:#fff
    classDef subcomp fill:#4392f1,stroke:#000,stroke-width:1px,color:#fff

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Extension Modules]:::ext
        L3[External Systems]:::external
        L4[Sub Components]:::subcomp
    end
```
