# GoodGo Platform API Exploration Summary ## Executive Summary Complete audit of GoodGo Platform monorepo API endpoints and data structures. All field names, types, and response formats documented for UI component mapping. **Generated**: April 21, 2026 **Scope**: `apps/api/src/modules/{analytics,listings,agents,search}` + `prisma/schema.prisma` --- ## πŸ“‹ Key Findings ### Analytics Module (βœ… Fully Explored) **Endpoints Count**: 15+ key endpoints **Architecture**: CQRS with query handlers β†’ DTOs **Caching**: 30min - 24hr TTL across endpoints **Auth**: JWT required (except public endpoints) **Core Features**: 1. **Market Data** (snapshot, trends, heatmap, district stats) - Real-time aggregation from active listings - Price change metrics (1d, 7d, 30d) - Per-district inventory & absorption data 2. **Valuations (AVM)** (v1 & v2 models) - GET by property ID or coordinates - POST manual input with extended features - Batch operations (up to 50 properties) - Historical tracking & comparisons - Confidence scoring with explanations 3. **Trending Areas** - Scoring algorithm: `inquiriesΓ—0.6 + viewsΓ—0.3 + listingsΓ—0.1` - Time-window configurable (default 30 days) - District/ward level aggregation 4. **Neighborhood Scores** - 6 dimensional scoring (education, healthcare, transport, shopping, greenery, safety) - POI counting (schools, hospitals, transit, malls, parks, restaurants) - 0-100 scale with aggregation 5. **Nearby POIs** (Public) - Geographic search within radius - 6 main categories with type mapping - Distance calculation using PostGIS ### Listings Module (βœ… Fully Explored) **Entity Count**: 2 main aggregates (Listing + Property) **Field Count**: ~45 total fields across entities **Key Features**: - Listing status state machine (DRAFT β†’ PENDING_REVIEW β†’ ACTIVE β†’ SOLD/RENTED) - AI price estimates with confidence scores - Moderation workflow with scoring - Engagement metrics (views, saves, inquiries) - Featured promotion with expiry tracking - Rent pricing support - Commission tracking **Property Fields**: - Core: type, title, description, location (PostGIS), area - Rooms: bedrooms, bathrooms, floors, floor level - Infrastructure: direction, year built, legal status, metro distance - Amenities: JSON-based (flexible schema) - Enhanced: furnishing, condition, parking, maintenance fee, pet-friendly, view types, suitability tags ### Agents Module (βœ… Explored) **Key Fields**: - Profile: userId, licenseNumber, agency, bio - Credentials: isVerified (boolean) - Performance: qualityScore (0-100), totalDeals, responseTimeAvg - Coverage: serviceAreas (array of district IDs) **Performance Metrics**: - Quality score as composite metric - Response time in seconds (need conversion for display) - Deal count as credibility indicator ### Search Module (βœ… Explored) **Architecture**: Meilisearch (typesense-compatible backend) **Index Fields**: 31 fields per document **Key Features**: - Full-text + filtering + geo-search - Featured listing flag - Engagement metrics copied to index - Amenities as string array **Supported Filters**: - propertyType, transactionType - Price range, area range - Bedrooms (>= operator) - District, city - Featured status ### Prisma Schema (βœ… Full Review) **Key Models**: - User (role-based: BUYER, SELLER, AGENT, DEVELOPER, PARK_OPERATOR, ADMIN) - Property (core real estate entity) - Listing (marketplace listing wrapper) - Agent (performance tracking) - Valuation (AVM history) - MarketIndex (market analytics cache) - Transaction, Inquiry, Lead, Payment, Order, Escrow models **Enums**: - PropertyType: 6 values (APARTMENT, VILLA, TOWNHOUSE, LAND, OFFICE, SHOPHOUSE) - TransactionType: 2 values (SALE, RENT) - ListingStatus: 8 values (DRAFT...REJECTED) - Direction: 8 compass values - Furnishing: 3 levels - PropertyCondition: 4 conditions --- ## 🎯 API Field Reference by Use Case ### For Property Card Display ``` Price β†’ listing.priceVND (format as VND) Type β†’ listing.transactionType Status β†’ listing.status Area β†’ property.areaM2 Beds/Baths β†’ property.bedrooms, property.bathrooms Location β†’ property.district, property.ward, property.city Agent β†’ listing.agent.user.fullName, listing.agent.qualityScore Engagement β†’ listing.viewCount, listing.saveCount, listing.inquiryCount Featured β†’ listing.featuredUntil (if > now, show badge) ``` ### For Valuation Display ``` Estimate β†’ ValuationDto.estimatedPrice (string, format as VND) Confidence β†’ ValuationDto.confidence (0.0-1.0, convert to %) Price/mΒ² β†’ ValuationDto.pricePerM2 Model Version β†’ ValuationDto.modelVersion (v1|v2|ensemble) Comparables β†’ ValuationDto.comparables[] with distance & price ``` ### For Market Analysis ``` Market Snapshot β†’ GET /analytics/market-snapshot β”œβ”€ activeCount, avgPrice, medianPrice, avgPricePerM2 β”œβ”€ daysOnMarket, newListings24h └─ priceChangePct { d1, d7, d30 } Price Trend β†’ GET /analytics/price-trend β”œβ”€ trend[] { period, medianPrice, avgPriceM2, totalListings } Heatmap β†’ GET /analytics/heatmap β”œβ”€ dataPoints[] { district, avgPriceM2, totalListings, medianPrice } District Stats β†’ GET /analytics/district-stats β”œβ”€ districts[] { district, medianPrice, avgPriceM2, totalListings, daysOnMarket, yoyChange } Trending Areas β†’ GET /analytics/trending-areas β”œβ”€ areas[] { name, listings, inquiries, views, priceChangePct, scoreRank } ``` ### For Location Intelligence ``` Neighborhood Score β†’ GET /analytics/neighborhoods/:district/score β”œβ”€ educationScore, healthcareScore, transportScore, shoppingScore β”œβ”€ greeneryScore, safetyScore, totalScore (all 0-100) β”œβ”€ poiCounts { schools, hospitals, transit, shopping, parks, restaurants } Nearby POIs β†’ GET /analytics/pois/nearby β”œβ”€ pois[] { name, type, category, lat, lng, distance, address } ``` --- ## πŸ”Œ Quick Integration Checklist ### Before Mapping UI Components: - [ ] **Understand Caching**: Most analytics endpoints have 30min-24hr cache - Include `cachedAt` and `nextRefreshAt` in UI - Plan refresh UX accordingly - [ ] **Price Handling**: All prices in VND - Received as strings (precision preservation) - Must format for display (thousand separators, currency symbol) - BigInt in DB, may overflow JS numbers - [ ] **Confidence Scores**: Different scales - Valuation confidence: 0.0-1.0 (multiply by 100 for %) - Moderation score: 0-100 (direct use) - Quality score (agent): 0-100 (convert 0-5 stars) - [ ] **Enum Handling**: Map enum values to display labels - PropertyType: 6 values (need translations) - ListingStatus: 8 values (map to colors/icons) - TransactionType: 2 values (SALE vs RENT) - [ ] **Coordinates**: Use `property.location` (PostGIS geometry) - Accessible as `lat`, `lng` in API responses - Distance calculations use PostGIS functions - [ ] **Rate Limits**: Per endpoint - Valuation POST: 10 req/min/user - Search: 200 req/min/user - Implement backoff/retry logic - [ ] **Null Handling**: Many fields optional - `bedrooms`/`bathrooms` can be null (studio) - `agentId` can be null (direct seller) - Valuation `confidence` may have `null` comparables - Handle gracefully in UI - [ ] **Pagination**: Search results include - `page`, `perPage`, `totalPages`, `totalFound` - Implement lazy loading or infinite scroll --- ## πŸ“š Documentation Files Generated 1. **API_ENDPOINTS_REFERENCE.md** (~800 lines) - Complete endpoint documentation - Request/response schemas in TypeScript - Query parameters & caching info - Prisma model definitions 2. **UI_MAPPING_QUICK_GUIDE.md** (~400 lines) - Visual mockups with field mappings - Pre-formatted example layouts - Common conversions (price, confidence, distance) - UI integration patterns 3. **API_EXPLORATION_SUMMARY.md** (this file) - Executive overview - Key findings by module - Integration checklist - References --- ## πŸ”— Source Files Analyzed ### Analytics Module - `controllers/analytics.controller.ts` β†’ 15 endpoints - `domain/services/avm-service.ts` β†’ AVM interface & types - `application/queries/{...}/handler.ts` β†’ 10+ query handlers with DTO definitions - `presentation/dto/{...}.ts` β†’ Request/response types ### Listings Module - `domain/entities/listing.entity.ts` β†’ Listing aggregate (status machine, events) - `domain/entities/property.entity.ts` β†’ Property aggregate (updateable fields) ### Agents Module - `domain/entities/agent.entity.ts` β†’ Agent profile & performance metrics ### Search Module - `domain/repositories/search.repository.ts` β†’ SearchResult interface & 31 indexed fields ### Database - `prisma/schema.prisma` β†’ 30+ models with enums & indexes --- ## βœ… Data Quality Notes **Strengths**: - Strong type safety (NestJS + Prisma) - Comprehensive DTOs for API contracts - Clear status machine for listings - Well-indexed database schema - Separation of concerns (domain β†’ application β†’ presentation) **Considerations**: - JSON fields in Property (amenities, nearbyPOIs) β€” verify schema client-side - Price precision β€” use strings, not numbers, for financial data - Confidence scores use different scales β€” easy to mix up - Service areas stored as JSON array of district IDs β€” need mapping table - Valuation comparables may be null if insufficient data --- ## πŸŽ“ Next Steps 1. **API Client Generation** - Use Swagger/OpenAPI docs from NestJS controllers - Generate TypeScript client with `openapi-generator` 2. **Component Development** - Start with property card components - Wire market snapshot widget - Build valuation display components 3. **Data Transformation Layer** - Create utility functions for price formatting - Build confidence score converters - Implement district ID β†’ name mappings 4. **Testing** - Mock response data from this reference - Test edge cases (null values, precision, formatting) - Verify caching behavior --- ## πŸ“ž Key Contacts & Resources **API Documentation**: Swagger/OpenAPI available at `/api/docs` (NestJS Swagger module) **Prisma Models**: Comprehensive schema with relationships in `prisma/schema.prisma` **Code Examples**: Query handlers in `apps/api/src/modules/analytics/application/queries/` --- **Document Version**: 1.0 **Last Updated**: April 21, 2026 **Status**: Complete βœ… All information current as of repository scan on 2026-04-21.