Ether Data Documentation

Comprehensive documentation for the Ether Data spatio-temporal data workspace

View the Project on GitHub

Ether API Gateway

A unified API gateway that combines all microservices into a single entry point.

Overview

The API Gateway serves as the single point of entry for all client requests, routing them to the appropriate microservices. It provides:

Architecture

Gateway Architecture

The API Gateway serves as a unified entry point that routes client requests to specialized microservices, each connected to their respective data sources and featuring unique capabilities.

Service Overview

πŸ“Š Census API (/census)

πŸ—ΊοΈ Overture API (/overture)

🚦 TomTom Flow API (/tomtom-flow)

Key Benefits

Quick Start

Local Development

# Run the gateway locally (from workspace root)
./proj/apis/gateway/run-local.sh

# This will:
# - Navigate to workspace root automatically
# - Use uv to manage dependencies and virtual environment
# - Run the gateway server with proper workspace setup

Cloud Deployment

# Deploy to Google Cloud Run
./proj/apis/gateway/deployment/deploy.sh your-project-id us-central1

Access Points

Local Development:

Production (after deployment):

Gateway Endpoints

Service Discovery

Health Monitoring

Root

Configuration

The gateway can be configured via environment variables:

# Gateway settings
GATEWAY_HOST                    # Production host
GATEWAY_PORT=8000               # Port to run on
ENVIRONMENT=development         # Environment (development/staging/production)

# Service discovery
ENABLE_SERVICE_DISCOVERY=true  # Enable service discovery

# Health checks
HEALTH_CHECK_INTERVAL=30       # Health check interval (seconds)

# CORS
CORS_ORIGINS=["*"]             # Allowed origins

# Rate limiting (future)
RATE_LIMIT_REQUESTS=100        # Requests per minute

Adding New APIs

To add a new microservice to the gateway:

  1. Add dependency in pyproject.toml:
    dependencies = [
        # ... existing deps
        "your-new-api",
    ]
       
    [tool.uv.sources]
    your-new-api = { workspace = true }
    
  2. Import and mount in main.py:
    from your_new_api.main import app as new_api_app
       
    # Mount the new API
    app.mount("/new-api", new_api_app)
    
  3. Update service registry in routes/discovery.py:
    services = {
        # ... existing services
        "new-api": ServiceInfo(
            name="new-api",
            version="1.0.0",
            description="Description of new API",
            base_path="/new-api",
            docs_url="/new-api/docs",
            health_url="/health/new-api",
            endpoints=[
                # Define endpoints...
            ]
        )
    }
    
  4. Add health check in routes/health.py:
    services_to_check = {
        # ... existing services
        "new-api": "/new-api/health"
    }
    

Middleware

The gateway includes several middleware components:

CORS Middleware

Request Logging Middleware

Development

Running in Development

# Using the local run script (recommended)
./proj/apis/gateway/run-local.sh

# Alternative - direct execution with hot reload
ENVIRONMENT=development uv run --directory proj/apis/gateway python -m gateway.server

Testing

# Run tests
cd proj/apis/gateway
uv run pytest

Cloud Run Deployment

Architecture

Deployment Process

  1. Build container using Cloud Build
  2. Push to Container Registry
  3. Deploy to Cloud Run with production configuration
  4. Verify deployment with automated health checks

Configuration

Environment variables set for production deployment:

Monitoring

View logs and metrics:

# View recent logs
gcloud logging read 'resource.type="cloud_run_revision" AND resource.labels.service_name="ether-gateway"' --limit=50

# Get service status
gcloud run services describe ether-gateway --region=us-central1

API Documentation

The gateway provides unified OpenAPI documentation at /docs.