Skip to content

kupp0/multi-db-property-search-data-agents

Repository files navigation

Unified Data Cloud Property Search Demo

The Unified Data Cloud Property Search Demo showcases a Natural Language to SQL (NL2SQL) application powered by the Gemini Data Agent. It enables users to search for property listings using everyday language (e.g., "Show me 2-bedroom apartments in Zurich under 3000 CHF"). The application translates these natural language queries into SQL and executes them across four different database backends—AlloyDB, Spanner, Cloud SQL for PostgreSQL, and Cloud SQL for MySQL—allowing users to seamlessly compare performance, vector search capabilities, and SQL dialects across Google Cloud's premier database offerings.

The application features two primary modalities:

  1. Main UI (Search Bar): Directly interacts with the QueryData API (Gemini Data Analytics API) for fast, direct natural language to SQL translation.
  2. CHAT Interface: Interacts with a conversational Agent connected to the QueryData API endpoint via the ADK / MCP Toolkit, allowing for follow-up questions and refined searches.

⚠️ Note: This is my personal work and is not an official Google Cloud product. It is a demonstration of GCP features and is not meant for production use. Use at your own risk.

Architecture

Architecture Diagram

  • Frontend: React application (Vite) with a modern UI and a 4-way toggle to switch between database backends.
  • Backend: FastAPI (Python) service that proxies requests to the Gemini Data Agent API, logs prompt history to the active database, and serves images securely from Google Cloud Storage.
  • ADK Chat Agent: A dynamic "Single Agent" architecture that instantiates on-the-fly with the specific MCP tool for the selected database.
  • Databases:
    • AlloyDB: PostgreSQL-compatible database using pgvector and ScaNN indexes.
    • Cloud Spanner: Globally distributed database using Google Standard SQL and exact vector search.
    • Cloud SQL for PostgreSQL: Fully managed PostgreSQL using pgvector and HNSW/IVFFlat indexes.
    • Cloud SQL for MySQL: Fully managed MySQL database using inline ml_embedding models with exact KNN vector search.

Features

  • Dual Modalities: The main UI features a search bar that directly interacts with the QueryData API (Gemini Data Analytics API). Alternatively, users can use the CHAT interface, which interacts with an Agent connected to the QueryData API endpoint via the ADK / MCP Toolkit.
  • Multi-Database Support: Seamlessly switch between AlloyDB, Spanner, Cloud SQL PG, and Cloud SQL MySQL to compare performance and SQL dialects.
  • Natural Language Search: Ask questions like "Show me 2-bedroom apartments in Zurich under 3000 CHF".
  • Generative AI Answers: Get natural language summaries alongside data results.
  • Conversational Agent: Interact with the ADK Chat Agent for follow-up questions and refined searches.
  • Secure Image Serving: Images are served securely from a private GCS bucket via the backend.

Prerequisites

  • Google Cloud Project with billing enabled.
  • AlloyDB Cluster, Cloud Spanner Instance, Cloud SQL PG Instance, and Cloud SQL MySQL Instance.
  • Gemini Data Agent configured with all four databases as data sources.
  • Google Cloud Storage bucket for images.

Local Development & Setup

1. Configure Environment

Run the setup script to configure your environment variables (Project ID, Database IDs, Credentials, and Context Set IDs):

./scripts/setup_env.sh

2. Database Initialization & Data Loading

The project includes an automated script to deploy the schemas and load the sample data (with embeddings) into all four databases via an IAP SSH tunnel to a Bastion Host.

./scripts/install_databases.sh

3. Pre-populating Demo Mode Cache (Optional)

The application features a Demo Mode to mimic GDA API responses with zero API latency during presentations. To pre-populate the Google Cloud Storage cache bucket with the raw Gemini Data Agent responses for all four database backends and sample queries, run:

./scripts/auxiliary/generate_all_demo_files.sh

Note: This requires active Google Cloud credentials and live GDA API access. Once the files are generated on GCS, you can run the application with "Demo Mode" enabled, which avoids calling the live GDA API.

4. Start Services Locally

Run the local debug script to build and start the Backend, Frontend, Toolbox (MCP Server), and Agent containers:

./scripts/debug_local.sh

Deployment

To deploy the Frontend and Backend to Google Cloud Run:

./scripts/deploy.sh

Project Structure

  • backend/: FastAPI application and ADK Agent service.
  • frontend/: React application.
  • database_artefacts/: DDL scripts, data generation, and context files.
  • scripts/: Automation scripts for setup, deployment, and local debugging.
  • terraform/: Infrastructure as Code to provision the databases and Bastion Host.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors