# Backend API Audit: Trading Exchange UI Refactor β€” Index ## πŸ“‹ Audit Documents This audit analyzed the goodgo-platform-ai backend API to identify gaps for the frontend refactor into a "trading exchange" (sΓ n giao dα»‹ch) style UI. ### Documents Generated 1. **BACKEND_API_AUDIT_EXCHANGE_UI.md** (261 lines) - Full detailed audit with endpoint inventory - Per-module breakdown (listings, analytics, search, agents, admin, reviews) - All 10 critical + medium priority gaps documented - Phased implementation roadmap (Phase 1–3) - **Use this for**: In-depth planning, requirement discussions with backend team 2. **BACKEND_API_AUDIT_QUICK_REFERENCE.txt** (130 lines) - One-page quick reference with visual formatting - Highlights only the 10 gaps that need attention - Sprint-by-sprint roadmap - **Use this for**: Daily standup reference, priority discussions, quick reviews --- ## 🎯 Key Findings ### Summary Statistics - **Total Endpoints Audited:** 70+ - **Ready for FE:** 58 βœ… - **Critical Gaps:** 5 πŸ”΄ - **Medium Priority Gaps:** 5 🟑 - **Estimated Dev Effort:** 2–3 sprints - **Quick Wins:** 2 (sortBy, metadata) ### The 10 Gaps at a Glance | # | Gap | Priority | Module | Effort | |---|-----|----------|--------|--------| | 1 | Recent listings ticker | πŸ”΄ CRITICAL | listings | Low | | 2 | Market snapshot endpoint | πŸ”΄ CRITICAL | analytics | Medium | | 3 | Trending areas | πŸ”΄ CRITICAL | analytics | Medium | | 4 | Similar listings | πŸ”΄ CRITICAL | listings | Medium | | 5 | Listing detail enrichment | πŸ”΄ CRITICAL | listings | Medium | | 6 | Price movers (gainers/losers) | 🟑 Medium | analytics | Low | | 7 | Market history (12m trends) | 🟑 Medium | analytics | Medium | | 8 | Ward-level heatmap | 🟑 Medium | analytics | Low | | 9 | Real-time listing updates | 🟑 Medium | listings | High | | 10 | Cache metadata in responses | 🟑 Medium | analytics | Low | --- ## πŸ“Š Detailed Breakdown by UI Screen ### 1. Home Dashboard (Market Overview) **Status:** 40% ready **Currently Available:** - Market report (district-level stats) βœ… - Heatmap (by district) βœ… - Price trends βœ… **Missing:** - Market snapshot (live tiles with totalActive, avgPrice, change%) ❌ Gap #2 - Recent listings ticker ❌ Gap #1 - Trending areas (hot markets by inquiry volume) ❌ Gap #3 **Effort to Complete:** ~1 week (gaps #1–3) --- ### 2. Listings Board (Search + Filter) **Status:** 80% ready **Currently Available:** - Full search with faceted filters βœ… - Pagination, sorting (but not by publishedAt) βœ… - Real-time updates endpoint exists but needs `sortBy=publishedAt` ⚠️ **Missing:** - Sort by "newest first" (publishedAt) ❌ Gap #1 - "Just posted" / "price dropped" badges (needs real-time) ❌ Gap #9 - Similar listings comparables ❌ Gap #4 **Effort to Complete:** ~2–3 days (gaps #1, #4) --- ### 3. Listing Detail **Status:** 70% ready **Currently Available:** - Full property data (description, media, location) βœ… - Seller & agent info βœ… - Price history βœ… - Media gallery βœ… - AVM endpoint exists (separate call) βœ… **Missing:** - Valuation estimate in detail response ❌ Gap #5 - Inquiry count exposed ❌ Gap #5 - Agent quality score denormalized ❌ Gap #5 - Similar listings carousel ❌ Gap #4 **Effort to Complete:** ~3–4 days (gaps #4, #5) --- ### 4. Agent Profile Card **Status:** 85% ready **Currently Available:** - Public agent profile βœ… - Quality score βœ… - Agency info βœ… **Missing:** - Review stats (avg, count) β€” have separate endpoint but not denormalized ⚠️ - Active listings count ❌ (search + filter workaround: count by agent) - Response time metrics ❌ (not tracked) **Effort to Complete:** ~2–3 days (no new endpoints needed, just denormalization) --- ### 5. Admin Panel **Status:** 95% ready **Currently Available:** - Moderation queue βœ… - KYC queue βœ… - User management βœ… - Audit logs βœ… - Revenue analytics βœ… **Missing:** - None for core features; only nice-to-haves like queue statistics **Effort to Complete:** Complete, ready for FE --- ### 6. Market Analytics Page **Status:** 60% ready **Currently Available:** - Market report (current snapshot) βœ… - Price trends βœ… - Heatmap (by district) βœ… - Neighborhood scores βœ… **Missing:** - Market history (12-month data for trend charts) ❌ Gap #7 - Ward-level heatmap drill-down ❌ Gap #8 - Price movers (top gainers/losers) ❌ Gap #6 - Cache metadata (data age indicators) ❌ Gap #10 **Effort to Complete:** ~1 week (gaps #6–8, #10) --- ## πŸš€ Recommended Implementation Order ### Sprint 1 (Days 1–4) - **Gap #1:** Add `sortBy=publishedAt` to `/listings` search - File: `apps/api/src/modules/listings/presentation/dto/search-listings.dto.ts` - Effort: 1 day - **Gap #4:** Add `GET /listings/:id/similar` endpoint - File: New query: `apps/api/src/modules/listings/application/queries/get-similar-listings/` - Effort: 1.5 days ### Sprint 2 (Days 5–8) - **Gap #2:** Add `GET /analytics/market-snapshot` endpoint - File: New query in analytics module - Effort: 2 days - **Gap #3:** Add `GET /analytics/trending-areas` endpoint - Effort: 1.5 days ### Sprint 3 (Days 9–12) - **Gap #5:** Enrich `GET /listings/:id` with `valuationEstimate`, `inquiryCount`, `agentScore` - Effort: 1.5 days - **Gap #10:** Add `cachedAt`, `nextRefreshAt` to all `/analytics/*` responses - Effort: 1 day ### Sprint 4 (Days 13–17) β€” Medium Priority - **Gap #6:** `GET /analytics/price-movers` - Effort: 1.5 days - **Gap #7:** `GET /analytics/market-history?period=12m` - Effort: 2 days ### Sprint 5+ (Optional) - **Gap #8:** Ward-level heatmap enhancement - **Gap #9:** Real-time updates (WebSocket/SSE) --- ## πŸ“ File Structure Reference All controllers follow this pattern: ``` apps/api/src/modules/{MODULE}/ β”œβ”€β”€ presentation/ β”‚ β”œβ”€β”€ controllers/ β”‚ β”‚ └── {name}.controller.ts β”‚ └── dto/ β”‚ └── *.dto.ts β”œβ”€β”€ application/ β”‚ β”œβ”€β”€ commands/ β”‚ └── queries/ β”‚ └── {query-name}/ β”‚ β”œβ”€β”€ {query-name}.query.ts β”‚ └── {query-name}.handler.ts β”œβ”€β”€ domain/ β”‚ └── repositories/ └── infrastructure/ ``` Key files to modify: - **Listings module:** `apps/api/src/modules/listings/presentation/controllers/listings.controller.ts` - **Analytics module:** `apps/api/src/modules/analytics/presentation/controllers/analytics.controller.ts` - **Search module:** `apps/api/src/modules/search/presentation/controllers/search.controller.ts` --- ## βœ… Audit Checklist - [x] All 70+ endpoints enumerated by module - [x] Route prefixes, methods, query params documented - [x] Auth/guard requirements identified - [x] Gaps mapped to UI screen requirements - [x] Implementation roadmap created - [x] Sprint-by-sprint effort estimates provided - [x] No mock data recommendedβ€”all real backend data - [x] File paths provided for easy navigation --- ## πŸŽ“ How to Use This Audit ### For Backend TechLead: 1. Read **BACKEND_API_AUDIT_EXCHANGE_UI.md** for full context 2. Prioritize gaps 1–5 (critical) in Sprint 1–2 3. Reference "Implementation Roadmap" section for sequencing 4. Use "Recommendations" section for effort estimates ### For Frontend Lead: 1. Read **BACKEND_API_AUDIT_QUICK_REFERENCE.txt** for quick summary 2. For each screen needing data: - Check "Available Endpoints" section - If gaps exist, reference "Critical Gaps" section - Communicate blocker status to backend ### For Product Manager: 1. Review "Detailed Breakdown by UI Screen" section above 2. Readiness % shows which screens are ready for FE work 3. Effort estimates help with release planning --- ## πŸ“ž Questions / Follow-ups **Q: Can we use mock data on FE while waiting for gaps?** **A:** No β€” requirement is for real backend data only. Gaps must be closed before FE integration. **Q: Which gap is easiest to complete first?** **A:** Gap #1 (sortBy=publishedAt) β€” adds 1 parameter to existing search endpoint, ~1 day. **Q: Which gap has the most impact?** **A:** Gap #2 (market-snapshot) β€” powers entire home dashboard, enables real-time trading feel. **Q: Can gaps #8 and #9 be skipped?** **A:** Yes β€” Gap #8 (ward-level heatmap) is nice-to-have; Gap #9 (real-time) is polish. Gaps #1–7 are blocking. --- **Audit Date:** 2026-04-21 **Repository:** goodgo-platform-ai **Scope:** 70+ endpoints across 12 modules **Status:** Ready for planning | No mock data allowed **Next Step:** TechLead prioritization of gaps 1–7 for sprint planning