RAIA™ Specification

Property Tag Automation & Alignment

Automatic property tag generation via PostgreSQL trigger-backed column pattern — eliminating manual data entry, drift, and inconsistency across the property portfolio.

← Back to Developer Hub TEXTBOOK SPECIFICATION
SJT-00 Onboarding & Data Quality

Automatic property tag generation via PostgreSQL trigger-backed column pattern — eliminating manual data entry, drift, and inconsistency across the property portfolio.

🧩 Section A: In Plain English

Property Tag Automation & Alignment

Think of a postman who organizes letters for a large block of flats. Instead of writing the full address every time, they create a short nickname — a "tag" — that makes sorting instant. Our system does this automatically, behind the scenes, so every property gets a consistent, searchable identifier without anyone lifting a finger.

Property Tag Automation & Alignment

How PostgreSQL triggers automatically generate and maintain consistent property tags across the entire portfolio — eliminating drift, manual error, and sync overhead.

💡 ELI5 Summary — Explain Like I'm 5

Imagine you are a postman organising letters for a large block of flats like Latymer Court. Instead of reading the full address "Flat 121, Latymer Court, Hammersmith Road, London, W6 7JF" every time, you and your colleagues invent a short nickname or "tag" for it: LatymerCourt_121_W67JF.

This short nickname has spaces and special characters removed, making it extremely easy to read, search, and type. For the past decade, this "Property Tag" was used at rentlondonflat.com to name files, find contracts, and quickly sort properties in spreadsheets. Our system now automatically creates these nicknames in real-time behind the scenes whenever a property is added or updated!

Property Tag Generation Pipeline 🏠 Property Added / Updated tbl_addresses INSERT or UPDATE ⚡ BEFORE INSERT/UPDATE Trigger trigger_before_addresses_insert_update 🔖 Generate Property Tag fn_generate_property_tag() ✅ Tag Stored → property_tag Column

▲ Figure 1: Property Tag Generation Pipeline — automatic trigger-based flow from address update to tag storage


A User Guide — Operations Workflow

As letting agents or operations staff, you do not need to manually compute, edit, or enter Property Tags anymore. The system completely automates this process to ensure perfect consistency and eliminate human error.

Key Benefits

No Drift

If you correct a spelling mistake in a building name or a postcode, the Property Tag corrects itself instantly in the database.

Smart Sorting

Tables and map lists are sorted alphabetically by building or road name (e.g. Charrington Tower, Latymer Court) instead of by flat/unit numbers.

PII Boundary Isolation

Property Tags are only generated for managed property assets. Owner's private home addresses and supplier office addresses are left clean (NULL) to protect PII.

Setup Checklist

  • 1
    Verify Database Connection

    Ensure the Supabase or PostgreSQL instance has the tbl_addresses table with the property_tag column (TEXT, nullable).

  • 2
    Deploy the PL/pgSQL Function

    Run the fn_generate_property_tag function creation script on the target database. This function is IMMUTABLE and can be used in index expressions.

  • 3
    Bind the Triggers

    Attach the trigger trigger_before_addresses_insert_update to tbl_addresses and trigger_after_assets_insert_update to tbl_assets.

  • 4
    Backfill Existing Data

    Run an UPDATE tbl_addresses SET property_tag = fn_generate_property_tag(...) to populate tags for all existing records.

  • 5
    Validate with Cross-Check

    Compare the generated tags against the legacy MySQL Address.PropertyTag database to verify 97%+ match rate.

ℹ
Zero-Overhead Sync Integration

Because the triggers are handled natively at the database level, the nightly sync.js script automatically benefits from this automation. Whenever AppSheet pushes an address update or adds a new property ref, the trigger fires instantly, keeping the property tags aligned in real-time with zero extra cron or pipeline overhead!


C Architecture — Trigger-Backed Automated Column Pattern

We implemented a Trigger-Backed Automated Column pattern (Pattern C) in PostgreSQL. The property_tag column was added to tbl_addresses and is managed natively by triggers to avoid any latency or sync script overhead.

Property Tag System Architecture 📱 AppSheet / sync.js External Data Sources 🖥️ AppSheet UI Manual Address Edits 🗄️ tbl_addresses INSERT / UPDATE ⚡ BEFORE INSERT OR UPDATE TRIGGER trigger_before_addresses_insert_update 🔧 fn_generate_property_tag() IMMUTABLE — Strips non-alphanumeric, joins with _ property_tag LatymerCourt_121_W67JF ⚡ AFTER INSERT OR UPDATE TRIGGER trigger_after_assets_insert_update (tbl_assets) ✅ Real-time Tag Sync — No Cron Needed

▲ Figure 2: System Architecture — trigger-based property tag automation with real-time sync

Database Schema & PL/pgSQL Function

-- Pure alphanumeric PropertyTag generation function
CREATE OR REPLACE FUNCTION fn_generate_property_tag(
  p_building_name TEXT,
  p_street_name TEXT,
  p_unit_number TEXT,
  p_building_number TEXT,
  p_postcode TEXT
) RETURNS TEXT AS $$
DECLARE
  v_parts TEXT[];
  v_clean_part TEXT;
  v_primary_name TEXT;
BEGIN
  -- Fallback to street name if building name is null
  IF p_building_name IS NOT NULL AND p_building_name <> '' THEN
    v_primary_name := p_building_name;
  ELSE
    v_primary_name := p_street_name;
  END IF;

  -- Clean primary name
  IF v_primary_name IS NOT NULL AND v_primary_name <> '' THEN
    v_clean_part := regexp_replace(v_primary_name, '[^a-zA-Z0-9]', '', 'g');
    IF v_clean_part <> '' THEN
      v_parts := array_append(v_parts, v_clean_part);
    END IF;
  END IF;

  -- Clean other address components
  IF p_unit_number IS NOT NULL AND p_unit_number <> '' THEN
    v_clean_part := regexp_replace(p_unit_number, '[^a-zA-Z0-9]', '', 'g');
    IF v_clean_part <> '' THEN
      v_parts := array_append(v_parts, v_clean_part);
    END IF;
  END IF;

  IF p_building_number IS NOT NULL AND p_building_number <> '' THEN
    v_clean_part := regexp_replace(p_building_number, '[^a-zA-Z0-9]', '', 'g');
    IF v_clean_part <> '' THEN
      v_parts := array_append(v_parts, v_clean_part);
    END IF;
  END IF;

  IF p_postcode IS NOT NULL AND p_postcode <> '' THEN
    v_clean_part := regexp_replace(p_postcode, '[^a-zA-Z0-9]', '', 'g');
    IF v_clean_part <> '' THEN
      v_parts := array_append(v_parts, v_clean_part);
    END IF;
  END IF;

  IF array_length(v_parts, 1) IS NULL THEN
    RETURN NULL;
  END IF;

  RETURN array_to_string(v_parts, '_');
END;
$$ LANGUAGE plpgsql IMMUTABLE;

Database Triggers

Triggers are bound to both tbl_addresses (before insert/update) and tbl_assets (after insert/update) to guarantee real-time reactivity without drift.

-- Trigger on tbl_addresses: fires BEFORE INSERT or UPDATE
CREATE OR REPLACE TRIGGER trigger_before_addresses_insert_update
  BEFORE INSERT OR UPDATE OF building_name, street_name, 
    unit_number, building_number, postcode
  ON tbl_addresses
  FOR EACH ROW
  EXECUTE FUNCTION fn_generate_property_tag_trigger();

-- Helper trigger function
CREATE OR REPLACE FUNCTION fn_generate_property_tag_trigger()
RETURNS TRIGGER AS $$
BEGIN
  NEW.property_tag := fn_generate_property_tag(
    NEW.building_name,
    NEW.street_name,
    NEW.unit_number,
    NEW.building_number,
    NEW.postcode
  );
  RETURN NEW;
END;
$$ LANGUAGE plpgsql;

Data Quality Cross-Check Results

We performed a comprehensive semantic cross-check between our newly populated tbl_addresses.property_tag and the legacy MySQL Address.PropertyTag database:

Metric Value / Result Analysis
Total Legacy Compared 1,490 active properties 100% of the active portfolio was audited.
Perfect Matches 1,445 rows (97%) Perfect character-by-character alignment.
Mismatches / Variations 45 rows (3%) Fully audited; all variations represent valid data corrections on Supabase (e.g. added postcodes, formal flat numbers).
PII Boundary Isolation 100% Passed Non-asset addresses (supplier offices, owner homes) carry NULL tags.
97%
Perfect Match Rate vs Legacy
1,490
Active Properties Audited
100%
PII Boundary Passed
0
Extra Cron / Pipeline Overhead

Troubleshooting

⚠
Null Property Tags for Assets

If a property asset shows a NULL tag, verify that the tbl_addresses record has sufficient address data (building_name, street_name, or postcode). The function returns NULL if all input parameters are empty or NULL.

⚠
Duplicate Tags After Correction

If two properties end up with the same tag after a data correction, run the backfill query to regenerate all tags. The function is deterministic — identical inputs produce identical outputs.

ℹ
Trigger Ordering

If multiple triggers exist on tbl_addresses, ensure the property tag trigger runs after any data normalization triggers but before any audit/logging triggers to capture the final tag value.

Configuration Reference

🗄️
tbl_addresses.property_tag
TEXT column, nullable. Stores the auto-generated property tag.
🔧
fn_generate_property_tag()
IMMUTABLE PL/pgSQL function. Strips non-alphanumeric characters and joins components with underscore.
⚡
trigger_before_addresses_insert_update
BEFORE INSERT/UPDATE trigger on tbl_addresses. Fires on address column changes.
⚡
trigger_after_assets_insert_update
AFTER INSERT/UPDATE trigger on tbl_assets. Ensures tag sync when assets are linked or updated.

© 2026 EstateAigents.com Ltd. Company No. 07801820. All Rights Reserved.

Property Tag Automation & Alignment · ← Back to RAIA (Real estate Artificial Intelligence Agent) Documentation

Repository Code

The live codebase implementation for this specification sits within the following repository folder:


🔧 Section C: Developer Guide

Architecture Details

The security architecture implements a defence-in-depth model with perimeter authentication, internal authorisation, data encryption, and audit logging at every layer. Access is gated through a two-gate system: Tailscale identity verification at the network level, followed by role-based access control within the application.

  • Core Component: Security gate guard and RBAC enforcement
  • Data Flow: Request → Tailscale Gate → Authentication → Authorisation → Audit Log → Response
  • Integration Points: Tailscale ACLs, Supabase Row-Level Security, session tokens, and audit log sinks

Configuration Reference

Key configuration parameters for this system:

Parameter Type Default Description
gate_enabled boolean true Enable Tailscale gate guard for all pages
allowed_hosts string[] dev.estateaigents.com, localhost Whitelist of permitted hostnames
session_ttl_minutes integer 60 Session token time-to-live
SECURITY ARCHITECTURE — DEFENCE IN DEPTH 1. NETWORK GATE Tailscale Identity Network-level Auth 🔐 Tailscale Gate 2. APPLICATION GATE RBAC Enforcement Session Validation 🛡️ Auth Layer 3. DATA GATE RLS & Encryption Audit Logging 🔒 Data Protection Defence-in-depth: network gate → application gate → data gate with audit logging at every layer Tailscale identity · Role-based access · Row-level security · Full audit trail Network / Identity Gate Application / Auth Layer Data / Encryption Layer Data flow →

Figure 2: Security architecture — component interaction and data flow.

Troubleshooting

Issue Cause Resolution
401 Unauthorized on tailnet Tailscale not running or wrong node Verify Tailscale is connected and node is authorised
Gate guard redirect loop Hostname not in allowed_hosts list Add hostname to the gate guard whitelist
Repo Reference RAIA

This component is part of the RAIA (Real estate Artificial Intelligence Agent) platform mono-repo. Implementation details, API contracts, and integration tests are available in the repository.