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

# Routing

> Frontline route assignment and traffic switching

Routing updates are handled by the routing Restate service. It updates frontline route records to point to the desired deployment.

Key components:

* Routing service ([`svc/ctrl/worker/routing`](https://github.com/unkeyed/unkey/blob/main/svc/ctrl/worker/routing)).
* Frontline route records in the database.

## Flow: assign routes

```mermaid theme={"theme":"kanagawa-wave"}
sequenceDiagram
  participant Worker as Control Worker
  participant Routing as Routing Service
  participant DB as MySQL

  Worker->>Routing: AssignFrontlineRoutes(project_id key, route ids)
  Routing->>DB: Update frontline_routes deployment_id
```

## Notes

`AssignFrontlineRoutes` updates each route sequentially with `ReassignFrontlineRoute` and sets `updated_at` for each row.
