# Run locally

As the [public website](https://www.orderbook.wtf/) is limited in its ability to process all orderbook requests and update them dynamically, anyone can clone and launch the interface and adapt it to their needs.

By default, the [orderbook.wtf](https://www.orderbook.wtf/) user interface simulates between 20 and 40 points on each side. A real orderbook would require 10x or 100x more simulations. So let's deploy locally.

By customising the backend, you can run your own unlimited orderbook simulations and use your own solver to customise the algorithm behind it.

You can start by cloning the repository [here](https://github.com/0xMerso/tycho-orderbook-web).

The repository has a NextJS frontend and a Rust backend API.

The application is designed to be modular and can be launched effortlessly using docker compose.

The repo has the `sdk` and the `frontend` part as a submodule, so to clone it, do :

```bash
git clone --recurse-submodules https://github.com/0xMerso/tycho-orderbook-web web
cd web
```

It's important to have the following tree structure

```sh
tree -L 1
├── back
├── docker-compose.yaml
├── front
├── sdk
└── update.sh
```

If you prefer, step by step.

```sh
# Make sure you've cloned the 2 submodules
cd web
git pull --recurse-submodules
git submodule update --remote --recursive


# Optionally
cd sdk ; git pull origin main
cd front ; git pull origin main

```

#### Docker Setup Instructions

Make sure Docker is installed and active. You can launch the whole stack with one shell script.

```sh
sh launch.sh
```

Or, step by step.

```bash
cp -n back/.env.ex back/.env # Duplicate .env.ex to .env, if not already existing

docker network create tycho
# Start with UI
docker compose up --build -d --profiles ui
# Start without UI if you just need the API & Terminal logs
docker compose up --build -d

# Logs
docker compose logs -f
# Stop it
docker compose stop
# Remove it
docker compose down
# Restart it
docker compose restart
```

You can then access the UI at `http://localhost:3000/`

The swagger at  `http://localhost:42042/swagger`

You can also use an SSH tunnel to view it from your local machine if you're running the docker compose on a remote server.

```sh
ssh -i ~/.ssh/id_rsa -L 3000:localhost:3000 user@ip
```

#### Local Setup Instructions

If you prefer to build and run the application directly, we provide shell scripts for simple startup.\
You will need to install **Rust, Node, Redis.**

```bash
git clone --recurse-submodules https://github.com/0xMerso/tycho-orderbook-web web
cd back
# Launch 'ethereum' Axum API + Redis. You can use 'base' instead
sh ops/local.api.start.sh ethereum
# Tests
sh ops/local.api.test.sh ethereum

```

```bash
cd front/front
pnpm install
pnpm dev
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tycho-orderbook.gitbook.io/docs/application/run-locally.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
