Skip to content

Business loan application

Kestrel Business Banking, an invented bank, offers pre-approved loans to the small businesses that bank with it. Its online banking has a fixed flow for this that it cannot easily change, so it renders Mica documents inside it and keeps every decision to itself. Two documents are involved, and neither knows the workflow:

  • loan-application.json has two pages: Your loan, the first round of questions, and A few more questions, which declares every follow-up question the bank might ask. No button in the document links to the second page.
  • loan-decision.json is a separately prepared document that loads one decision and lets the applicant sign an offer.

The bank decides which document to render, which page of it to show, what the introduction says, which follow-up questions to ask, and when to refuse.

The bar above the preview is the host’s: who is signed in, and where the host has put the applicant. The host log lists each action the document’s buttons dispatch and each step the host takes. The bank’s rules are invented for the example and run in your browser.

  • Straight to a decision. As Marta, ask for 30000 for Stock over 24 months, with 300000 of sales. This is inside her pre-approved limit, so the host decides at once and renders the decision document. Sign it by typing her name (a different name is refused under the field).
  • The host asks for more. Reset, then ask for 55000 for Equipment over 36 months, with 300000 of sales. The host moves you to A few more questions with a new headline and introduction, and shows only two of the four question groups: security (the amount is above the limit) and the supplier’s quote (equipment over €15,000). Each group says why the host asks.
  • A refusal on the second page. Offer security worth 10000. The host refuses and names the field: security must cover the €15,000 above the limit. Change it to 20000 and continue.
  • A refusal on the first page. Enter 100000 as last year’s sales. The host compares it with the €318,400 it saw in Marta’s account and asks her to check it. An amount above 120000, three times her limit, is refused too.
  • Another applicant, the same document. Switch to Kieran. The layout and the questions are the same, but the headline, introduction, limit and rate are his. Ask for 40000 to Refinance a loan over 48 months with 140000 of sales: the host asks three groups this time. Answer them with security worth 30000, any lender but Kestrel (a Kestrel loan is refused), a balance of 18000 and monthly costs of 11000. The repayment leaves too little to spare, so the host refers the application to an underwriter instead of making an offer, and the same decision document shows that outcome.

The application is a business object with only an update capability. The host seeds the store with the applicant’s record before the first render, so the personalised content is there at once, with no fetch. The headline, introduction, guidance, limit and rate are fields of that record, and each follow-up question has an asked flag and a reason. The limit and rate are raw numbers (the rate a fraction), which the page formats with $format:

{
"fields": {
"id": {
"kind": "string",
"required": true
},
"stage": {
"kind": "string",
"required": true,
"enum": [
"details",
"follow-up",
"decided"
]
},
"headline": {
"kind": "string",
"required": true
},
"intro": {
"kind": "string",
"required": true
},
"guidance": {
"kind": "string",
"required": true
},
"limit": {
"kind": "number",
"required": true
},
"apr": {
"kind": "number",
"required": true
},
"requestLabel": {
"kind": "string",
"nullable": true
},
"decisionId": {
"kind": "string",
"nullable": true
},
"followUp": {
"kind": "object",
"required": true,
"fields": {
"collateral": {
"kind": "object",
"required": true,
"fields": {
"asked": {
"kind": "boolean",
"required": true
},
"reason": {
"kind": "string",
"required": true
}
}
},
"refinance": {
"kind": "object",
"required": true,
"fields": {
"asked": {
"kind": "boolean",
"required": true
},
"reason": {
"kind": "string",
"required": true
}
}
},
"quote": {
"kind": "object",
"required": true,
"fields": {
"asked": {
"kind": "boolean",
"required": true
},
"reason": {
"kind": "string",
"required": true
}
}
},
"affordability": {
"kind": "object",
"required": true,
"fields": {
"asked": {
"kind": "boolean",
"required": true
},
"reason": {
"kind": "string",
"required": true
}
}
}
}
}
}
}

The first page reads those fields like any other state:

{
"hero-headline": {
"type": "Heading",
"props": {
"content": {
"$state": "/objects/application/data/headline"
},
"level": "1",
"align": "left",
"accent": true
},
"children": []
},
"hero-intro": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/application/data/intro"
},
"size": "lg",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"hero-limit-value": {
"type": "Text",
"props": {
"content": {
"$format": "currency",
"value": {
"$state": "/objects/application/data/limit"
},
"currency": "EUR"
},
"size": "lg",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"expect-guidance": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/application/data/guidance"
},
"size": "md",
"tone": "muted",
"align": "left",
"italic": false
},
"children": []
}
}

Both Continue buttons dispatch the same update, with all twelve answers. The four first-round inputs are always required. Each follow-up input is required only while the host’s record says its question is asked, so an unanswered, unasked question does not stop the first page:

{
"inputs": {
"amount": {
"kind": "number",
"required": true,
"minimum": 5000,
"maximum": 250000
},
"purpose": {
"kind": "string",
"required": true,
"enum": [
"equipment",
"stock",
"refinance",
"premises"
]
},
"termMonths": {
"kind": "integer",
"required": true,
"minimum": 6,
"maximum": 60
},
"annualRevenue": {
"kind": "number",
"required": true,
"minimum": 1
},
"collateralDescription": {
"kind": "string",
"requiredWhen": {
"$state": "/objects/application/data/followUp/collateral/asked"
},
"maxLength": 120
},
"collateralValue": {
"kind": "number",
"requiredWhen": {
"$state": "/objects/application/data/followUp/collateral/asked"
},
"minimum": 0
},
"existingLender": {
"kind": "string",
"requiredWhen": {
"$state": "/objects/application/data/followUp/refinance/asked"
},
"maxLength": 80
},
"existingBalance": {
"kind": "number",
"requiredWhen": {
"$state": "/objects/application/data/followUp/refinance/asked"
},
"minimum": 0
},
"supplierName": {
"kind": "string",
"requiredWhen": {
"$state": "/objects/application/data/followUp/quote/asked"
},
"maxLength": 80
},
"quoteReference": {
"kind": "string",
"requiredWhen": {
"$state": "/objects/application/data/followUp/quote/asked"
},
"maxLength": 40
},
"monthlyOutgoings": {
"kind": "number",
"requiredWhen": {
"$state": "/objects/application/data/followUp/affordability/asked"
},
"minimum": 0
},
"notes": {
"kind": "string",
"maxLength": 500
}
}
}

Mica checks those declared rules before the host is asked, and reports a missing or out-of-range answer under its field. The host sees only answers that pass them.

The second page declares every follow-up question. Each group is shown only while the host asks it, and opens with the host’s reason:

{
"ask-collateral": {
"type": "Section",
"props": {
"eyebrow": "SECURITY",
"title": "What can secure the loan?",
"tone": "outlined",
"padding": "lg"
},
"children": [
"ask-collateral-reason",
"collateral-description",
"collateral-value"
],
"visible": {
"$state": "/objects/application/data/followUp/collateral/asked"
}
},
"ask-collateral-reason": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/application/data/followUp/collateral/reason"
},
"size": "md",
"tone": "muted",
"align": "left",
"italic": false
},
"children": []
}
}

The host’s update answers with the next record: a new headline and introduction, a stage of follow-up, and the questions it wants asked. The host shell reads stage and passes page-follow-up to PageProvider. When the host refuses instead, it throws an error with a message per field, the record stays as it was, and so does the page. Each field’s error reads its field’s message, which shows under the field:

{
"collateral-value": {
"type": "NumberField",
"props": {
"label": "What is it worth today?",
"format": "currency",
"currency": "EUR",
"min": 0,
"required": true,
"helpText": "A recent valuation or purchase price.",
"value": {
"$bindState": "/answers/collateralValue"
},
"error": {
"$state": "/meta/objects/application/operations/update/error/fieldErrors/collateralValue"
}
},
"children": []
}
}

Once the host decides, the record’s stage is decided and it names a decisionId. The host stops rendering the application and renders loan-decision.json instead, with that id in its state. The decision document loads the decision at startup:

{
"lifecycle": {
"startup": [
{
"action": "fetch",
"params": {
"object": "decision",
"inputs": {
"decisionId": {
"$state": "/decisionId"
}
}
}
}
]
}
}

The same document shows an offer or a referral, whichever the decision is:

{
"offer": {
"type": "Section",
"props": {
"eyebrow": "YOUR OFFER",
"title": null,
"tone": "ink",
"padding": "xl"
},
"children": [
"offer-headline",
"offer-summary",
"offer-terms",
"offer-total"
],
"visible": [
{
"$state": "/meta/objects/decision/operations/fetch/phase",
"eq": "success"
},
{
"$state": "/objects/decision/data/outcome",
"eq": "offer"
}
]
},
"referred": {
"type": "Section",
"props": {
"eyebrow": "WITH AN UNDERWRITER",
"title": null,
"tone": "ink",
"padding": "xl"
},
"children": [
"referred-headline",
"referred-summary",
"referred-facts"
],
"visible": [
{
"$state": "/meta/objects/decision/operations/fetch/phase",
"eq": "success"
},
{
"$state": "/objects/decision/data/outcome",
"eq": "referred"
}
]
}
}

Signing is an ordinary update followed by goToPage. Here the document moves itself to its Signed page, because the step belongs to the document and not to the bank’s workflow:

{
"sign-accept": {
"type": "Button",
"props": {
"label": "Accept and sign",
"variant": "solid",
"size": "md",
"disabled": false,
"fullWidth": true,
"busy": {
"$cond": {
"$state": "/meta/objects/decision/operations/update/phase",
"eq": "loading"
},
"$then": true,
"$else": false
},
"busyLabel": "Signing…"
},
"children": [],
"on": {
"press": [
{
"action": "update",
"params": {
"object": "decision",
"inputs": {
"signature": {
"$state": "/answers/signature"
}
}
}
},
{
"action": "goToPage",
"params": {
"page": "page-signed"
}
}
]
}
}
}

Let the host run the workflow shows the host code behind each of these steps.

Complete document — examples/documents/loan-application.json
examples/documents/loan-application.json
{
"envelopeVersion": 1,
"ui": {
"root": "app",
"elements": {
"hero-headline": {
"type": "Heading",
"props": {
"content": {
"$state": "/objects/application/data/headline"
},
"level": "1",
"align": "left",
"accent": true
},
"children": []
},
"hero-intro": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/application/data/intro"
},
"size": "lg",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"hero-limit-label": {
"type": "Text",
"props": {
"content": "Pre-approved up to",
"size": "sm",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"hero-limit-value": {
"type": "Text",
"props": {
"content": {
"$format": "currency",
"value": {
"$state": "/objects/application/data/limit"
},
"currency": "EUR"
},
"size": "lg",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"hero-limit": {
"type": "Stack",
"props": {
"direction": "vertical",
"gap": "xs",
"align": "stretch",
"justify": "start",
"wrap": false,
"padding": "none",
"surface": null
},
"children": [
"hero-limit-label",
"hero-limit-value"
]
},
"hero-rate-label": {
"type": "Text",
"props": {
"content": "Your rate (APR)",
"size": "sm",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"hero-rate-value": {
"type": "Text",
"props": {
"content": {
"$format": "percent",
"value": {
"$state": "/objects/application/data/apr"
}
},
"size": "lg",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"hero-rate": {
"type": "Stack",
"props": {
"direction": "vertical",
"gap": "xs",
"align": "stretch",
"justify": "start",
"wrap": false,
"padding": "none",
"surface": null
},
"children": [
"hero-rate-label",
"hero-rate-value"
]
},
"hero-figures": {
"type": "Grid",
"props": {
"columns": 2,
"gap": "md",
"padding": "none",
"minCellWidth": 150
},
"children": [
"hero-limit",
"hero-rate"
]
},
"hero": {
"type": "Section",
"props": {
"eyebrow": "KESTREL BUSINESS BANKING",
"title": null,
"tone": "ink",
"padding": "xl"
},
"children": [
"hero-headline",
"hero-intro",
"hero-figures"
]
},
"expect-what": {
"type": "Text",
"props": {
"content": "Tell us how much you would like to borrow, what the money is for, over how many months you want to repay it, and what the business sold last year. It takes about two minutes.",
"size": "md",
"tone": "default",
"align": "left",
"italic": false
},
"children": []
},
"expect-guidance": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/application/data/guidance"
},
"size": "md",
"tone": "muted",
"align": "left",
"italic": false
},
"children": []
},
"expect-next": {
"type": "Text",
"props": {
"content": "When you press Continue we check your answers against what we already know. Most applications get a decision straight away; some need one or two more answers first.",
"size": "md",
"tone": "muted",
"align": "left",
"italic": false
},
"children": []
},
"expect": {
"type": "Section",
"props": {
"eyebrow": null,
"title": "What we need from you",
"tone": "outlined",
"padding": "lg"
},
"children": [
"expect-what",
"expect-guidance",
"expect-next"
]
},
"amount": {
"type": "NumberField",
"props": {
"label": "How much would you like to borrow?",
"format": "currency",
"currency": "EUR",
"min": 5000,
"max": 250000,
"required": true,
"helpText": "Between €5,000 and €250,000.",
"value": {
"$bindState": "/answers/amount"
},
"error": {
"$state": "/meta/objects/application/operations/update/error/fieldErrors/amount"
}
},
"children": []
},
"term": {
"type": "NumberField",
"props": {
"label": "Repayment term (months)",
"min": 6,
"max": 60,
"step": 1,
"required": true,
"helpText": "From 6 to 60 months.",
"value": {
"$bindState": "/answers/termMonths"
},
"error": {
"$state": "/meta/objects/application/operations/update/error/fieldErrors/termMonths"
}
},
"children": []
},
"revenue": {
"type": "NumberField",
"props": {
"label": "What did the business sell last year?",
"format": "currency",
"currency": "EUR",
"min": 1,
"required": true,
"helpText": "All sales before costs, for the last full financial year.",
"value": {
"$bindState": "/answers/annualRevenue"
},
"error": {
"$state": "/meta/objects/application/operations/update/error/fieldErrors/annualRevenue"
}
},
"children": []
},
"continue": {
"type": "Button",
"props": {
"label": "Continue",
"variant": "solid",
"size": "md",
"disabled": false,
"fullWidth": true,
"busy": {
"$cond": {
"$state": "/meta/objects/application/operations/update/phase",
"eq": "loading"
},
"$then": true,
"$else": false
},
"busyLabel": "Sending your answers…"
},
"children": [],
"on": {
"press": {
"action": "update",
"params": {
"object": "application",
"inputs": {
"amount": {
"$state": "/answers/amount"
},
"purpose": {
"$state": "/answers/purpose"
},
"termMonths": {
"$state": "/answers/termMonths"
},
"annualRevenue": {
"$state": "/answers/annualRevenue"
},
"collateralDescription": {
"$state": "/answers/collateralDescription"
},
"collateralValue": {
"$state": "/answers/collateralValue"
},
"existingLender": {
"$state": "/answers/existingLender"
},
"existingBalance": {
"$state": "/answers/existingBalance"
},
"supplierName": {
"$state": "/answers/supplierName"
},
"quoteReference": {
"$state": "/answers/quoteReference"
},
"monthlyOutgoings": {
"$state": "/answers/monthlyOutgoings"
},
"notes": {
"$state": "/answers/notes"
}
}
}
}
}
},
"send-error": {
"type": "Text",
"props": {
"content": {
"$state": "/meta/objects/application/operations/update/error/message"
},
"size": "md",
"tone": "accent",
"align": "left",
"italic": false
},
"children": [],
"visible": {
"$state": "/meta/objects/application/operations/update/phase",
"eq": "error"
}
},
"form-details": {
"type": "Section",
"props": {
"eyebrow": "STEP 1",
"title": "Your loan",
"tone": "raised",
"padding": "lg"
},
"children": [
"amount",
"purpose",
"term",
"revenue",
"continue",
"send-error"
]
},
"follow-headline": {
"type": "Heading",
"props": {
"content": {
"$state": "/objects/application/data/headline"
},
"level": "1",
"align": "left",
"accent": true
},
"children": []
},
"follow-intro": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/application/data/intro"
},
"size": "lg",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"follow-request-label": {
"type": "Text",
"props": {
"content": "Your request",
"size": "sm",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"follow-request-value": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/application/data/requestLabel"
},
"size": "lg",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"follow-request": {
"type": "Stack",
"props": {
"direction": "vertical",
"gap": "xs",
"align": "stretch",
"justify": "start",
"wrap": false,
"padding": "none",
"surface": null
},
"children": [
"follow-request-label",
"follow-request-value"
]
},
"follow-hero": {
"type": "Section",
"props": {
"eyebrow": "KESTREL BUSINESS BANKING",
"title": null,
"tone": "ink",
"padding": "xl"
},
"children": [
"follow-headline",
"follow-intro",
"follow-request"
]
},
"collateral-description": {
"type": "Input",
"props": {
"label": "What would you offer as security?",
"placeholder": "What it is",
"inputType": "text",
"required": true,
"helpText": null,
"maxLength": 120,
"value": {
"$bindState": "/answers/collateralDescription"
},
"error": {
"$state": "/meta/objects/application/operations/update/error/fieldErrors/collateralDescription"
}
},
"children": []
},
"collateral-value": {
"type": "NumberField",
"props": {
"label": "What is it worth today?",
"format": "currency",
"currency": "EUR",
"min": 0,
"required": true,
"helpText": "A recent valuation or purchase price.",
"value": {
"$bindState": "/answers/collateralValue"
},
"error": {
"$state": "/meta/objects/application/operations/update/error/fieldErrors/collateralValue"
}
},
"children": []
},
"ask-collateral-reason": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/application/data/followUp/collateral/reason"
},
"size": "md",
"tone": "muted",
"align": "left",
"italic": false
},
"children": []
},
"ask-collateral": {
"type": "Section",
"props": {
"eyebrow": "SECURITY",
"title": "What can secure the loan?",
"tone": "outlined",
"padding": "lg"
},
"children": [
"ask-collateral-reason",
"collateral-description",
"collateral-value"
],
"visible": {
"$state": "/objects/application/data/followUp/collateral/asked"
}
},
"existing-lender": {
"type": "Input",
"props": {
"label": "Who is the loan with?",
"placeholder": "Lender name",
"inputType": "text",
"required": true,
"helpText": null,
"maxLength": 80,
"value": {
"$bindState": "/answers/existingLender"
},
"error": {
"$state": "/meta/objects/application/operations/update/error/fieldErrors/existingLender"
}
},
"children": []
},
"existing-balance": {
"type": "NumberField",
"props": {
"label": "How much is left to repay?",
"format": "currency",
"currency": "EUR",
"min": 0,
"required": true,
"helpText": null,
"value": {
"$bindState": "/answers/existingBalance"
},
"error": {
"$state": "/meta/objects/application/operations/update/error/fieldErrors/existingBalance"
}
},
"children": []
},
"ask-refinance-reason": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/application/data/followUp/refinance/reason"
},
"size": "md",
"tone": "muted",
"align": "left",
"italic": false
},
"children": []
},
"ask-refinance": {
"type": "Section",
"props": {
"eyebrow": "REFINANCING",
"title": "The loan you want to replace",
"tone": "outlined",
"padding": "lg"
},
"children": [
"ask-refinance-reason",
"existing-lender",
"existing-balance"
],
"visible": {
"$state": "/objects/application/data/followUp/refinance/asked"
}
},
"supplier-name": {
"type": "Input",
"props": {
"label": "Supplier",
"placeholder": "Who is selling it?",
"inputType": "text",
"required": true,
"helpText": null,
"maxLength": 80,
"value": {
"$bindState": "/answers/supplierName"
},
"error": {
"$state": "/meta/objects/application/operations/update/error/fieldErrors/supplierName"
}
},
"children": []
},
"quote-reference": {
"type": "Input",
"props": {
"label": "Quote reference",
"placeholder": "As printed on the quote",
"inputType": "text",
"required": true,
"helpText": null,
"maxLength": 40,
"value": {
"$bindState": "/answers/quoteReference"
},
"error": {
"$state": "/meta/objects/application/operations/update/error/fieldErrors/quoteReference"
}
},
"children": []
},
"ask-quote-reason": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/application/data/followUp/quote/reason"
},
"size": "md",
"tone": "muted",
"align": "left",
"italic": false
},
"children": []
},
"ask-quote": {
"type": "Section",
"props": {
"eyebrow": "EQUIPMENT",
"title": "The supplier's quote",
"tone": "outlined",
"padding": "lg"
},
"children": [
"ask-quote-reason",
"supplier-name",
"quote-reference"
],
"visible": {
"$state": "/objects/application/data/followUp/quote/asked"
}
},
"monthly-outgoings": {
"type": "NumberField",
"props": {
"label": "What does the business spend in a typical month?",
"format": "currency",
"currency": "EUR",
"min": 0,
"required": true,
"helpText": "Rent, wages, suppliers and other loan repayments.",
"value": {
"$bindState": "/answers/monthlyOutgoings"
},
"error": {
"$state": "/meta/objects/application/operations/update/error/fieldErrors/monthlyOutgoings"
}
},
"children": []
},
"ask-affordability-reason": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/application/data/followUp/affordability/reason"
},
"size": "md",
"tone": "muted",
"align": "left",
"italic": false
},
"children": []
},
"ask-affordability": {
"type": "Section",
"props": {
"eyebrow": "AFFORDABILITY",
"title": "Your monthly costs",
"tone": "outlined",
"padding": "lg"
},
"children": [
"ask-affordability-reason",
"monthly-outgoings"
],
"visible": {
"$state": "/objects/application/data/followUp/affordability/asked"
}
},
"notes": {
"type": "Input",
"props": {
"label": "Anything our lending team should know",
"placeholder": "Optional",
"inputType": "text",
"lines": 4,
"required": false,
"helpText": "Up to 500 characters.",
"maxLength": 500,
"value": {
"$bindState": "/answers/notes"
},
"error": {
"$state": "/meta/objects/application/operations/update/error/fieldErrors/notes"
}
},
"children": []
},
"follow-continue": {
"type": "Button",
"props": {
"label": "Continue",
"variant": "solid",
"size": "md",
"disabled": false,
"fullWidth": true,
"busy": {
"$cond": {
"$state": "/meta/objects/application/operations/update/phase",
"eq": "loading"
},
"$then": true,
"$else": false
},
"busyLabel": "Sending your answers…"
},
"children": [],
"on": {
"press": {
"action": "update",
"params": {
"object": "application",
"inputs": {
"amount": {
"$state": "/answers/amount"
},
"purpose": {
"$state": "/answers/purpose"
},
"termMonths": {
"$state": "/answers/termMonths"
},
"annualRevenue": {
"$state": "/answers/annualRevenue"
},
"collateralDescription": {
"$state": "/answers/collateralDescription"
},
"collateralValue": {
"$state": "/answers/collateralValue"
},
"existingLender": {
"$state": "/answers/existingLender"
},
"existingBalance": {
"$state": "/answers/existingBalance"
},
"supplierName": {
"$state": "/answers/supplierName"
},
"quoteReference": {
"$state": "/answers/quoteReference"
},
"monthlyOutgoings": {
"$state": "/answers/monthlyOutgoings"
},
"notes": {
"$state": "/answers/notes"
}
}
}
}
}
},
"follow-send-error": {
"type": "Text",
"props": {
"content": {
"$state": "/meta/objects/application/operations/update/error/message"
},
"size": "md",
"tone": "accent",
"align": "left",
"italic": false
},
"children": [],
"visible": {
"$state": "/meta/objects/application/operations/update/phase",
"eq": "error"
}
},
"follow-send": {
"type": "Section",
"props": {
"eyebrow": "STEP 2",
"title": "Anything else?",
"tone": "raised",
"padding": "lg"
},
"children": [
"notes",
"follow-continue",
"follow-send-error"
]
},
"page-details": {
"type": "Page",
"props": {
"title": "Your loan",
"background": "mist"
},
"children": [
"hero",
"expect",
"form-details"
]
},
"page-follow-up": {
"type": "Page",
"props": {
"title": "A few more questions",
"background": "mist"
},
"children": [
"follow-hero",
"ask-collateral",
"ask-refinance",
"ask-quote",
"ask-affordability",
"follow-send"
]
},
"app": {
"type": "PageStack",
"props": {
"name": "Business loan application"
},
"children": [
"page-details",
"page-follow-up"
]
},
"purpose": {
"type": "Choice",
"props": {
"label": "What is the loan for?",
"display": "segmented",
"options": [
{
"value": "equipment",
"label": "Equipment"
},
{
"value": "stock",
"label": "Stock"
},
{
"value": "refinance",
"label": "Refinance a loan"
},
{
"value": "premises",
"label": "New premises"
}
],
"required": true,
"helpText": null,
"value": {
"$bindState": "/answers/purpose"
},
"error": {
"$state": "/meta/objects/application/operations/update/error/fieldErrors/purpose"
}
},
"children": []
}
},
"state": {
"answers": {
"amount": null,
"purpose": null,
"termMonths": null,
"annualRevenue": null,
"collateralDescription": "",
"collateralValue": null,
"existingLender": "",
"existingBalance": null,
"supplierName": "",
"quoteReference": "",
"monthlyOutgoings": null,
"notes": ""
}
}
},
"meta": {
"pack": {
"id": "mica.core",
"version": "1.0.0"
}
},
"objects": {
"application": {
"type": "lending.loan_application",
"cardinality": "one",
"identity": "id",
"fields": {
"id": {
"kind": "string",
"required": true
},
"stage": {
"kind": "string",
"required": true,
"enum": [
"details",
"follow-up",
"decided"
]
},
"headline": {
"kind": "string",
"required": true
},
"intro": {
"kind": "string",
"required": true
},
"guidance": {
"kind": "string",
"required": true
},
"limit": {
"kind": "number",
"required": true
},
"apr": {
"kind": "number",
"required": true
},
"requestLabel": {
"kind": "string",
"nullable": true
},
"decisionId": {
"kind": "string",
"nullable": true
},
"followUp": {
"kind": "object",
"required": true,
"fields": {
"collateral": {
"kind": "object",
"required": true,
"fields": {
"asked": {
"kind": "boolean",
"required": true
},
"reason": {
"kind": "string",
"required": true
}
}
},
"refinance": {
"kind": "object",
"required": true,
"fields": {
"asked": {
"kind": "boolean",
"required": true
},
"reason": {
"kind": "string",
"required": true
}
}
},
"quote": {
"kind": "object",
"required": true,
"fields": {
"asked": {
"kind": "boolean",
"required": true
},
"reason": {
"kind": "string",
"required": true
}
}
},
"affordability": {
"kind": "object",
"required": true,
"fields": {
"asked": {
"kind": "boolean",
"required": true
},
"reason": {
"kind": "string",
"required": true
}
}
}
}
}
},
"capabilities": {
"update": {
"inputs": {
"amount": {
"kind": "number",
"required": true,
"minimum": 5000,
"maximum": 250000
},
"purpose": {
"kind": "string",
"required": true,
"enum": [
"equipment",
"stock",
"refinance",
"premises"
]
},
"termMonths": {
"kind": "integer",
"required": true,
"minimum": 6,
"maximum": 60
},
"annualRevenue": {
"kind": "number",
"required": true,
"minimum": 1
},
"collateralDescription": {
"kind": "string",
"requiredWhen": {
"$state": "/objects/application/data/followUp/collateral/asked"
},
"maxLength": 120
},
"collateralValue": {
"kind": "number",
"requiredWhen": {
"$state": "/objects/application/data/followUp/collateral/asked"
},
"minimum": 0
},
"existingLender": {
"kind": "string",
"requiredWhen": {
"$state": "/objects/application/data/followUp/refinance/asked"
},
"maxLength": 80
},
"existingBalance": {
"kind": "number",
"requiredWhen": {
"$state": "/objects/application/data/followUp/refinance/asked"
},
"minimum": 0
},
"supplierName": {
"kind": "string",
"requiredWhen": {
"$state": "/objects/application/data/followUp/quote/asked"
},
"maxLength": 80
},
"quoteReference": {
"kind": "string",
"requiredWhen": {
"$state": "/objects/application/data/followUp/quote/asked"
},
"maxLength": 40
},
"monthlyOutgoings": {
"kind": "number",
"requiredWhen": {
"$state": "/objects/application/data/followUp/affordability/asked"
},
"minimum": 0
},
"notes": {
"kind": "string",
"maxLength": 500
}
}
}
},
"sample": {
"id": "LA-0000",
"stage": "details",
"headline": "Your business loan is pre-approved",
"intro": "A personalised introduction from the host.",
"guidance": "What the host already knows about this customer.",
"limit": 25000,
"apr": 0.095,
"requestLabel": null,
"decisionId": null,
"followUp": {
"collateral": {
"asked": false,
"reason": ""
},
"refinance": {
"asked": false,
"reason": ""
},
"quote": {
"asked": false,
"reason": ""
},
"affordability": {
"asked": false,
"reason": ""
}
}
}
}
}
}
Complete document — examples/documents/loan-decision.json
examples/documents/loan-decision.json
{
"envelopeVersion": 1,
"ui": {
"root": "app",
"elements": {
"loading": {
"type": "Text",
"props": {
"content": "Loading your decision…",
"size": "md",
"tone": "muted",
"align": "left",
"italic": false
},
"children": [],
"visible": {
"$state": "/meta/objects/decision/operations/fetch/phase",
"eq": "loading"
}
},
"load-error-message": {
"type": "Text",
"props": {
"content": {
"$state": "/meta/objects/decision/operations/fetch/error/message"
},
"size": "md",
"tone": "accent",
"align": "left",
"italic": false
},
"children": []
},
"load-retry": {
"type": "Button",
"props": {
"label": "Try again",
"variant": "outline",
"size": "md",
"disabled": false,
"fullWidth": false
},
"children": [],
"on": {
"press": {
"action": "fetch",
"params": {
"object": "decision",
"inputs": {
"decisionId": {
"$state": "/decisionId"
}
}
}
}
}
},
"load-error": {
"type": "Section",
"props": {
"eyebrow": null,
"title": "We couldn't load your decision",
"tone": "outlined",
"padding": "lg"
},
"children": [
"load-error-message",
"load-retry"
],
"visible": {
"$state": "/meta/objects/decision/operations/fetch/phase",
"eq": "error"
}
},
"offer-headline": {
"type": "Heading",
"props": {
"content": {
"$state": "/objects/decision/data/headline"
},
"level": "1",
"align": "left",
"accent": true
},
"children": []
},
"offer-summary": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/decision/data/summary"
},
"size": "lg",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"offer-amount-label": {
"type": "Text",
"props": {
"content": "Loan",
"size": "sm",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"offer-amount-value": {
"type": "Text",
"props": {
"content": {
"$format": "currency",
"value": {
"$state": "/objects/decision/data/amount"
},
"currency": "EUR"
},
"size": "lg",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"offer-amount": {
"type": "Stack",
"props": {
"direction": "vertical",
"gap": "xs",
"align": "stretch",
"justify": "start",
"wrap": false,
"padding": "none",
"surface": null
},
"children": [
"offer-amount-label",
"offer-amount-value"
]
},
"offer-term-label": {
"type": "Text",
"props": {
"content": "Term",
"size": "sm",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"offer-term-value": {
"type": "Text",
"props": {
"content": {
"$format": "count",
"value": {
"$state": "/objects/decision/data/termMonths"
},
"one": "month",
"other": "months"
},
"size": "lg",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"offer-term": {
"type": "Stack",
"props": {
"direction": "vertical",
"gap": "xs",
"align": "stretch",
"justify": "start",
"wrap": false,
"padding": "none",
"surface": null
},
"children": [
"offer-term-label",
"offer-term-value"
]
},
"offer-rate-label": {
"type": "Text",
"props": {
"content": "Rate (APR)",
"size": "sm",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"offer-rate-value": {
"type": "Text",
"props": {
"content": {
"$format": "percent",
"value": {
"$state": "/objects/decision/data/apr"
}
},
"size": "lg",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"offer-rate": {
"type": "Stack",
"props": {
"direction": "vertical",
"gap": "xs",
"align": "stretch",
"justify": "start",
"wrap": false,
"padding": "none",
"surface": null
},
"children": [
"offer-rate-label",
"offer-rate-value"
]
},
"offer-monthly-label": {
"type": "Text",
"props": {
"content": "Monthly repayment",
"size": "sm",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"offer-monthly-value": {
"type": "Text",
"props": {
"content": {
"$format": "currency",
"value": {
"$state": "/objects/decision/data/monthly"
},
"currency": "EUR"
},
"size": "lg",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"offer-monthly": {
"type": "Stack",
"props": {
"direction": "vertical",
"gap": "xs",
"align": "stretch",
"justify": "start",
"wrap": false,
"padding": "none",
"surface": null
},
"children": [
"offer-monthly-label",
"offer-monthly-value"
]
},
"offer-terms": {
"type": "Grid",
"props": {
"columns": 2,
"gap": "md",
"padding": "none",
"minCellWidth": 150
},
"children": [
"offer-amount",
"offer-term",
"offer-rate",
"offer-monthly"
]
},
"offer-total": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/decision/data/totalLabel"
},
"size": "md",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"offer": {
"type": "Section",
"props": {
"eyebrow": "YOUR OFFER",
"title": null,
"tone": "ink",
"padding": "xl"
},
"children": [
"offer-headline",
"offer-summary",
"offer-terms",
"offer-total"
],
"visible": [
{
"$state": "/meta/objects/decision/operations/fetch/phase",
"eq": "success"
},
{
"$state": "/objects/decision/data/outcome",
"eq": "offer"
}
]
},
"offer-conditions-text": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/decision/data/conditions"
},
"size": "md",
"tone": "default",
"align": "left",
"italic": false
},
"children": []
},
"offer-valid": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/decision/data/validUntilLabel"
},
"size": "md",
"tone": "muted",
"align": "left",
"italic": false
},
"children": []
},
"offer-conditions": {
"type": "Section",
"props": {
"eyebrow": null,
"title": "Conditions",
"tone": "outlined",
"padding": "lg"
},
"children": [
"offer-conditions-text",
"offer-valid"
],
"visible": [
{
"$state": "/meta/objects/decision/operations/fetch/phase",
"eq": "success"
},
{
"$state": "/objects/decision/data/outcome",
"eq": "offer"
}
]
},
"sign-how": {
"type": "Text",
"props": {
"content": "Type your full name as it appears on your account. You can cancel within 14 days at no cost.",
"size": "md",
"tone": "default",
"align": "left",
"italic": false
},
"children": []
},
"signature": {
"type": "Input",
"props": {
"label": "Your full name",
"placeholder": "First and last name",
"inputType": "text",
"required": true,
"helpText": null,
"maxLength": 80,
"value": {
"$bindState": "/answers/signature"
},
"error": {
"$state": "/meta/objects/decision/operations/update/error/fieldErrors/signature"
}
},
"children": []
},
"sign-accept": {
"type": "Button",
"props": {
"label": "Accept and sign",
"variant": "solid",
"size": "md",
"disabled": false,
"fullWidth": true,
"busy": {
"$cond": {
"$state": "/meta/objects/decision/operations/update/phase",
"eq": "loading"
},
"$then": true,
"$else": false
},
"busyLabel": "Signing…"
},
"children": [],
"on": {
"press": [
{
"action": "update",
"params": {
"object": "decision",
"inputs": {
"signature": {
"$state": "/answers/signature"
}
}
}
},
{
"action": "goToPage",
"params": {
"page": "page-signed"
}
}
]
}
},
"sign-error": {
"type": "Text",
"props": {
"content": {
"$state": "/meta/objects/decision/operations/update/error/message"
},
"size": "md",
"tone": "accent",
"align": "left",
"italic": false
},
"children": [],
"visible": {
"$state": "/meta/objects/decision/operations/update/phase",
"eq": "error"
}
},
"sign": {
"type": "Section",
"props": {
"eyebrow": "ACCEPT",
"title": "Sign to accept the offer",
"tone": "raised",
"padding": "lg"
},
"children": [
"sign-how",
"signature",
"sign-accept",
"sign-error"
],
"visible": [
{
"$state": "/meta/objects/decision/operations/fetch/phase",
"eq": "success"
},
{
"$state": "/objects/decision/data/outcome",
"eq": "offer"
},
{
"$state": "/objects/decision/data/status",
"eq": "open"
}
]
},
"already-signed-text": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/decision/data/signedLabel"
},
"size": "md",
"tone": "muted",
"align": "left",
"italic": false
},
"children": []
},
"already-signed-open": {
"type": "Button",
"props": {
"label": "See the confirmation",
"variant": "ghost",
"size": "md",
"disabled": false,
"fullWidth": false
},
"children": [],
"on": {
"press": {
"action": "goToPage",
"params": {
"page": "page-signed"
}
}
}
},
"already-signed": {
"type": "Section",
"props": {
"eyebrow": null,
"title": "You have signed this offer",
"tone": "outlined",
"padding": "lg"
},
"children": [
"already-signed-text",
"already-signed-open"
],
"visible": [
{
"$state": "/meta/objects/decision/operations/fetch/phase",
"eq": "success"
},
{
"$state": "/objects/decision/data/status",
"eq": "accepted"
}
]
},
"referred-headline": {
"type": "Heading",
"props": {
"content": {
"$state": "/objects/decision/data/headline"
},
"level": "1",
"align": "left",
"accent": true
},
"children": []
},
"referred-summary": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/decision/data/summary"
},
"size": "lg",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"referred-reference-label": {
"type": "Text",
"props": {
"content": "Reference",
"size": "sm",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"referred-reference-value": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/decision/data/reference"
},
"size": "lg",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"referred-reference": {
"type": "Stack",
"props": {
"direction": "vertical",
"gap": "xs",
"align": "stretch",
"justify": "start",
"wrap": false,
"padding": "none",
"surface": null
},
"children": [
"referred-reference-label",
"referred-reference-value"
]
},
"referred-contact-label": {
"type": "Text",
"props": {
"content": "What happens next",
"size": "sm",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"referred-contact-value": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/decision/data/contactLabel"
},
"size": "lg",
"tone": "inverse",
"align": "left",
"italic": false
},
"children": []
},
"referred-contact": {
"type": "Stack",
"props": {
"direction": "vertical",
"gap": "xs",
"align": "stretch",
"justify": "start",
"wrap": false,
"padding": "none",
"surface": null
},
"children": [
"referred-contact-label",
"referred-contact-value"
]
},
"referred-facts": {
"type": "Grid",
"props": {
"columns": 2,
"gap": "md",
"padding": "none",
"minCellWidth": 150
},
"children": [
"referred-reference",
"referred-contact"
]
},
"referred": {
"type": "Section",
"props": {
"eyebrow": "WITH AN UNDERWRITER",
"title": null,
"tone": "ink",
"padding": "xl"
},
"children": [
"referred-headline",
"referred-summary",
"referred-facts"
],
"visible": [
{
"$state": "/meta/objects/decision/operations/fetch/phase",
"eq": "success"
},
{
"$state": "/objects/decision/data/outcome",
"eq": "referred"
}
]
},
"page-decision": {
"type": "Page",
"props": {
"title": "Decision",
"background": "paper"
},
"children": [
"loading",
"load-error",
"offer",
"offer-conditions",
"sign",
"already-signed",
"referred"
]
},
"signed-heading": {
"type": "Heading",
"props": {
"content": "Signed. Thank you.",
"level": "1",
"align": "left",
"accent": true
},
"children": []
},
"signed-funding": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/decision/data/fundingLabel"
},
"size": "lg",
"tone": "default",
"align": "left",
"italic": false
},
"children": []
},
"signed-by": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/decision/data/signedLabel"
},
"size": "md",
"tone": "muted",
"align": "left",
"italic": false
},
"children": []
},
"signed-reference": {
"type": "Value",
"props": {
"label": "Reference",
"value": {
"$state": "/objects/decision/data/reference"
}
},
"children": []
},
"signed-back": {
"type": "Button",
"props": {
"label": "Back to the offer",
"variant": "outline",
"size": "md",
"disabled": false,
"fullWidth": false
},
"children": [],
"on": {
"press": {
"action": "goToPage",
"params": {
"page": "page-decision"
}
}
}
},
"page-signed": {
"type": "Page",
"props": {
"title": "Signed",
"background": "mist"
},
"children": [
"signed-heading",
"signed-funding",
"signed-by",
"signed-reference",
"signed-back"
]
},
"app": {
"type": "PageStack",
"props": {
"name": "Business loan decision"
},
"children": [
"page-decision",
"page-signed"
]
}
},
"state": {
"decisionId": "DEC-0000",
"answers": {
"signature": ""
}
}
},
"meta": {
"pack": {
"id": "mica.core",
"version": "1.0.0"
}
},
"objects": {
"decision": {
"type": "lending.credit_decision",
"cardinality": "one",
"identity": "id",
"fields": {
"id": {
"kind": "string",
"required": true
},
"outcome": {
"kind": "string",
"required": true,
"enum": [
"offer",
"referred"
]
},
"status": {
"kind": "string",
"required": true,
"enum": [
"open",
"accepted"
]
},
"reference": {
"kind": "string",
"required": true
},
"headline": {
"kind": "string",
"required": true
},
"summary": {
"kind": "string",
"required": true
},
"amount": {
"kind": "number",
"nullable": true
},
"termMonths": {
"kind": "number",
"nullable": true
},
"apr": {
"kind": "number",
"nullable": true
},
"monthly": {
"kind": "number",
"nullable": true
},
"totalLabel": {
"kind": "string",
"nullable": true
},
"conditions": {
"kind": "string",
"nullable": true
},
"validUntilLabel": {
"kind": "string",
"nullable": true
},
"contactLabel": {
"kind": "string",
"nullable": true
},
"fundingLabel": {
"kind": "string",
"nullable": true
},
"signedLabel": {
"kind": "string",
"nullable": true
}
},
"capabilities": {
"fetch": {
"inputs": {
"decisionId": {
"kind": "string",
"required": true
}
}
},
"update": {
"inputs": {
"signature": {
"kind": "string",
"required": true,
"minLength": 2,
"maxLength": 80
}
}
}
},
"sample": {
"id": "DEC-0000",
"outcome": "offer",
"status": "open",
"reference": "KB-0000",
"headline": "Your loan is approved",
"summary": "A summary of the decision, written by the host.",
"amount": 25000,
"termMonths": 36,
"apr": 0.095,
"monthly": 800,
"totalLabel": "€28,800 to repay in total.",
"conditions": "Conditions set by the host.",
"validUntilLabel": "Valid until a date the host sets.",
"contactLabel": null,
"fundingLabel": null,
"signedLabel": null
}
}
},
"lifecycle": {
"startup": [
{
"action": "fetch",
"params": {
"object": "decision",
"inputs": {
"decisionId": {
"$state": "/decisionId"
}
}
}
}
]
}
}