# Dubai DLD Analytics API - Complete Postman Collection Guide ## ๐Ÿ“‹ Overview This comprehensive Postman collection provides complete testing coverage for the Dubai DLD Analytics API. It includes natural language queries, predefined endpoints, context-aware follow-up queries, error handling, and performance testing scenarios. ## ๐Ÿš€ Quick Start ### 1. Import the Collection - Download `Dubai_DLD_Analytics_API_Complete.postman_collection.json` - Open Postman and click "Import" - Select the downloaded JSON file - The collection will be imported with all folders and requests ### 2. Set Up Environment Variables The collection uses these variables: - `baseUrl`: `http://localhost:3000` (default) - `sessionId`: Auto-generated random session ID ### 3. Start the API Server ```bash cd /home/tech4biz/Desktop/dubai_dld npm start ``` ### 4. Run Tests - Click on any folder to run all tests in that category - Use "Run Collection" to execute all tests - Individual requests can be run by clicking on them ## ๐Ÿ“ Collection Structure ### ๐Ÿฅ Health & System **Purpose**: Verify API health and system status - **Health Check**: Basic API health verification - **Database Info**: Check database tables and record counts - **Available Queries**: List all available endpoints and examples ### ๐Ÿ” Natural Language Queries **Purpose**: Test the core NLP functionality with various query types - **Basic Rental Trend**: Standard rental price trend queries - **Top Areas**: Find areas with most rental transactions - **Project Summary**: General and specific project summaries - **Fast Moving Projects**: Identify high-activity projects - **Off-Plan Uptick**: Find areas with off-plan project growth - **Commercial/Residential Leasing**: Test dynamic number extraction (Top 3, Top six, etc.) - **3BHK Apartment Analysis**: Complex multi-area visualization queries ### ๐Ÿ”„ Context-Aware Follow-up Queries **Purpose**: Test session-based context management - **Initial Query**: Establish context with Business Bay trend - **Follow-up Queries**: Test grouping changes (weekly/monthly) and filters (apartments/villas only) ### ๐Ÿ“Š Predefined Query Endpoints **Purpose**: Test direct API endpoints without NLP processing - **Rental Trends**: Direct area-specific endpoints - **Top Areas**: Predefined rental transaction queries - **Project Summaries**: Direct project data endpoints - **Leasing Queries**: Direct commercial/residential leasing endpoints ### ๐Ÿงช Advanced Test Scenarios **Purpose**: Test edge cases and complex scenarios - **Multi-Parameter Queries**: Complex queries with multiple filters - **Edge Cases**: Invalid areas, long time periods, large numbers - **Invalid Formats**: Test error handling and fallbacks ### โŒ Error Handling Tests **Purpose**: Verify proper error handling and validation - **Missing Parameters**: Test required field validation - **Invalid JSON**: Test malformed request handling - **Non-existent Endpoints**: Test 404 error responses - **Wrong HTTP Methods**: Test method validation ### ๐Ÿš€ Performance Tests **Purpose**: Test API performance and concurrency - **Concurrent Requests**: Same and different session IDs - **Large Responses**: Queries returning substantial data - **Response Time**: Verify performance benchmarks ### ๐Ÿ“‹ Sample Data Validation **Purpose**: Verify data availability and quality - **Business Bay Data**: Validate core area data - **Commercial/Residential Data**: Verify leasing data - **Project Data**: Check project information availability ## ๐ŸŽฏ Key Features Tested ### 1. Natural Language Processing - **Intent Classification**: Trend, compare, summary, filter intents - **Entity Extraction**: Areas, time periods, property types, room types - **Number Extraction**: Both digits (3, 5) and words (three, six, ten) - **Project Name Extraction**: Specific project identification ### 2. Dynamic Query Generation - **Template Selection**: Automatic template matching - **Parameter Building**: Dynamic SQL parameter construction - **Context Awareness**: Session-based query refinement ### 3. Data Visualization - **Chart Generation**: Line charts, bar charts, pie charts - **Card Creation**: Metric cards with descriptions - **Multi-Area Charts**: Comparative area analysis - **Time Series**: Monthly and weekly grouping ### 4. Context Management - **Session Persistence**: Maintain query context across requests - **Follow-up Queries**: Refine existing queries with new parameters - **Grouping Changes**: Switch between monthly/weekly grouping - **Filter Application**: Add property type filters ## ๐Ÿ“Š Expected Response Structure ### Successful Response ```json { "success": true, "data": { "text": "Descriptive text about the query results", "visualizations": [ { "type": "line|bar|pie", "title": "Chart title", "data": { "labels": ["Label1", "Label2"], "datasets": [...] }, "options": {...} } ], "cards": [ { "title": "Card title", "value": "Card value", "subtitle": "Card subtitle", "description": "Card description", "icon": "icon-name" } ], "sql_queries": ["SELECT ..."], "metadata": { "query": "Original query", "intent": "trend|compare|summary|filter", "time_period": {...}, "areas": [...], "result_count": 5, "data_source": "rents|transactions", "topCount": 3, "fallback_reason": null } } } ``` ### Error Response ```json { "success": false, "message": "Error description", "error": "Detailed error message (development only)" } ``` ## ๐Ÿงช Test Scenarios ### 1. Basic Functionality - โœ… Health check passes - โœ… Database connection works - โœ… Basic queries return data - โœ… Response structure is valid ### 2. Number Extraction - โœ… "Top 3 areas" โ†’ `topCount: 3` - โœ… "Top six areas" โ†’ `topCount: 6` - โœ… "Top ten areas" โ†’ `topCount: 10` - โœ… Invalid numbers fallback to default (5) ### 3. Context Management - โœ… Initial query establishes context - โœ… Follow-up queries use existing context - โœ… Grouping changes work (weekly/monthly) - โœ… Filters apply correctly (apartments/villas) ### 4. Error Handling - โœ… Missing parameters return validation errors - โœ… Invalid JSON returns parse errors - โœ… Non-existent endpoints return 404 - โœ… Wrong HTTP methods return method errors ### 5. Performance - โœ… Response time < 5000ms - โœ… Concurrent requests handled properly - โœ… Large responses processed efficiently ## ๐Ÿ”ง Customization ### Adding New Tests 1. **Create New Request**: Add to appropriate folder 2. **Set Variables**: Use `{{baseUrl}}` and `{{sessionId}}` 3. **Add Tests**: Include in the test script section 4. **Document**: Add description and expected behavior ### Modifying Variables - **baseUrl**: Change to point to different environment - **sessionId**: Modify for specific session testing - **Custom Variables**: Add project-specific variables ### Environment Setup Create different environments for: - **Development**: `http://localhost:3000` - **Staging**: `http://staging-api.example.com` - **Production**: `http://api.example.com` ## ๐Ÿ“ˆ Monitoring & Analytics ### Response Time Monitoring All requests include response time tests: ```javascript pm.test('Response time is less than 5000ms', function () { pm.expect(pm.response.responseTime).to.be.below(5000); }); ``` ### Data Quality Validation Key validation tests: - Response structure validation - Data completeness checks - Error handling verification - Performance benchmarks ### Success Rate Tracking Monitor success rates across: - Different query types - Various parameter combinations - Error scenarios - Performance metrics ## ๐Ÿšจ Troubleshooting ### Common Issues 1. **Connection Refused** - Verify API server is running (`npm start`) - Check port 3000 is available - Verify `baseUrl` variable 2. **Empty Responses** - Check database connection - Verify sample data is loaded - Review query parameters 3. **Context Errors** - Ensure session ID is consistent - Check follow-up query sequence - Verify context manager state 4. **Performance Issues** - Monitor response times - Check database query performance - Review server resources ### Debug Steps 1. **Check Health**: Run health check first 2. **Verify Database**: Check database info endpoint 3. **Test Basic Query**: Try simple rental trend query 4. **Review Logs**: Check server console output 5. **Validate Data**: Ensure sample data is loaded ## ๐Ÿ“š Additional Resources - **API Documentation**: See `README.md` for detailed API docs - **Database Schema**: Check `2.sql` for table structures - **Sample Data**: Review JSON files for data examples - **Implementation Guide**: See `IMPLEMENTATION_SUMMARY.md` ## ๐ŸŽ‰ Success Criteria A successful test run should show: - โœ… All health checks pass - โœ… Database connectivity confirmed - โœ… Natural language queries work - โœ… Context management functions - โœ… Error handling works properly - โœ… Performance meets benchmarks - โœ… Data quality is maintained --- **Happy Testing!** ๐Ÿš€ This collection provides comprehensive coverage of the Dubai DLD Analytics API, ensuring all features work correctly and performance meets expectations.