📋 Data Structure

Data Schema

Two core entities: Clients (people) and Deals (mortgage projects)

Entity Relationship

👤 Client Person record
has many
belongs to
🏠 Deal Mortgage project

Client Record Contains:

  • • Personal details (name, DOB, contact)
  • • Address history
  • • Employment information
  • • Residency & tax status
  • • Income details
  • • Assets (properties, investments, KiwiSaver)
  • • Liabilities & expenses

Deal Record Contains:

  • • Project type (purchase, refinance, etc.)
  • • Banks approached
  • • Bank chosen
  • • Loan structure & terms
  • • Application status
  • • Key dates & milestones
  • • Documents & notes
👤

Client Schema

~80 fields

1 Cover Page 3 fields

Field Type Notes
Client NameText-
Is Joint ApplicationYes/NoIf yes, duplicate personal sections
Application DateDate-

2 Personal Details per client ~35 fields

Basic Information 6 fields

Title
Selection
Legal Name(s)
Text
Last Name
Text
Preferred Name
Text
Date of Birth
Date
Gender
Selection

Current Address 8 fields

Street Address
Text
Suburb
Text
Town/City
Text
Country
Text
Postcode
Text
Living Situation
Selection
Years at Address
Number
Months at Address
Number

Previous Address conditional: if <3 years

Street Address
Suburb
Town/City
Country
Postcode
Years
Months

Contact Information 6 fields

Home Phone
Work Phone
Personal Mobile
Work Mobile
Personal Email
Work Email

Relationship & Dependants repeatable

Relationship Status
Selection
Dependant Name
Text (×n)
Dependant Gender
Selection (×n)
Dependant DOB
Date (×n)

3 Employment per client ~16 fields

Employment Status & Type

Employment Status
Employee / Self-Employed / Not Employed / Contractor
Employment Type
Full-time / Part-time / Casual / Seasonal

Employer Benefits

KiwiSaver ✓/✗
Life Insurance ✓/✗
Income Protection ✓/✗
Shares ✓/✗

Current & Previous Employer

Employer Name
Occupation/Role
Industry
Years
Months

+ Previous employer fields if <3 years at current

4 Residency & Tax per client 4 fields

Tax Resident NZ
Yes/No
Country of Residence
Text
Country of Citizenship
Text
IRD Number
Formatted

5 Income per client 13 fields

Employment Income

Salary/Wages (Gross Annual) $
Commission $
Bonus $
Self-Employed Income $

Other Income

Rental Property (Annual) $
Boarder/Flatmate $
Benefits/ACC $
Investment/Super/WFF/Other $

6 Assets shared repeatable

🏠 Properties up to 10, 8 fields each

Property Type
Owner Occ / Rental / etc
Property Address
Owner
Personal / Trust / etc
Valuation Type
S&P / CV / RV / etc
Valuation Date
Property Value $
Weekly Rental $
Currency

📈 Investments up to 6, 5 fields each

Product Type
Cash / Shares / etc
Institution
Monthly Contribution
Current Value
Currency

🥝 KiwiSaver per client, 5 fields

Provider
Contribution Rate
PIR Rate
Current Balance
First Home Buyer?
🏠

Deal Schema

Mortgage Project

Deal Record

1 Project Details

Project Type

First Home Purchase
Next Home Purchase
Investment Property
Refinance
Top-up
Construction

Key Amounts

Purchase Price$
Deposit$
Loan Amount$
LVR%

Property

Property Address
Property Type
Intended Use
Settlement Date

2 Bank Selection

Banks Approached

ANZ ASB BNZ Westpac Kiwibank SBS TSB Co-op + Others

Bank Chosen

BankSelection
Rate Offered%
Cash Contribution$
ConditionsText

3 Loan Structure repeatable tranches

Tranche Amount
Rate Type
Fixed/Floating
Fixed Term
1-5 years
Interest Rate
Repayment Type
P&I / IO
Loan Term

4 Status & Key Dates

Application Status

New In Progress Submitted Conditionally Approved Unconditional Settled Declined

Key Dates

Application Date
Submission Date
Approval Date
Settlement Date
Finance Date
Expiry Date

🗄️ Database Structure

-- Core tables
CREATE TABLE clients (
    id SERIAL PRIMARY KEY,
    created_at TIMESTAMP,
    updated_at TIMESTAMP,
    -- Personal details (encrypted)
    legal_name_encrypted BYTEA,
    email_encrypted BYTEA,
    phone_encrypted BYTEA,
    -- ... other fields
);

CREATE TABLE deals (
    id SERIAL PRIMARY KEY,
    client_id INTEGER REFERENCES clients(id),
    project_type TEXT,
    status TEXT,
    bank_chosen TEXT,
    loan_amount DECIMAL,
    -- ... other fields
);

CREATE TABLE pending_changes (
    id SERIAL PRIMARY KEY,
    entity_type TEXT,  -- 'client' or 'deal'
    entity_id INTEGER,
    field_name TEXT,
    proposed_value JSONB,
    source_type TEXT,   -- 'form', 'webhook', 'document', 'portal'
    status TEXT,       -- 'pending', 'approved', 'rejected'
    reviewed_by INTEGER,
    reviewed_at TIMESTAMP
);

-- Repeatable sections stored as JSONB or separate tables
CREATE TABLE client_properties (...);
CREATE TABLE client_dependants (...);
CREATE TABLE deal_loan_tranches (...);
CREATE TABLE deal_banks_approached (...);
← Back to How It Works