Two end-to-end flowcharts — each box shows the question prompt and field id, each arrow shows the selection label. Source-of-truth: lib/enquiry-flow.ts.
flowchart TD
LANDING(["Landing /<br/>Hero + 2 pills"]) -->|"Click: 'Buy a property'"| NAV["Navigate to<br/>/check?intent=purchase"]
NAV --> Q1["<b>Q1 · targetValue</b><br/>What's the target purchase price?<br/>—————<br/>Input: slider<br/>Range: £50,000 – £2,000,000<br/>Default: £250,000"]
Q1 --> Q2["<b>Q2 · deposit</b><br/>How much deposit are you putting in?<br/>—————<br/>Input: slider<br/>Range: 15–50% of target<br/>Default: 25% (= 75% LTV)"]
Q2 --> Q3{"<b>Q3 · foundProperty</b><br/>Have you found a property?<br/>—————<br/>• Yes — I have one in mind<br/>• Not yet — still looking"}
Q3 -->|"Yes"| Q4_ADDR["<b>Q4 · address</b><br/>What's the address?<br/>—————<br/>Input: typeahead<br/>Resolves: postcode + UPRN<br/>Auto-derives isScotland"]
Q3 -->|"Not yet"| Q_SCOT_FALLBACK
Q4_ADDR --> Q5_RENT["<b>Q5 · targetRent</b><br/>Target monthly rental income?<br/>—————<br/>Input: number · £/mo"]
Q5_RENT --> SCOT_CHECK{"isScotland<br/>auto-derived?<br/>—————<br/>• Yes (postcode known)<br/>• No (raw fallback)"}
SCOT_CHECK -->|"Yes"| Q_PROP
SCOT_CHECK -->|"No"| Q_SCOT_EXP
Q_SCOT_FALLBACK{"<b>Q · isScotland</b><br/>Will the property be in Scotland?<br/>—————<br/>• Yes — Scotland<br/>• No — England, Wales or NI"}
Q_SCOT_FALLBACK -->|"Yes"| Q_PROP
Q_SCOT_FALLBACK -->|"No"| Q_PROP
Q_SCOT_EXP{"<b>Q · isScotland</b><br/>Will the property be in Scotland?<br/>—————<br/>• Yes — Scotland<br/>• No — England, Wales or NI"}
Q_SCOT_EXP -->|"Yes"| Q_PROP
Q_SCOT_EXP -->|"No"| Q_PROP
Q_PROP{"<b>Q · propertyType</b><br/>What property are you financing?<br/>—————<br/>• Standard buy-to-let<br/>• HMO (3+ unrelated tenants)<br/>• Multi-unit block (MUFB)<br/>• Commercial — DISABLED<br/>• Short-term let — DISABLED"}
Q_PROP -->|"Standard BTL"| Q_TENURE
Q_PROP -->|"HMO"| Q_HMO_LIC
Q_PROP -->|"MUFB"| Q_MUFB
Q_PROP -->|"Commercial"| BLOCKED1[("Coming soon")]
Q_PROP -->|"STL"| BLOCKED2[("Coming soon")]
Q_HMO_LIC{"<b>Q · hmoLicence</b><br/>Existing HMO licence in place?<br/>—————<br/>• Yes — licence in place<br/>• No — not yet"}
Q_HMO_LIC -->|"Yes"| Q_HMO_ROOMS
Q_HMO_LIC -->|"No"| Q_HMO_ROOMS
Q_HMO_ROOMS["<b>Q · hmoRooms</b><br/>Beds / baths / communal<br/>—————<br/>3 atomic number fields<br/>writes hmoBedrooms,<br/>hmoBathrooms, hmoCommunal"]
Q_HMO_ROOMS --> Q_TENURE
Q_MUFB["<b>Q · mufbUnits</b><br/>How many self-contained units?<br/>—————<br/>Input: number"] --> Q_TENURE
Q_TENURE{"<b>Q · tenure</b><br/>Freehold or leasehold?<br/>—————<br/>• Freehold<br/>• Leasehold"}
Q_TENURE -->|"Freehold"| Q_EX_LA
Q_TENURE -->|"Leasehold"| Q_STOREYS
Q_STOREYS["<b>Q · storeysInBlock</b><br/>Storeys in the block?<br/>—————<br/>Input: number"] --> Q_LEASE
Q_LEASE["<b>Q · leaseYearsLeft</b><br/>Years left on the lease?<br/>—————<br/>Input: number"] --> Q_STUDIO
Q_STUDIO{"<b>Q · isStudio</b><br/>Is the property a studio flat?<br/>—————<br/>• Yes<br/>• No"}
Q_STUDIO -->|"Yes"| Q_SQM
Q_STUDIO -->|"No"| Q_EX_LA
Q_SQM["<b>Q · sqMetres</b><br/>Square metres?<br/>—————<br/>Input: number · sq m"] --> Q_EX_LA
Q_EX_LA{"<b>Q · exLocalAuthority</b><br/>Is it ex local authority?<br/>—————<br/>• Yes — skips newBuild<br/>• No"}
Q_EX_LA -->|"Yes"| Q_ABOVE
Q_EX_LA -->|"No"| Q_NEWBUILD
Q_NEWBUILD{"<b>Q · newBuild</b><br/>Is it a new build?<br/>—————<br/>• Yes<br/>• No"}
Q_NEWBUILD --> Q_ABOVE
Q_ABOVE{"<b>Q · aboveCommercial</b><br/>Above commercial premises?<br/>—————<br/>• No — residential / standalone<br/>• Yes — pub<br/>• Yes — office<br/>• Yes — food outlet"}
Q_ABOVE --> Q_OWN
Q_OWN{"<b>Q · ownership</b><br/>Borrowing as individual or SPV?<br/>—————<br/>• In my own name<br/>• Through a limited company (SPV)"}
Q_OWN --> Q_EXP
Q_EXP{"<b>Q · experienced</b><br/>Experienced landlord?<br/>—————<br/>• Yes — experienced<br/>• No — first-time landlord"}
Q_EXP -->|"Yes"| Q_MORT
Q_EXP -->|"No"| Q_AGE
Q_MORT{"<b>Q · mortgagedBtls</b><br/>Mortgaged BTLs you own?<br/>—————<br/>• Under 4<br/>• 4 or more (portfolio landlord)"}
Q_MORT --> Q_AGE
Q_AGE["<b>Q · age</b><br/>How old are you?<br/>—————<br/>Input: number"] --> Q_INCOME
Q_INCOME["<b>Q · taxableIncome</b><br/>Your taxable income?<br/>—————<br/>Input: number · £/yr"] --> Q_NAT
Q_NAT{"<b>Q · nationality</b><br/>What's your nationality?<br/>—————<br/>• British<br/>• EEA national<br/>• Non-EEA"}
Q_NAT -->|"British"| END
Q_NAT -->|"EEA"| END
Q_NAT -->|"Non-EEA"| Q_RTR
Q_RTR{"<b>Q · rightToReside</b><br/>Permanent right to reside in UK?<br/>—————<br/>• Yes<br/>• No"}
Q_RTR --> END
END(["<b>Results page</b><br/>Donut · bars · recap · lenders<br/>+ View report toggle<br/>+ Lead capture form"])
END --> SUBMIT[("POST api/leads<br/>logs formatted report")]
%% Styling
classDef question fill:#FFFFFF,stroke:#16242B,color:#16242B
classDef decision fill:#FFF1E8,stroke:#F2643C,color:#16242B
classDef gate fill:#FEF3C7,stroke:#D97706,color:#16242B,stroke-width:2px
classDef terminal fill:#16242B,stroke:#F2643C,color:#F4EAD8
classDef blocked fill:#F5EAE5,stroke:#E8D4CB,color:#8E3B22,stroke-dasharray:4 4
%% Non-gate nodes (routing only / informational)
class Q3,Q4_ADDR,SCOT_CHECK,NAV question
%% Policy gates — these answers narrow the lender pool
class Q1,Q2,Q5_RENT,Q_HMO_ROOMS,Q_MUFB,Q_STOREYS,Q_LEASE,Q_SQM,Q_AGE,Q_INCOME gate
class Q_SCOT_FALLBACK,Q_SCOT_EXP,Q_PROP,Q_HMO_LIC,Q_TENURE,Q_STUDIO,Q_EX_LA,Q_NEWBUILD,Q_ABOVE,Q_OWN,Q_EXP,Q_MORT,Q_NAT,Q_RTR gate
class LANDING,END,SUBMIT terminal
class BLOCKED1,BLOCKED2 blockedftb = 'no' set on intent select (the FTB question was removed in favour of the assumption notice on foundProperty)