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.
Automatic property tag generation via PostgreSQL trigger-backed column pattern — eliminating manual data entry, drift, and inconsistency across the property portfolio.
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.
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!
▲ 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
If you correct a spelling mistake in a building name or a postcode, the Property Tag corrects itself instantly in the database.
Tables and map lists are sorted alphabetically by building or road name (e.g. Charrington Tower, Latymer Court) instead of by flat/unit numbers.
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
-
1Verify Database Connection
Ensure the Supabase or PostgreSQL instance has the
tbl_addressestable with theproperty_tagcolumn (TEXT, nullable). -
2Deploy the PL/pgSQL Function
Run the
fn_generate_property_tagfunction creation script on the target database. This function isIMMUTABLEand can be used in index expressions. -
3Bind the Triggers
Attach the trigger
trigger_before_addresses_insert_updatetotbl_addressesandtrigger_after_assets_insert_updatetotbl_assets. -
4Backfill Existing Data
Run an
UPDATE tbl_addresses SET property_tag = fn_generate_property_tag(...)to populate tags for all existing records. -
5Validate with Cross-Check
Compare the generated tags against the legacy MySQL
Address.PropertyTagdatabase to verify 97%+ match rate.
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.
▲ 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. |
Troubleshooting
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.
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.
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
© 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:
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 |
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 |
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.