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

# System architecture

> How the Relayer, Aggregator, Gateway, and mxnode operator tooling fit together.

Four independently deployable surfaces cover the full MultiversX lifecycle: chain observation, swap routing, transaction broadcasting, and node operation. The first three share an event-driven backbone; mxnode is operator tooling installed on each validator or observer host.

## Core services

| Service             | Role                                                                                                                                                                  | Docs                                        |
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- |
| Transaction Relayer | WebSocket and REST interface for broadcasting, co-signing, and streaming real-time chain data directly from the P2P gossipsub network.                                | [Relayer overview](/relayer/overview)       |
| DEX Aggregator      | REST API that evaluates liquidity across four DEXs and returns ready-to-sign swap transactions with split routing.                                                    | [Aggregator overview](/aggregator/overview) |
| Gateway             | Rust-native MultiversX RPC proxy with 80 endpoints, shard-aware routing, and request deduplication.                                                                   | [Gateway overview](/gateway/overview)       |
| mxnode              | Installs, operates, and upgrades MultiversX validators, observers, and multikey squads on Linux hosts.                                                                | [mxnode overview](/mxnode/overview)         |
| Notifier            | Internal service that processes finalized blockchain events and distributes account deltas, transaction confirmations, and pool state changes to downstream services. | Internal                                    |

## Service endpoints

| Service             | Protocol  | Endpoint                                                                           |
| ------------------- | --------- | ---------------------------------------------------------------------------------- |
| Transaction Relayer | WebSocket | `wss://relayer.xoxno.com/ws`                                                       |
| Transaction Relayer | REST      | `https://relayer.xoxno.com`                                                        |
| DEX Aggregator      | REST      | `https://swap.xoxno.com`                                                           |
| Gateway             | RPC       | `https://rust-gateway.xoxno.com`                                                   |
| mxnode              | CLI       | `curl -fsSL https://raw.githubusercontent.com/XOXNO/mx-node/main/install.sh \| sh` |

## Data flow

```mermaid theme={"system"}
flowchart LR
    V[Validators] --> P2P[P2P Network]

    P2P --> R[mx-relayer]
    R -->|Gas stats · 50 ms| C1[Client WebSocket]
    R -->|Network snapshots| C1
    R -->|Tx broadcasting| P2P

    V --> N[mx-notifier]
    N -->|Account deltas| R
    N -->|Tx status| R
    R -->|Account and Tx events| C2[Client WebSocket]

    N -->|Pool state changes| A[arb-algo]
    A -->|Quote and Tx| C3[Client REST]

    V --> O[Observers]
    O --> G[Gateway]
    G -->|RPC responses| C4[Client REST]

    style V fill:#053c7f,color:#fff
    style P2P fill:#053c7f,color:#fff
    style O fill:#053c7f,color:#fff
    style R fill:#007bff,color:#fff
    style N fill:#007bff,color:#fff
    style A fill:#007bff,color:#fff
    style G fill:#007bff,color:#fff
    style C1 fill:#3bc5fc,color:#000
    style C2 fill:#3bc5fc,color:#000
    style C3 fill:#3bc5fc,color:#000
    style C4 fill:#3bc5fc,color:#000
```

### Path 1: Gas and block observation

The Relayer participates as an observer in the P2P gossipsub network, extracting gas prices from pending mempool transactions and recently finalized blocks. Per-shard gas statistics reach clients within 50 ms of new mempool activity; network snapshots follow at adaptive intervals tuned to block time.

### Path 2: Account and transaction updates

The notifier ingests finalized events and forwards them to the Relayer: balance mutations, nonce increments, and transaction confirmations. The Relayer then distributes each update to every client subscribed to the relevant address or transaction hash.

### Path 3: DEX aggregation

The Aggregator receives pool state changes from the notifier the moment they finalize on-chain. On each quote request, it evaluates liquidity across all supported DEXs, computes the split route, and returns a ready-to-sign transaction.

### Path 4: Chain state queries

The Gateway forwards HTTP requests to shard observer nodes. It derives the target shard from the request (usually the address), selects an observer via round-robin, and returns the response. The Gateway TTL-caches block, hyperblock, and validator data; it coalesces identical concurrent requests into a single observer call.

## When to use which service

| Use case                                  | Service                          | Rationale                                                                                     |
| ----------------------------------------- | -------------------------------- | --------------------------------------------------------------------------------------------- |
| Stream real-time gas prices               | Relayer WebSocket                | 50 ms cadence from P2P observation, push-based delivery                                       |
| Monitor account balance changes           | Relayer WebSocket                | Push-based delivery as soon as a block is finalized                                           |
| Broadcast a signed transaction            | Relayer REST or WebSocket        | Direct P2P delivery to validators                                                             |
| Gasless transaction (V3)                  | Relayer WebSocket                | Enterprise: relayer co-signs and covers gas on behalf of the user                             |
| Execute a token swap                      | Aggregator REST                  | Split routing across four DEXs with a complete transaction object                             |
| Query chain state (blocks, accounts, VMs) | [Gateway RPC](/gateway/overview) | Standard MultiversX RPC with shard-aware routing and caching                                  |
| Build a trading bot                       | Relayer + Aggregator             | Stream gas statistics for timing, request quotes for execution, broadcast through the Relayer |

Combine the Gateway with the Relayer when you need both reads and events: use the Gateway for on-demand chain queries and the Relayer WebSocket for gas stats, account deltas, and transaction confirmations.

## Internal components

| Component       | Role                                                                                                                                                      |
| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **mx-relayer**  | Maintains persistent P2P connections. Exposes WebSocket topics, broadcasting, Relayer V3 co-signing, and historical network stats.                        |
| **arb-algo**    | DEX Aggregator. Consumes pool state from the notifier and computes split routes across all supported DEXs.                                                |
| **mx-notifier** | Internal only. Watches finalized blocks for account mutations, tx confirmations, and pool changes, then distributes events to the Relayer and Aggregator. |
| **Gateway**     | Rust-native MultiversX RPC at `rust-gateway.xoxno.com` with 80 endpoints, shard-aware routing, TTL caching, and request coalescing.                       |
