Skip to content

learnsol/HomeBuyerAgent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

39 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ADK Home Buyer - Production-Ready Multi-Agent Real Estate Application

A production-ready multi-agent home buying application built using the Google Agent Development Kit (ADK) framework. This cloud-native application demonstrates advanced agent orchestration, intelligent property analysis, and modern web interfaces using Google Cloud services.

🎯 Overview

This application provides an intelligent home buying assistant that coordinates 5 specialized AI agents to help users find, analyze, and get personalized property recommendations. The system processes real estate data, performs semantic search, and provides comprehensive property analysis through a modern React web interface.

✨ Key Features

  • 🏠 Intelligent Property Discovery: Vector-based semantic search using Vertex AI embeddings
  • πŸ€– Multi-Agent Analysis: 5 specialized agents providing comprehensive property evaluation
  • πŸ“Š Real-time Data: Live BigQuery integration with property listings and neighborhood data
  • 🎯 Personalized Recommendations: User priority-based scoring with detailed explanations
  • ☁️ Cloud-Native: Fully deployed on Google Cloud Run with auto-scaling and high availability
  • πŸ“± Modern Interface: React-based responsive web application with Ant Design
  • πŸ“ˆ Persistent History: Firestore-backed query tracking for analytics and debugging
  • πŸ” Smart Filtering: Advanced criteria matching with fallback recommendations

πŸ—οΈ Production Architecture

React Frontend (Cloud Run) β†’ API Gateway β†’ Backend API (Cloud Run)
                                             ↓
                           ADK Orchestrator β†’ Specialized Agents
                                             ↓
        BigQuery (Properties) + Firestore (History) + Vertex AI (LLMs)

Agent Workflow:

User Request β†’ 
  πŸ“‹ Listing Discovery (Vector Search + Filtering) β†’
  πŸ”„ Parallel Analysis:
    🏘️ Neighborhood Analysis (Demographics, Schools)
    ⚠️ Risk Assessment (Natural disasters, Safety)
    πŸ’° Affordability Calculation (DTI, Monthly costs)
  β†’ 🎯 Personalized Recommendations (Priority-based scoring)
β†’ πŸ“Š Ranked Results with AI-generated Explanations

πŸ“ Project Structure

c:\github\ADKAgent\
β”œβ”€β”€ agents/                      # Specialized agent implementations
β”‚   β”œβ”€β”€ base_agent.py           # Base agent class with ADK patterns
β”‚   β”œβ”€β”€ listing_review_agent.py # Vector search and property filtering
β”‚   β”œβ”€β”€ locality_review_agent.py # Neighborhood and school analysis
β”‚   β”œβ”€β”€ hazard_analysis_agent.py # Risk assessment and safety scoring
β”‚   β”œβ”€β”€ affordability_agent.py  # Financial analysis and DTI calculations
β”‚   β”œβ”€β”€ recommendation_agent.py # Personalized scoring and ranking
β”‚   β”œβ”€β”€ agent_utils.py          # Shared utilities (BigQuery, logging)
β”‚   └── vector_search_utils.py  # Vector embeddings and semantic search
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ settings.py             # Production configuration management
β”‚   β”œβ”€β”€ cloud_run_settings.py   # Cloud Run specific configurations
β”‚   └── affordability_params.json # Financial calculation parameters
β”œβ”€β”€ frontend/                    # Modern React web application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/         # React components
β”‚   β”‚   β”‚   β”œβ”€β”€ SearchForm.js   # Enhanced property search form
β”‚   β”‚   β”‚   β”œβ”€β”€ ProgressTracker.js # Real-time analysis progress
β”‚   β”‚   β”‚   └── RecommendationResults.js # Beautiful results display
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   └── api.js          # Backend API client
β”‚   β”‚   β”œβ”€β”€ App.js              # Main React application with modern UI
β”‚   β”‚   └── index.js            # React entry point
β”‚   β”œβ”€β”€ public/                 # Static assets and PWA configuration
β”‚   β”œβ”€β”€ package.json            # Node.js dependencies
β”‚   β”œβ”€β”€ Dockerfile             # Frontend container for Cloud Run
β”‚   └── .dockerignore          # Docker build optimization
β”œβ”€β”€ deploy/                     # Production deployment configurations
β”‚   β”œβ”€β”€ deploy_cloud_run.sh    # Linux/Mac Cloud Run deployment
β”‚   β”œβ”€β”€ deploy_cloud_run.ps1   # Windows PowerShell Cloud Run deployment
β”‚   └── deployment_architecture.md # Cloud architecture documentation
β”œβ”€β”€ docs/                       # Comprehensive documentation
β”‚   β”œβ”€β”€ deployment_checklist.md # Production deployment guide
β”‚   └── api_documentation.md    # API endpoint documentation
β”œβ”€β”€ orchestrator_adk.py         # Production ADK orchestrator
β”œβ”€β”€ api_server.py              # Flask API server with Cloud Run optimization
β”œβ”€β”€ query_history_cloud.py     # Cloud-native query history (Firestore)
β”œβ”€β”€ main.py                    # CLI application entry point
β”œβ”€β”€ Dockerfile                 # Backend container for Cloud Run
β”œβ”€β”€ .dockerignore             # Container build optimization
β”œβ”€β”€ requirements-production.txt # Minimal production dependencies
β”œβ”€β”€ .gitignore                # Comprehensive security exclusions
└── README.md                 # This documentation

🌐 Frontend Application

✨ Modern React Interface

The project includes a production-ready React frontend with professional UI/UX:

  • 🎨 Modern Design: Glass morphism effects with Ant Design components
  • πŸ” Intelligent Search: Comprehensive form with financial criteria and user priorities
  • πŸ“Š Real-time Progress: Visual tracking of AI agents working in parallel
  • 🏠 Beautiful Results: Professional property cards with detailed analysis
  • πŸ“± Responsive Design: Optimized for desktop, tablet, and mobile
  • ⚑ Performance Optimized: Code splitting, lazy loading, and PWA features
  • β™Ώ Accessible: WCAG AA compliant design with proper contrast and navigation

πŸ—οΈ Full-Stack Architecture

React Frontend (Cloud Run) β†’ Load Balancer β†’ Flask API (Cloud Run)
     ↓                           ↓                    ↓
  Modern UI/UX             β†’ REST API          β†’ ADK Orchestrator
     ↓                           ↓                    ↓
  User Experience         β†’ JSON Responses    β†’ Multi-Agent Analysis

πŸš€ Quick Development Setup

  1. Prerequisites:

    # Ensure you have the required tools
    node --version  # v16+ required
    python --version  # 3.8+ required
    gcloud --version  # Latest Google Cloud SDK
  2. Environment Setup:

    # Clone and setup virtual environment
    git clone <repository-url>
    cd ADKAgent
    python -m venv venv
    venv\Scripts\activate  # Windows
    # source venv/bin/activate  # Linux/Mac
    
    # Install dependencies
    pip install -r requirements-production.txt
  3. Configure Environment Variables:

    # Copy template and update with your credentials
    cp .env.example .env
    # Edit .env with your Google Cloud project details
  4. Start Development Servers:

    # Terminal 1: Backend API
    python api_server.py
    
    # Terminal 2: Frontend Development Server
    cd frontend
    npm install
    npm start
  5. Access Application:

☁️ Production Deployment

One-Click Cloud Run Deployment

Deploy both frontend and backend to Google Cloud Run:

Windows PowerShell:

# Set your project ID
$env:GOOGLE_CLOUD_PROJECT = "your-project-id"

# Deploy to Cloud Run
.\deploy\deploy_cloud_run.ps1

Linux/Mac Bash:

# Set your project ID  
export GOOGLE_CLOUD_PROJECT="your-project-id"

# Deploy to Cloud Run
./deploy/deploy_cloud_run.sh

Deployment Features

The deployment script automatically:

  • βœ… Builds optimized containers for both frontend and backend
  • βœ… Configures environment variables for production
  • βœ… Sets up auto-scaling with cost optimization
  • βœ… Enables health checks and monitoring
  • βœ… Configures CORS for cross-origin requests
  • βœ… Provides deployment URLs for immediate access

Production Environment Variables

# Required for Cloud Run deployment
GOOGLE_CLOUD_PROJECT=your-project-id
QUERY_HISTORY_BACKEND=firestore
BIGQUERY_PROJECT_ID=your-project-id
BIGQUERY_DATASET_ID=your-dataset-name
VERTEX_AI_PROJECT_ID=your-project-id

✨ Key Features

πŸ” Enhanced Vector Search

  • Semantic Understanding: Vertex AI text-embedding-004 with 768-dimensional embeddings
  • Smart Discovery: Finds up to 15 relevant listings with intelligent filtering
  • Real-time Processing: Sub-second similarity matching with BigQuery integration
  • Criteria Matching: Combines semantic similarity with hard constraints (bedrooms, price, etc.)

πŸ€– Production Multi-Agent System

  • ADK Framework: Built on Google's official Agent Development Kit
  • Parallel Processing: Concurrent analysis using ParallelAgent patterns
  • Specialized Intelligence: Domain-specific agents with focused expertise
  • Fault Tolerance: Robust error handling and graceful degradation

πŸ’° Comprehensive Financial Analysis

  • Advanced Calculations: Monthly payments, property taxes, insurance, HOA fees
  • Affordability Assessment: Debt-to-income ratios with industry standards
  • Market Intelligence: Property value evaluation and investment insights
  • Scenario Analysis: Multiple financing option comparisons

⚠️ Risk Assessment Intelligence

  • Multi-Hazard Analysis: Wildfire, flood, earthquake, and crime risk evaluation
  • Official Data Sources: FEMA flood zones, USGS geological data
  • Insurance Impact: Risk-based insurance cost estimates
  • Safety Scoring: Neighborhood safety analysis with multiple data sources

🎯 AI-Powered Recommendations

  • Personalized Scoring: User priority-based ranking algorithm
  • Detailed Explanations: AI-generated summaries explaining recommendations
  • Fallback Logic: Provides alternatives when no "perfect" matches exist
  • Investment Analysis: Long-term value and market trend insights

πŸ“Š Query History & Analytics

Cloud-Native History Tracking

The application includes production-ready query history using Firestore:

  • Persistent Storage: All user queries stored in Firestore database
  • Performance Analytics: Query response times and success rates
  • User Behavior Insights: Search patterns and preference analysis
  • Debugging Support: Detailed query logs for troubleshooting
  • Scalable Architecture: Auto-scaling storage with Google Cloud

History API Endpoints

# View recent query history
GET /api/history

# Get query analytics
GET /api/history/analytics

# Search query history
GET /api/history/search?criteria=<search_terms>

πŸ”§ Advanced Configuration

Production Settings

Key configuration in config/settings.py:

# AI Model Configuration
DEFAULT_AGENT_MODEL = "gemini-2.0-flash-001"  # Latest Gemini model
ORCHESTRATOR_MODEL = "gemini-2.0-flash-001"   # Optimized for coordination

# Search Optimization
VECTOR_SEARCH_LIMIT = 15                       # Enhanced discovery
FINAL_RECOMMENDATION_COUNT = 3                 # Focused results

# Cloud Run Optimization  
REQUEST_TIMEOUT = 300                          # Extended for AI processing
MAX_CONCURRENT_REQUESTS = 80                   # High throughput

Environment-Specific Configuration

# Development
QUERY_HISTORY_BACKEND = "local"  # JSON file storage

# Production  
QUERY_HISTORY_BACKEND = "firestore"  # Cloud-native storage

# Testing
QUERY_HISTORY_BACKEND = "memory"  # In-memory only

πŸ§ͺ Testing & Quality Assurance

Comprehensive Test Coverage

The system includes extensive testing:

# Run all tests
python -m pytest tests/

# Run specific test suites
python test_agents.py          # Individual agent testing
python test_orchestrator.py    # Workflow testing  
python test_vector_search.py   # Search functionality
python test_api_endpoints.py   # API testing

Production Validation

Before deployment, run the validation suite:

# Validate Google Cloud connectivity
python validate_cloud_setup.py

# Test end-to-end workflow
python validate_production_ready.py

# Performance benchmarking
python benchmark_performance.py

πŸ“ˆ Performance & Scalability

Production Metrics

  • Response Time: < 30 seconds for complete analysis
  • Throughput: 80+ concurrent requests supported
  • Availability: 99.9% uptime with Cloud Run auto-scaling
  • Cost Optimization: Pay-per-request with automatic scaling to zero

Optimization Features

  • Container Optimization: Multi-stage Docker builds for minimal image size
  • Memory Management: Efficient resource allocation (2GB RAM, 1 CPU)
  • Caching Strategy: Intelligent caching of vector embeddings and BigQuery results
  • Auto-Scaling: Scales from 0 to 10 instances based on demand

πŸ” Security & Compliance

Production Security Features

  • Environment Isolation: Secure credential management with Cloud Run
  • HTTPS Enforcement: All traffic encrypted with automatic SSL certificates
  • CORS Configuration: Properly configured cross-origin resource sharing
  • Input Validation: Comprehensive request validation and sanitization
  • Error Handling: Secure error responses without sensitive information exposure

Data Privacy

  • Query Anonymization: Personal financial data not stored permanently
  • Secure Transmission: All API calls encrypted in transit
  • Access Controls: Cloud IAM integration for fine-grained permissions
  • Audit Logging: Comprehensive request logging for security monitoring

πŸ”§ Development & Extension

Adding New Agents

Follow ADK patterns to extend the system:

from google.adk.agents import LlmAgent
from google.adk.tools import FunctionTool

# Create new agent following ADK patterns
new_agent = LlmAgent(
    name="NewAnalysisAgent",
    instructions="Analyze property for specific criteria...",
    model_name=DEFAULT_AGENT_MODEL,
    tools=[
        FunctionTool(analyze_new_criteria, description="Analysis function")
    ],
    input_schema=NewAgentInput,
    output_key="new_analysis"
)

Extending the Orchestrator

# Add to parallel analysis workflow
parallel_analysis_agent = ParallelAgent(
    name="ParallelAnalysisAgent", 
    sub_agents=[
        locality_agent,
        hazard_agent, 
        affordability_agent,
        new_agent  # Your new agent
    ]
)

API Development

Add new endpoints following Flask patterns:

@app.route('/api/new-feature', methods=['POST'])
def new_feature():
    """New API endpoint with proper error handling"""
    try:
        # Implementation
        return jsonify({"status": "success", "data": result})
    except Exception as e:
        logger.error(f"New feature error: {e}")
        return jsonify({"error": "Processing failed"}), 500

πŸ“– Documentation

Complete Documentation Suite

ADK Framework Integration

This application demonstrates advanced ADK patterns:

  • Sequential Pipeline: SequentialAgent for workflow coordination
  • Parallel Fan-Out/Gather: ParallelAgent for concurrent analysis
  • Function Tools: FunctionTool for external system integration
  • Session Management: Shared state across agent interactions
  • Error Handling: Robust exception management and recovery

πŸš€ Getting Started

Quick Start Options

Option 1: Local Development

git clone <repository>
cd ADKAgent
python -m venv venv && venv\Scripts\activate
pip install -r requirements-production.txt
cp .env.example .env  # Update with your credentials
python api_server.py

Option 2: Cloud Run Deployment

export GOOGLE_CLOUD_PROJECT="your-project-id"
./deploy/deploy_cloud_run.sh

Option 3: Docker Development

docker-compose up --build

Next Steps

  1. Configure Google Cloud: Set up BigQuery, Firestore, and Vertex AI
  2. Deploy Infrastructure: Use provided deployment scripts
  3. Customize Agents: Modify agent logic for your specific use case
  4. Extend Frontend: Add new UI components and features
  5. Monitor Performance: Set up Cloud Monitoring and alerting

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

🀝 Contributing

Contributions are welcome! Please see our Contributing Guide for details on:

  • Code standards and ADK patterns
  • Testing requirements
  • Documentation guidelines
  • Pull request process

πŸ™ Acknowledgments

  • Google Agent Development Kit (ADK): Official framework powering the multi-agent architecture
  • Google Cloud Platform: Infrastructure and AI services
  • React & Ant Design: Modern frontend framework and components
  • Open Source Community: Various libraries and tools that make this project possible

Project Status: βœ… Production Ready | Last Updated: January 2025 | Version: 2.0.0

Built with ❀️ using Google ADK framework for intelligent real estate analysis

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors