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

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors