> For the complete documentation index, see [llms.txt](https://docs.yifi.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yifi.io/getting-started/architecture-overview.md).

# Architecture Overview

## Architecture

> The routing engine that compares CEX, DEX, and private liquidity, then orchestrates execution through one API.

{% hint style="info" %}
This page describes the Swap routing engine. It lives in the Developer Hub alongside API Reference and is aimed at integrators, not end users – for the product-facing explanation, see How it works.&#x20;
{% endhint %}

### System architecture

YiFi sits between your application and every liquidity source it supports. It queries providers, ranks the results, and orchestrates execution through whichever one wins the route.

```mermaid
graph TB
    A[User] --> B[Your application]
    B --> C[YiFi Swap API]
    C --> D{Routing engine}
    D -->|On-chain route| E[DEX aggregators]
    D -->|Off-chain route| F[CEX exchange partners]
    D -->|Private route| G[Partner exchanges, two-leg]
    E --> H[Recipient wallet]
    F --> H
    G --> H
```

### Key components

#### 1. Your application

Integrates with YiFi through:

* **REST API** – direct HTTP calls for full control over quoting, order creation, and status tracking.
* **Widget** – an embeddable swap interface for a minimal-integration path.

See API Reference.

#### 2. Routing engine

The core YiFi Swap orchestration layer.

* Queries all connected providers across the three rails for a given request.
* Ranks routes by expected output, fees, and estimated time.
* Builds the transaction (on-chain) or deposit instruction (off-chain / private) for the selected route.
* Tracks order state through to settlement and exposes it via the status endpoint.

#### 3. On-chain DEX aggregation

Non-custodial execution through audited smart contracts; same-chain swaps are atomic, cross-chain routes are multi-step.

#### 4. Off-chain CEX exchange partners

One-to-one deposit-and-forward execution; no wallet connection or gas required from the user.

#### 5. Private routing

Two-leg execution through partner exchanges with an intermediate hop. See [Private Swaps](/swap-types/private-swaps.md).

#### 6. Recipient wallet&#x20;

Funds are sent to the address the user specifies – a standard receiving wallet address.

### Routing strategies

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-cover data-type="image">Cover image</th></tr></thead><tbody><tr><td><strong>DEX Routes</strong></td><td>Transparent, non-custodial, atomic on same chain</td><td></td></tr><tr><td><strong>CEX Routes</strong></td><td>No wallet or gas, widest coverage</td><td></td></tr><tr><td><strong>Private Routes</strong></td><td>Untraceable on-chain. No wallet connection required.</td><td></td></tr></tbody></table>

Each strategy can be requested independently through the API – see [API Reference](https://claude.ai/swap/api-reference.md) for the relevant endpoints.
