> ## 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.

# Loan management system

> Run the full credit journey, from product definition through origination and servicing, with payroll-loan connectivity for Brazil.

A credit operation runs for months or years. It touches product, risk, operations, and accounting at every stage. Most institutions assemble it from a product catalog here, an origination tool there, and servicing in the core.

Lerian composes it from separate pieces that each own one boundary. Lender runs the credit journey, Midaz holds the balances, and the Consignado CLT (Dataprev) rail owns the Dataprev boundary. Each piece hands the next one a recorded fact, never a guess.

## What you get

***

<Columns cols={3}>
  <Card title="Lender" icon="https://mintcdn.com/lerian-49cb71fc/47c4N7ZVIXfTkwUf/images/icons/core-banking-yellow.png?fit=max&auto=format&n=47c4N7ZVIXfTkwUf&q=85&s=05a04a8e503c01720a0d7e20fdd752ef" href="/en/lender/what-is-lender" width="1250" height="1250" data-path="images/icons/core-banking-yellow.png">
    The credit journey engine. It owns loan products, origination, servicing, posting rules and accrual runs, and the audit trail, for consumer credit (CDC). The ledger stays the source of truth for balances.
  </Card>

  <Card title="Consignado CLT (Dataprev)" icon="hand-holding-dollar" href="/en/rails/native/consignado/what-is-lerian-consignado">
    The native rail to Dataprev's Crédito do Trabalhador program for private-sector payroll loans.
  </Card>

  <Card title="Midaz" icon="https://mintcdn.com/lerian-49cb71fc/fChpL6UWCA02zfZr/images/icons/midaz-yellow.png?fit=max&auto=format&n=fChpL6UWCA02zfZr&q=85&s=66030808cf88e9836f58b228bdb04718" href="/en/midaz/what-is-midaz" width="270" height="270" data-path="images/icons/midaz-yellow.png">
    The source of truth for balances. It receives each disbursement and each interest accrual as a balanced double-entry transaction.
  </Card>

  <Card title="Access Manager" icon="https://mintcdn.com/lerian-49cb71fc/E8ayMkxDRO5pydGF/images/icons/access-manager-yellow.png?fit=max&auto=format&n=E8ayMkxDRO5pydGF&q=85&s=2383ad0e8e8ee6f46c95a9fbeb440ab2" href="/en/platform/access-manager/access-manager" width="1249" height="1249" data-path="images/icons/access-manager-yellow.png">
    Issues the machine-to-machine credentials and the short-lived JWT that the ledger relay carries, per tenant.
  </Card>

  <Card title="Matcher" icon="https://mintcdn.com/lerian-49cb71fc/fChpL6UWCA02zfZr/images/icons/matcher-yellow.png?fit=max&auto=format&n=fChpL6UWCA02zfZr&q=85&s=7fae0f09ee6ed8638a2175a2e84e0711" href="/en/matcher/what-is-matcher" width="270" height="270" data-path="images/icons/matcher-yellow.png">
    Turns a reconciliation verdict into a servicing action. Lender consumes the completed match run.
  </Card>

  <Card title="Streaming Hub" icon="tower-broadcast" href="/en/streaming-hub/what-is-streaming-hub">
    Delivers Lender and Consignado facts to a webhook, a cloud queue, or a cursor you pull.
  </Card>
</Columns>

## How the pieces fit together

***

```mermaid theme={null}
flowchart LR
  Channel["Your channel<br/>web, app, or partner"]
  Lender["Lender<br/>the credit journey"]
  GW["Consignado CLT (Dataprev)<br/>native rail"]
  Dataprev["Dataprev"]
  Midaz["Midaz ledger<br/>balances"]
  AM["Access Manager<br/>issues tokens"]
  Matcher["Matcher<br/>reconciliation verdicts"]
  Hub["Streaming Hub<br/>delivers events"]
  Sink["Your systems"]
  Channel -->|"REST /api/v1"| Lender
  Lender -.->|"commands on lerian.streaming.lender.commands"| GW
  GW -->|"per-tenant credentials and certificate"| Dataprev
  GW -.->|"facts on lerian.streaming.consignado-gw"| Lender
  Lender -->|"posting intent, outbox, relay"| Midaz
  AM -.->|"M2M credentials, short-lived JWT"| Lender
  Matcher -.->|"match_run.completed"| Lender
  Lender -.->|"facts on lerian.streaming.lender"| Hub
  Hub -.->|"webhook, queue, or pull"| Sink
  classDef lerian fill:#fff8e1,stroke:#f4b400,color:#333;
  classDef yours fill:#e8f0fe,stroke:#4285f4,color:#333;
  classDef ext fill:#f1f3f4,stroke:#9aa0a6,color:#333;
  class Lender,GW,Midaz,AM,Matcher,Hub lerian;
  class Channel,Sink yours;
  class Dataprev ext;
```

1. Your channel calls Lender over HTTP. Loan products, applications, loan accounts, accrual runs, and the Brazilian regulatory records all sit under `/api/v1`. There is no client library to install.
2. For a payroll loan, Lender emits a command on its command topic. The rail reads that command and calls Dataprev with the tenant's requester code, OAuth credentials, and ICP-Brasil certificate.
3. The rail publishes business facts back onto its own topic. Lender consumes those facts and moves the loan application through its stages.
4. A disbursement or an interest accrual writes a durable posting intent. The intent lands in the same database transaction that changes the domain state.
5. The ledger relay posts the balanced double-entry transaction to Midaz through the official SDK. Each posting carries a deterministic idempotency key, so a retried post collapses to one Midaz transaction.
6. The relay reaches Midaz through Access Manager. It authenticates with machine-to-machine credentials and a short-lived JWT, per tenant.
7. Lender publishes its own facts on its own event topic. Streaming Hub follows that topic and delivers each matched event to a destination you own.

Routing fails closed. The accounting profile resolves the organization and the ledger that receive each posting. When routing resolves no target, Lender refuses to post rather than book into an empty or wrong ledger.

One optional input closes the loop. When you reconcile with Matcher, Lender consumes the completed match run and translates the verdict into a servicing stage transition and the matching posting intent. That integration is configuration-gated, and both sides must agree on the CloudEvents source before you enable it.

## What each piece owns

***

| Piece                     | Source of truth for                                                                                                | Talks to                                                                                          | You keep                                                                             |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| Lender                    | the credit journey: loan products, applications, loan accounts, accrual runs, and the Brazilian regulatory records | Midaz through the ledger relay, the Consignado rail through commands and facts, and Matcher facts | underwriting, pricing, approval policy, the loan product, and customer communication |
| Midaz                     | balances                                                                                                           | receives the postings the relay sends                                                             | your ledger data, in your database                                                   |
| Consignado CLT (Dataprev) | the Dataprev boundary                                                                                              | Dataprev, and Lender through the stream                                                           | the requester code, OAuth credentials, and ICP-Brasil certificate of each tenant     |
| Access Manager            | the identities and the tokens each service trusts                                                                  | Lender, on the way to Midaz                                                                       | your people and your machine-to-machine applications                                 |
| Matcher                   | match rules, runs, and verdicts                                                                                    | Lender, which consumes the completed match run                                                    | your reconciliation sources                                                          |
| Streaming Hub             | which Lender and Consignado facts reach which destination                                                          | the fact topics, and the sinks you register                                                       | your sinks and your signing secrets                                                  |

## Adopt it one piece at a time

***

<Steps>
  <Step title="Run a first loan with Lender alone">
    PostgreSQL and Valkey are the services origination needs. Production also requires an identity provider for route authorization. A first loan needs no Midaz and no RedPanda. The posting intent stays durable in the outbox until you configure a ledger.
  </Step>

  <Step title="Configure the ledger relay">
    Point Lender at Midaz and at Access Manager. Lender then posts each disbursement and each accrual as a balanced transaction. Before the relay posts, Lender makes sure each account alias in the accounting profile exists. It skips external accounts, and it never creates assets.
  </Step>

  <Step title="Add the Consignado CLT (Dataprev) rail">
    Private-sector payroll loans reach Dataprev's Crédito do Trabalhador program through the native rail. Register the tenant's ICP-Brasil certificate, OAuth credentials, and three-digit requester code before the first call.
  </Step>

  <Step title="Close the loop on the facts">
    Turn on streaming and subscribe to Lender facts in Streaming Hub. When you reconcile with Matcher, first agree the event contract on both sides. Then turn on the Matcher listener in Lender.
  </Step>
</Steps>

## Bring your own

***

* **Your channels.** The REST API is the whole client surface, so you call Lender from the stack you already run.
* **Your secrets custody.** The relay reads its machine-to-machine credentials from AWS Secrets Manager, or from HashiCorp Vault KV v2 when you select it.
* **Your identity protocols.** Access Manager's identity provider supports OAuth 2.0 and OIDC, SAML 2.0, SCIM 2.0 provisioning, and LDAP against an external directory.
* **Your event consumers.** A Streaming Hub subscription delivers to a webhook, a pull cursor, Amazon SQS, RabbitMQ, or Amazon EventBridge.
* **Your reconciliation sources**, through Matcher. See [Reconciliation](/en/solutions/reconciliation).

## A worked example

***

This example follows a private-sector payroll loan from the first call to the ledger entry.

1. Your channel creates the loan application in Lender against a loan product version.
2. Lender emits the margin request command. The rail performs the worker margin read against Dataprev and returns the rail response, without turning it into an underwriting decision.
3. You price the loan and approve it under your own credit policy. Lender records the contracted rate, the CET, the IOF, and the installment plan as facts, and binds them to the product version.
4. Brazilian origination adds regulated steps. Lender records the CET disclosure. It also records the capitalization consent, with the clause text and the hash it recomputes.
5. The rail registers the contract with Dataprev, attaches the CCB document, and publishes the booking and payment facts. Lender consumes the contract registration and the disbursement confirmation.
6. Lender commits the disbursement event, the origination schedule, and the posting intent in one database transaction. The relay posts the balanced transaction to Midaz shortly after the response.
7. Each accrual run posts the same way, on the same idempotency guarantee. If you reconcile, a completed match run moves the servicing stage and creates the matching posting intent.

## Start here

***

<Columns cols={3}>
  <Card title="What is Lender?" icon="https://mintcdn.com/lerian-49cb71fc/47c4N7ZVIXfTkwUf/images/icons/core-banking-yellow.png?fit=max&auto=format&n=47c4N7ZVIXfTkwUf&q=85&s=05a04a8e503c01720a0d7e20fdd752ef" href="/en/lender/what-is-lender" width="1250" height="1250" data-path="images/icons/core-banking-yellow.png">
    The five domains of the credit journey, and what each one owns.
  </Card>

  <Card title="Lender quick start" icon="https://mintcdn.com/lerian-49cb71fc/E8ayMkxDRO5pydGF/images/icons/code-yellow.png?fit=max&auto=format&n=E8ayMkxDRO5pydGF&q=85&s=5ff68ec60f9a6219649dc6d0457b5fa6" href="/en/lender/lender-quick-start" width="1249" height="1249" data-path="images/icons/code-yellow.png">
    Six calls from an empty database to a disbursed loan.
  </Card>

  <Card title="Consignado CLT (Dataprev)" icon="hand-holding-dollar" href="/en/rails/native/consignado/what-is-lerian-consignado">
    What the payroll rail covers, and where its responsibility ends.
  </Card>
</Columns>
