Documentation
Displaying a grid or slideshow of 6+ property photos directly on our dashboard causes massive clutter, slows down page load times, and frequently exposes duplicate, blurry, or low-quality photos (like
Displaying a grid or slideshow of 6+ property photos directly on our dashboard causes massive clutter, slows down page load times, and frequently exposes duplicate, blurry, or low-quality photos (like
Media Carousel & Deduplication
Displaying a grid of property photos causes clutter and slow load times. This redesign shows exactly one perfect hero photo on the main card, with AI ranking images and automated nightly deduplication.
Displaying a grid or slideshow of 6+ property photos directly on our dashboard causes massive clutter, slows down page load times, and frequently exposes duplicate, blurry, or low-quality photos (like closets or hallways) right at the top. We are redesigning our gallery to show exactly 1 perfect, high-resolution "Hero" photo on the main card. Clicking it launches a fast full-screen viewer. Behind the scenes, our AI automatically ranks all property photos to select the best one (preferring living rooms and professional horizontal shots over bathrooms or boilers), and runs a nightly automated pipeline to find and soft-delete duplicate images without requiring manual work.
2. How it works — operational workflow
The redesigned asset media system operates on a dual-engine architecture: the **Heuristic Thumbnail Selector** (which dynamically assigns the single best photo as the primary asset image) and the **Nightly MD5 Image Deduplicator** (which cleans the database of duplicate files). Both run fully autonomously with **zero human-in-the-loop (Non-HITL) intervention**.
Dual-Engine Operational Steps
-
1Single Hero Photo Layout (UI Redesign)
The dashboard asset card is simplified from a multi-photo 2x3 grid to exactly 1 prominent horizontal Hero image slot. This eliminates grid clutter, prevents page layout shifting, and reduces first-load browser bandwidth requirements by up to 85%.
-
2Automated Heuristic Thumbnail Ranking
A background job scores all photos linked to an asset based on MIME-type, resolution, aspect ratio, and AI classification tags. The highest-scoring photo's
media_idis automatically set as the asset's activethumbnail_media_idontbl_assets. -
3Nightly MD5 Hash population
Every night, our pipelines query GCS and Cloudinary object metadata to fetch file MD5 hashes without downloading the actual image bytes. These hashes are written to our media ledger's new
content_hashfield. -
4Soft-Deduplication Execution
The system searches for rows matching on
(asset_id, content_hash). For identical duplicates, it soft-deletes (archives) the older records by settingmedia_status = 'archived', leaving only the primary clean image active in the lightbox viewer.
3. Technical specifications & code reference
This design adds a content_hash column to tbl_media to support high-performance duplicate detection directly at the database layer.
Database Migration (V211__add_media_content_hash.sql)
-- Add content_hash to tbl_media
ALTER TABLE public.tbl_media ADD COLUMN IF NOT EXISTS content_hash VARCHAR(64);
-- Index for high-performance cross-referencing and deduplication
CREATE INDEX IF NOT EXISTS idx_media_asset_content_hash
ON public.tbl_media (asset_id, content_hash)
WHERE media_status = 'active';
Heuristic Selection Scoring Matrix
The ranking algorithm calculates a quality score for each horizontal image using the following criteria:
| Heuristic Rule | Criteria / Trigger | Score Weight | Rationale |
|---|---|---|---|
| Room Classification | AI tag matches living_room, reception, or exterior |
+10 points | These rooms represent the most appealing first impressions. |
| Supplementary Rooms | AI tag matches bedroom |
+5 points | Bedrooms are highly valuable secondary thum
Repository CodeThe live codebase implementation for this specification sits within the following repository folder:
bnails. |
| Utility Rooms | AI tag matches bathroom |
+2 points | Bathrooms are necessary but should not be the default first image. |
| Clutter & Technical Exclusion | AI tag matches hallway, closet, boiler, or description contains EPC |
-20 points | Guarantees that mechanical elements or narrow spaces are never selected. |
| Landscape Aspect Ratio | Aspect ratio matches 4:3 or 16:9 (horizontal) |
+10 points | Landscape photos look best in web carousels and card headers. |
| Resolution Quality | File size is larger than 1.5MB and resolution exceeds 1920px width | +5 points | Prefers sharp, professional photography over compressed shots. |
🛡️ Red Team Data Quality & UX Audit
A comprehensive vulnerability review of executing automated Non-HITL image selections and soft-deletions:
| Vulnerability | Risk & Attack Vector | Business / System Impact | Mitigation Strategy (Gating) |
|---|---|---|---|
| Mislabeled AI Tags / Hallucinations | AI misclassifies a messy storage closet or a bathroom toilet as a "living_room". | A poor, unappealing photo is set as the property's primary storefront thumbnail, hurting lead conversions. | Confidence Floor + File Size check. Only use AI tags with a confidence score greater than 85%. Combine the tag check with an active aspect-ratio and resolution constraint to verify professional capture. |
| Cross-Asset Collision | A generic floorplan or corporate logo (with identical content hash) matches across different properties. | Automated deduplication archives the image globally, deleting legitimate copies from other assets. | Local Scope Restriction. The deduplication script is strictly restricted to comparing files *within the same asset boundaries* (matching on asset_id). Cross-asset matching is flagged for review only. |
| Accidental GCS Object Erasure | A deletion script deletes the physical JPG file on GCS when soft-deleting a database duplicate record. | Irrecoverable loss of the original marketing asset if the active record ever gets corrupted or needs recovery. | Immutable GCS / Soft-Delete Only. The pipeline never deletes physical storage files. It is strictly limited to database ledger mutation, changing media_status from active to archived. |
Architecture Details
Component-based UI architecture built on React/Next.js with Tailwind CSS. The system uses a design token system for consistent theming, a component library for reusable UI elements, and server-side rendering for performance. State management follows a unidirectional data flow pattern.
- Core Component: UI component system and design token engine
- Data Flow: User Input → Component State → Action Dispatch → Data Fetch → Re-render → Display
- Integration Points: Next.js, Tailwind CSS, React context, REST API layer
Configuration Reference
Key configuration parameters for this system:
| Parameter | Type | Default | Description |
|---|---|---|---|
| theme_mode | string | light | UI theme mode (light, dark, system) |
| animation_enabled | boolean | true | Enable/disable UI animations |
| grid_columns | integer | 12 | Layout grid column count |
Figure 2: UI component architecture — component interaction and data flow.
Troubleshooting
| Issue | Cause | Resolution |
|---|---|---|
| Layout shift on page load | Missing dimensions on dynamic content | Add explicit width/height or aspect-ratio CSS |
| Theme mismatch | CSS variable not defined in current theme | Ensure all CSS variables are defined in both light and dark themes |
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.