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

# TED Lerian architecture

> How TED Lerian connects your institution to Midaz and Lerian SPB, where it keeps its data, and the components inside the service.

## Connected systems

***

* **Your institution's systems** send and read TEDs over HTTPS and receive the events.
* **Operators and administrators** run the queue, the deadlines and the policies through the API.
* **Access Manager** validates the token and the permission of each call.
* **Midaz** holds, settles and releases the amounts, calculates fees and answers account and holder lookups.
* **Lerian SPB** carries the messages to and from the STR over the RSFN.
* **Streaming Hub** delivers the events to your institution's subscription.

## Service and data

***

What runs inside TED Lerian and where each piece of data lives. The API and the background workers are one service.

* **TED service.** Answers the `/v1` API and runs the background workers: reconciliation, incoming TEDs, the daily cycle and the event relay. Each institution's data is isolated.
* **PostgreSQL** keeps transfers, incoming TEDs, returns, policies, the event outbox and the inbox of STR facts.
* **MongoDB** keeps the audit trail.
* **Valkey** keeps idempotency records, rate-limit counters and usage-limit counters.
* **Events.** Each status change writes its event in the same database transaction (outbox), and a relay publishes it on the platform event backbone. Streaming Hub delivers it from there.
* **STR facts.** Lerian SPB publishes what the STR reported (settlement, rejection, incoming TED, schedule changes, closing balance) on the event backbone. The TED service reads them through an inbox that never applies the same fact twice.

## Components of the TED service

***

The service has four domains, each with its own rules, data and endpoints.

| Component | What it does | API and events |
| - | - | - |
| Sending | Quotes, sends TEDs and internal transfers, cancels, reads, reconciles and unblocks. | `/v1/transfers`, `/v1/reconciliation`, `transfer.*` |
| Receiving | Credits incoming TEDs after checking the holder, returns them with the official reason, and handles manual reviews. | `/v1/incoming-transfers`, `incoming_transfer.*`, `incoming_return.*` |
| Policy | The effective window, cut-off, holidays, usage limits, ISPB bindings and the STR participant list. Follows the schedule changes the STR announces. | `/v1/policy`, `/v1/participants` |
| Operations | The daily dashboard, regulatory deadlines, the operations queue, inconsistencies and the closing balance the STR reports. | `/v1/operations`, `/v1/reconciliation/queue`, `/v1/reconciliation/inconsistencies` |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.