# elliottech/lighter-python architecture

> Architecture diagram of the GitHub repository elliottech/lighter-python, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/elliottech/lighter-python
- Repository: https://github.com/elliottech/lighter-python

## Overview

Lighter is a Python SDK for the zkLighter perpetuals exchange. Its principal workflow is constructing a client, invoking typed REST endpoint classes, and receiving deserialized account, market, or transaction data. The SDK also exposes signed transaction helpers, nonce coordination, websocket streaming, and bridge operations. The graph groups endpoint families rather than enumerating every generated API class. Relationships reflect README statements and SOURCE INDEX references; unsampled endpoint and websocket implementations limit more detailed call-flow claims.

Main entry points: [`lighter/api_client.py`](https://github.com/elliottech/lighter-python/blob/main/lighter/api_client.py) (API client), [`lighter/signer_client.py`](https://github.com/elliottech/lighter-python/blob/main/lighter/signer_client.py) (Signer client), [`lighter/models`](https://github.com/elliottech/lighter-python/tree/main/lighter/models) (Typed models), [`lighter/api/account_api.py`](https://github.com/elliottech/lighter-python/blob/main/lighter/api/account_api.py) (Account endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["SDK entry points"]
  node_exports["Public exports<br/>[__init__.py]"]
end

subgraph group_rest["REST and data"]
  node_account_api["Account endpoints<br/>[account_api.py]"]
  node_order_api["Order endpoints<br/>[order_api.py]"]
  node_referral_api["Referral endpoints<br/>[referral_api.py]"]
  node_other_apis["Other REST families"]
  node_api_client["API client<br/>[api_client.py]"]
  node_configuration["HTTP configuration<br/>[configuration.py]"]
  node_rest_transport["REST transport<br/>[rest.py]"]
  node_response["Response wrapper<br/>[api_response.py]"]
  node_errors["API exceptions<br/>[exceptions.py]"]
  node_models["Typed models"]
end

subgraph group_trading["Trading and signing"]
  node_tx_api["Transaction endpoints<br/>[transaction_api.py]"]
  node_signer["Signer client<br/>[signer_client.py]"]
  node_nonce["Nonce manager<br/>[nonce_manager.py]"]
  node_tx_builders["Transaction helpers"]
  node_signer_native["Native signer binaries"]
end

subgraph group_other["Streaming and bridge"]
  node_bridge_api["Bridge endpoints<br/>[bridge_api.py]"]
  node_websocket["Websocket client<br/>[ws_client.py]"]
end

node_user(("SDK caller"))
node_exchange(("Lighter exchange"))

node_user -->|"imports SDK"| node_exports
node_exports -->|"exposes"| node_account_api
node_user -->|"requests account data"| node_account_api
node_account_api -->|"calls"| node_api_client
node_order_api -->|"calls"| node_api_client
node_tx_api -->|"calls"| node_api_client
node_referral_api -->|"calls"| node_api_client
node_bridge_api -->|"calls"| node_api_client
node_other_apis -.->|"uses"| node_api_client
node_api_client -->|"configures"| node_configuration
node_api_client -->|"sends requests"| node_rest_transport
node_rest_transport -.->|"HTTP requests"| node_exchange
node_api_client -->|"returns typed response"| node_response
node_api_client -->|"raises"| node_errors
node_api_client -->|"deserializes with"| node_models
node_account_api -->|"uses account models"| node_models
node_order_api -->|"uses market models"| node_models
node_tx_api -->|"uses transaction models"| node_models
node_bridge_api -->|"uses bridge models"| node_models
node_user -->|"creates and submits transactions"| node_signer
node_signer -->|"coordinates nonces"| node_nonce
node_nonce -->|"fetches next nonce"| node_tx_api
node_signer -->|"uses transaction helpers"| node_tx_builders
node_signer -.->|"loads native signer"| node_signer_native
node_signer -.->|"submits transactions"| node_tx_api
node_user -->|"streams exchange state"| node_websocket
node_websocket -.->|"opens websocket"| node_exchange
node_user -->|"uses bridge operations"| node_bridge_api

click node_exports "https://github.com/elliottech/lighter-python/blob/main/lighter/__init__.py"
click node_account_api "https://github.com/elliottech/lighter-python/blob/main/lighter/api/account_api.py"
click node_order_api "https://github.com/elliottech/lighter-python/blob/main/lighter/api/order_api.py"
click node_tx_api "https://github.com/elliottech/lighter-python/blob/main/lighter/api/transaction_api.py"
click node_referral_api "https://github.com/elliottech/lighter-python/blob/main/lighter/api/referral_api.py"
click node_bridge_api "https://github.com/elliottech/lighter-python/blob/main/lighter/api/bridge_api.py"
click node_other_apis "https://github.com/elliottech/lighter-python/tree/main/lighter/api"
click node_api_client "https://github.com/elliottech/lighter-python/blob/main/lighter/api_client.py"
click node_configuration "https://github.com/elliottech/lighter-python/blob/main/lighter/configuration.py"
click node_rest_transport "https://github.com/elliottech/lighter-python/blob/main/lighter/rest.py"
click node_response "https://github.com/elliottech/lighter-python/blob/main/lighter/api_response.py"
click node_errors "https://github.com/elliottech/lighter-python/blob/main/lighter/exceptions.py"
click node_models "https://github.com/elliottech/lighter-python/tree/main/lighter/models"
click node_signer "https://github.com/elliottech/lighter-python/blob/main/lighter/signer_client.py"
click node_nonce "https://github.com/elliottech/lighter-python/blob/main/lighter/nonce_manager.py"
click node_tx_builders "https://github.com/elliottech/lighter-python/tree/main/lighter/transactions"
click node_websocket "https://github.com/elliottech/lighter-python/blob/main/lighter/ws_client.py"
click node_signer_native "https://github.com/elliottech/lighter-python/tree/main/lighter/signers"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_exports toneBlue
class node_account_api,node_order_api,node_referral_api,node_other_apis,node_api_client,node_configuration,node_rest_transport,node_response,node_errors,node_models toneAmber
class node_tx_api,node_signer,node_nonce,node_tx_builders,node_signer_native toneMint
class node_bridge_api,node_websocket toneRose
class node_user,node_exchange toneIndigo
```

## Components

### SDK entry points

- [Public exports](https://github.com/elliottech/lighter-python/blob/main/lighter/__init__.py): `lighter/__init__.py`

### REST and data

- [Account endpoints](https://github.com/elliottech/lighter-python/blob/main/lighter/api/account_api.py): `lighter/api/account_api.py`
- [Order endpoints](https://github.com/elliottech/lighter-python/blob/main/lighter/api/order_api.py): `lighter/api/order_api.py`
- [Referral endpoints](https://github.com/elliottech/lighter-python/blob/main/lighter/api/referral_api.py): `lighter/api/referral_api.py`
- [Other REST families](https://github.com/elliottech/lighter-python/tree/main/lighter/api): `lighter/api`
- [API client](https://github.com/elliottech/lighter-python/blob/main/lighter/api_client.py): `lighter/api_client.py`
- [HTTP configuration](https://github.com/elliottech/lighter-python/blob/main/lighter/configuration.py): `lighter/configuration.py`
- [REST transport](https://github.com/elliottech/lighter-python/blob/main/lighter/rest.py): `lighter/rest.py`
- [Response wrapper](https://github.com/elliottech/lighter-python/blob/main/lighter/api_response.py): `lighter/api_response.py`
- [API exceptions](https://github.com/elliottech/lighter-python/blob/main/lighter/exceptions.py): `lighter/exceptions.py`
- [Typed models](https://github.com/elliottech/lighter-python/tree/main/lighter/models): `lighter/models`

### Trading and signing

- [Transaction endpoints](https://github.com/elliottech/lighter-python/blob/main/lighter/api/transaction_api.py): `lighter/api/transaction_api.py`
- [Signer client](https://github.com/elliottech/lighter-python/blob/main/lighter/signer_client.py): `lighter/signer_client.py`
- [Nonce manager](https://github.com/elliottech/lighter-python/blob/main/lighter/nonce_manager.py): `lighter/nonce_manager.py`
- [Transaction helpers](https://github.com/elliottech/lighter-python/tree/main/lighter/transactions): `lighter/transactions`
- [Native signer binaries](https://github.com/elliottech/lighter-python/tree/main/lighter/signers): `lighter/signers`

### Streaming and bridge

- [Bridge endpoints](https://github.com/elliottech/lighter-python/blob/main/lighter/api/bridge_api.py): `lighter/api/bridge_api.py`
- [Websocket client](https://github.com/elliottech/lighter-python/blob/main/lighter/ws_client.py): `lighter/ws_client.py`

### Other components

- **SDK caller**
- **Lighter exchange**

## Connections

- SDK caller → Public exports: imports SDK (evidence: `README.md`)
- Public exports → Account endpoints: exposes (evidence: `lighter/__init__.py`)
- SDK caller → Account endpoints: requests account data (evidence: `README.md`)
- Account endpoints → API client: calls (evidence: `lighter/api/account_api.py`)
- Order endpoints → API client: calls (evidence: `lighter/api/order_api.py`)
- Transaction endpoints → API client: calls (evidence: `lighter/api/transaction_api.py`)
- Referral endpoints → API client: calls (evidence: `lighter/api/referral_api.py`)
- Bridge endpoints → API client: calls (evidence: `lighter/api/bridge_api.py`)
- Other REST families → API client: uses (evidence: `lighter/api/account_api.py`)
- API client → HTTP configuration: configures (evidence: `lighter/api_client.py`)
- API client → REST transport: sends requests (evidence: `lighter/api_client.py`)
- REST transport → Lighter exchange: HTTP requests
- API client → Response wrapper: returns typed response (evidence: `lighter/api_client.py`)
- API client → API exceptions: raises (evidence: `lighter/api_client.py`)
- API client → Typed models: deserializes with (evidence: `lighter/api_client.py`)
- Account endpoints → Typed models: uses account models (evidence: `lighter/api/account_api.py`)
- Order endpoints → Typed models: uses market models (evidence: `lighter/api/order_api.py`)
- Transaction endpoints → Typed models: uses transaction models (evidence: `lighter/api/transaction_api.py`)
- Bridge endpoints → Typed models: uses bridge models (evidence: `lighter/api/bridge_api.py`)
- SDK caller → Signer client: creates and submits transactions (evidence: `README.md`)
- Signer client → Nonce manager: coordinates nonces (evidence: `lighter/signer_client.py`)
- Nonce manager → Transaction endpoints: fetches next nonce (evidence: `lighter/nonce_manager.py`)
- Signer client → Transaction helpers: uses transaction helpers (evidence: `lighter/signer_client.py`)
- Signer client → Native signer binaries: loads native signer
- Signer client → Transaction endpoints: submits transactions
- SDK caller → Websocket client: streams exchange state (evidence: `README.md`)
- Websocket client → Lighter exchange: opens websocket
- SDK caller → Bridge endpoints: uses bridge operations (evidence: `lighter/api/bridge_api.py`)
