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

# System Overview

> LI.FI architectural overview

## Introduction

LI.FI is a multi-chain liquidity aggregation platform that connects decentralized applications (dApps) with various liquidity sources, including bridges, decentralized exchanges (DEXs), and solvers. This architecture enables seamless cross-chain and same-chain trading by facilitating price discovery, smart order routing, and efficient execution.

***

<img src="https://mintcdn.com/lifi/08FOM1AsMmrVbIEl/images/lifi-architecture.png?fit=max&auto=format&n=08FOM1AsMmrVbIEl&q=85&s=63e3d93ede3d25569bd5e492745a79d3" alt="LI.FI Overview" width="5088" height="2176" data-path="images/lifi-architecture.png" />

## Key Components of LI.FI Architecture

### 1. **dApp Interface (Integrators)**

* **Function**: What the end-user interacts with. dApps initiate quote requests and route selection to LI.FI's API.
* **Process**: A user sends a request from the dApp for the best trading route or quote, which is forwarded to LI.FI API for processing. Once the optimal route is selected, the dApp submits a transaction to execute the trade.

### 2. **LI.FI API - Aggregation and Routing Layer**

* **Purpose**: This off-chain layer performs core price discovery and smart order routing by interfacing with various liquidity sources.
* **Functionality**:
  * **Fetch Pricing**: LI.FI API retrieves quotes from multiple sources, including bridges, DEXs, and solvers, to determine the best price and route.
  * **Return Quote**: Once the optimal route is identified, LI.FI API returns the quote to the dApp.
  * **Order Routing**: The dApp submits the transaction with the selected route, which LI.FI API processes by routing it to the LI.FI Diamond Contract on-chain.

### 3. **LI.FI Diamond Contract**

* **Function**: Acts as the primary on-chain entry point, handling the execution of transactions based on the chosen route from LI.FI API.
* **Role**:
  * Routes the transaction to the appropriate **facet contract** (bridge, DEX, or solver) based on the chosen liquidity source.
  * Acts as the router for on-chain executions, allowing modular connections to different liquidity sources.

### 4. **LI.FI Facet Contracts**

Specialized on-chain contracts that interface with respective liquidity sources:

* **Bridge Facet Contracts**
  * Route transactions to specific bridge contracts (e.g., Bridge A or Bridge B) for cross-chain transfers.
  * Ensure bridge compatibility and secure asset transfer across blockchains.

* **DEX Facet Contracts**
  * Route transactions to specific DEX contracts for same-chain swaps.
  * Optimize execution based on DEX-specific parameters for efficient liquidity utilization.

* **Solver Facet Contracts**
  * Route transactions to solver contracts for accessing extended liquidity sources.
  * Enable advanced routing and pricing calculations based on solver protocols.

### 5. **Bridge/DEX/Solver Contracts**

Final execution of trades occurs on the blockchain network through interactions with selected liquidity providers (bridge, DEX, or solver contracts).

***

## End-to-End Order Flow

1. **Initiate Request**
   * A user initiates a quote request from the dApp for a multi-chain or same-chain trade.

2. **Quote and Route Discovery**
   * LI.FI BE receives the request and queries bridges, DEX aggregators, and solvers to gather pricing data and route options.
   * The optimal route is determined and returned to the dApp.

3. **Transaction Submission**
   * The user selects the best route in the dApp, which submits the transaction to LI.FI Diamond contract with the selected quote data.

4. **On-Chain Execution**
   * LI.FI Diamond contract forwards the transaction to the respective LI.FI Facet contract for execution.
   * The facet contract executes the transaction with the specific bridge, DEX, or solver on-chain contract, finalizing the trade or transfer.

5. **Output Return**
   * Once the transaction is complete, the resulting assets are returned to the user.
