Skip to content

πŸ† AWS AI Agent Hackathon Entry: Multi-agent HDB advisor using Amazon Bedrock AgentCore, Nova Lite, and intelligent cost optimization. Find your perfect Singapore home with AI.

License

seehiong/smartflat-ai

Repository files navigation

HDB Multi-Agent Advisor

A phased multi-agent system for HDB property recommendations using AWS Bedrock AgentCore and the official AWS multi-agent pattern.

Phase 3: Cost-Optimized Multi-Agent System (Current)

Complete multi-agent system with intelligent routing for cost optimization between PostgreSQL and Athena.

Architecture

graph TD
    A[User] --> B[Web Interface]
    B --> C[API Gateway]
    C --> D[Chat Handler Lambda]
    D --> E[AgentCore Supervisor<br/>Amazon Nova Lite]
    
    E --> F{Query Routing}
    F -->|Demographics| G[Demographics Agent]
    F -->|Complex Analytics| H[Property Agent]
    F -->|Cost-Optimized| I[PostgreSQL Agent]
    
    G --> J[Data Commons API]
    J --> K[Singapore Gov Data]
    
    H --> L[Athena API Lambda]
    L --> M[Amazon Athena]
    M --> N[S3 HDB Data]
    
    I --> O[PostgreSQL API Lambda]
    O --> P[RDS Proxy]
    P --> Q[PostgreSQL RDS]
    Q --> R[HDB Resale Data<br/>2017+ Transactions]
    
    G --> S[Response]
    H --> S
    I --> S
    S --> D
    D --> C
    C --> B
    B --> A
Loading

Components:

  • Supervisor Agent: Intelligent query routing using AWS AgentCore with Amazon Nova Lite
  • Demographics Agent: Singapore population data via Data Commons API
  • Property Agent: Complex HDB analytics via Athena queries (for statistical analysis)
  • PostgreSQL Agent: Cost-optimized HDB queries via RDS Proxy (70% cheaper than Athena)
  • Dual Data Sources: Same HDB data available via both PostgreSQL (fast) and Athena (complex analytics)

Capabilities & Examples

Query Type Example Agent Result
Property Search "Find 4-room flat in Bishan under $600k" Property "4 ROOM at 25 SIN MING RD, $442,000, 88sqm"
Price Statistics "Average HDB prices in Tampines?" Property "$643,467 average (3,975 transactions)"
Market Trends "Price trends for 5-room flats" Property Monthly trends with growth analysis
Demographics "Singapore population breakdown" Demographics "6,036,860 people (live gov data)"

Project Structure

hdb-multiagent-advisor/
β”œβ”€β”€ agent/
β”‚   β”œβ”€β”€ supervisor.py             # βœ… Routes queries with Amazon Nova Lite
β”‚   └── agents/
β”‚       β”œβ”€β”€ demographics_agent.py # βœ… Singapore population & statistics
β”‚       β”œβ”€β”€ property_agent.py     # βœ… Complex HDB analytics via Athena
β”‚       └── postgres_agent.py     # βœ… Cost-optimized HDB queries
β”œβ”€β”€ infrastructure/
β”‚   β”œβ”€β”€ phase1-stack.yaml         # Web interface + chat handler
β”‚   β”œβ”€β”€ phase2-stack.yaml         # Athena API + HDB database
β”‚   β”œβ”€β”€ phase3-stack.yaml         # PostgreSQL API + RDS Proxy
β”‚   └── cloudfront-stack.yaml     # CloudFront distribution (auto-generated)
β”œβ”€β”€ lambda/
β”‚   β”œβ”€β”€ chat_handler/             # Web interface backend
β”‚   β”œβ”€β”€ athena_complex_query/     # HDB data API endpoints (complex)
β”‚   └── postgres_query/           # HDB data API endpoints (cost-optimized)
β”œβ”€β”€ web/index.html                # Chat interface with 3 phase examples
β”œβ”€β”€ deploy-phase1.ps1             # Deploy web interface
β”œβ”€β”€ deploy-phase2.ps1             # Deploy Athena database
β”œβ”€β”€ deploy-phase3.ps1             # Deploy PostgreSQL integration
β”œβ”€β”€ deploy-cloudfront.ps1         # Deploy CloudFront distribution
└── setup.ps1                     # Environment setup

Migration Path Completed

βœ… Phase 1: Foundation (Completed)

  • Single HDB assistant with Data Commons integration
  • Basic chat interface and memory persistence

βœ… Phase 2: Multi-Agent HDB System (Completed)

  • Property Agent: HDB search, statistics, price trends using Athena + S3
  • Demographics Agent: Singapore population and statistics via Data Commons
  • Supervisor Agent: Intelligent query routing between specialized agents
  • Athena API: Full REST API for HDB resale data (2017 onwards)
  • Web Interface: Real-time chat with multi-agent responses

βœ… Phase 3: Cost-Optimized Multi-Agent System (Current)

  • PostgreSQL Agent: Cost-optimized HDB queries via RDS Proxy (70% cheaper)
  • Intelligent Cost Routing: Automatic selection between PostgreSQL and Athena
  • RDS Proxy Integration: Secure, scalable database connections
  • Cost Optimization: PostgreSQL for frequent queries, Athena for complex analytics
  • Dual Data Sources: Same HDB data available via both PostgreSQL and Athena
  • CloudFront CDN: Global content delivery with HTTPS, caching, and custom error pages

Getting Started

Prerequisites

  1. AWS CLI: Installed and configured with appropriate credentials.
  2. PowerShell: Available on your system to run the scripts.
  3. uv: Python package manager (installed by setup.ps1 if needed).

Quick Start

# 1. Initial setup
.\setup.ps1
.venv\Scripts\Activate.ps1

# 2. Deploy AgentCore supervisor
agentcore configure -e agent/supervisor.py
agentcore launch

# 3. Deploy infrastructure
.\deploy-phase1.ps1     # Web interface + chat handler
.\deploy-phase2.ps1     # Athena API + HDB database
.\deploy-phase3.ps1     # PostgreSQL API + RDS Proxy
.\deploy-cloudfront.ps1 # CloudFront distribution (global CDN)

# 4. Visit the CloudFront URL for global access

Key Features

βœ… Cost-Optimized Multi-Agent System

  • Property Search: Real HDB transactions via both PostgreSQL (fast) and Athena (complex)
  • Cost Intelligence: Automatic routing for 70% cost savings on frequent queries
  • Price Analytics: Statistics, trends, and market comparisons
  • Demographics: Live Singapore government data via Data Commons API
  • Intelligent Routing: Supervisor routes to optimal agent based on query complexity and cost

βœ… Production Architecture

  • AgentCore Runtime: AWS Bedrock AgentCore with Amazon Nova Lite model
  • Dual Data Sources: PostgreSQL (RDS Proxy) + Athena for cost optimization
  • RDS Proxy: Secure, scalable database connection pooling
  • CloudFront CDN: Global content delivery with HTTPS and caching
  • CloudFormation: Complete infrastructure as code
  • Web Interface: Real-time chat interface with phase examples

🎯 Example Queries (Phase 3)

  • "Average HDB prices in Tampines" β†’ PostgreSQL Agent (cost-optimized, 70% cheaper)
  • "Complex statistical analysis of 5-room price trends" β†’ Property Agent (Athena for analytics)
  • "Singapore population breakdown" β†’ Demographics Agent (Data Commons API)

Design Principles

  • AWS Official Pattern: Uses the supervisor-agent pattern from AWS multi-agent blog post
  • Amazon Nova Lite: Cost-effective AI model for intelligent query routing and responses
  • Specialized Agents: Each agent focuses on a specific domain (demographics, property data)
  • Intelligent Routing: Supervisor routes queries to appropriate specialized agents
  • Cost Optimization: Automatic selection between PostgreSQL (fast/cheap) and Athena (complex analytics)
  • Standalone Architecture: No complex imports or inheritance - each agent is self-contained
  • Memory-First: AgentCore Memory for conversation history and user preferences
  • Scalable Foundation: Ready for AgentCore Gateway, Memory, and advanced multi-agent workflows

About

πŸ† AWS AI Agent Hackathon Entry: Multi-agent HDB advisor using Amazon Bedrock AgentCore, Nova Lite, and intelligent cost optimization. Find your perfect Singapore home with AI.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published