> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spaceport.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Architecture

> A high-level overview of the Spaceport SDK architecture.

The SDK is composed of several clients and utilities that communicate with various backend and blockchain services. To better understand the architecture, we've broken it down into three simpler diagrams:

### 1. Spaceport SDK Internal Structure

This diagram illustrates the main components within the "Spaceport Core SDK" and their relationships.

```mermaid theme={null}
flowchart LR
    subgraph SDK["Spaceport Core SDK"]
        direction TB
        MainSDK["SpaceportSDK (Main Client)"]

        subgraph ResourceClients["Resource Clients"]
            AgreementClient
            AssetClient
            ListingClient
            SmartLicenseClient
            BondTokenClient
            UserClient
        end

        subgraph QuerySystem["Query System"]
            QueryClient
            ListingsQuery
            AgreementsQuery
            SmartLicensesQuery
        end

        subgraph Utils["Utilities"]
            SpaceportUtils
            IPFSUtils
            JobPolling
            ChainUtils
        end

        subgraph NetworkClients["Network Clients"]
            PublicClient["Viem PublicClient"]
            WalletClient["Viem WalletClient"]
            CulturaSDK["Cultura SDK Integration"]
        end

        MainSDK -- "Lazy Loads" --> ResourceClients
        MainSDK -- "Lazy Loads" --> QuerySystem
        MainSDK -- "Lazy Loads" --> Utils
        MainSDK -- "Initializes" --> NetworkClients
    end
```

### 2. Spaceport SDK and External Services Interaction

This diagram shows how the Spaceport SDK interacts with various external services.

```mermaid theme={null}
flowchart LR
    UserApp["Your Application"] --> MainSDK["SpaceportSDK (Main Client)"]
    UserApp --> WalletOptions["Account Integration"]

    MainSDK -- "API Requests" --> SpaceportAPI["Spaceport Core API"]
    MainSDK -- "Data Queries" --> TheGraph["Data Indexing Service"]
    MainSDK -- "File Uploads" --> IPFSService["Decentralized File Storage"]
    MainSDK -- "Network Calls" --> EVMNetwork["Distributed Ledger Network"]

    WalletOptions -- "Signs Transactions" --> MainSDK
```

### 3. Spaceport Backend Infrastructure

This diagram details the core blockchain and API components that underpin the Spaceport ecosystem.

```mermaid theme={null}
flowchart LR
    subgraph BlockchainLayer["Backend Infrastructure"]
        EVMNetwork["Distributed Ledger Network"]
        SpaceportContracts["Automated Licensing Contracts"]
        CulturaContracts["Licensing Logic"]

        subgraph ContractTypes["Contract Types"]
            ProtocolDiamond["Protocol Logic"]
            AssetDiamond["Asset Logic"]
        end

        EVMNetwork -- "Hosts" --> SpaceportContracts
        SpaceportContracts -- "Implements" --> ContractTypes
        SpaceportContracts -- "Inherits/Uses" --> CulturaContracts
    end

    SpaceportContracts -- "Emits Events" --> TheGraph["Data Indexing Service"]
    TheGraph -- "Indexes Data" --> QuerySystem["Query System"]
    SpaceportAPI["Spaceport Core API"] -- "Stores Metadata" --> Database["Spaceport Database"]
```
