> For the complete documentation index, see [llms.txt](https://txnlab.gitbook.io/haystack-dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://txnlab.gitbook.io/haystack-dev/haystack-router/architecture.md).

# Architecture

Order-Router Protocol

The Haystack Order Router protocol consists of two components:

* **Haystack Order Routing Algorithm (Off-Chain):** the Order Routing Algorithm computes the optimal route between two assets. The algorithm finds candidate routes between the two assets and combines them to maximize the output after fees.
* **Haystack Order Routing App (On-Chain):** the Order Routing App is used to perform multiple swaps atomically with the ability to compute asset balances before or after any swap is performed. This allows the App to execute complex routes that involve both multi-hop and combo swaps.

<figure><img src="https://4237715784-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ff7CoS3B3CCJggIxecPe2%2Fuploads%2Fgit-blob-11d7d174be8ce47a5543f6519cc1f1172c01ea6e%2ForderRouterProtocol.drawio%20(1).png?alt=media" alt=""><figcaption></figcaption></figure>
