Production-grade data engineering patterns and architecture blueprints for Google Cloud Platform (GCP) and Snowflake. Includes idempotent BigQuery pipelines, LLMOps gateways, multimodal OCR extraction, and high-throughput Playwright web scrapers.
graph LR
subgraph Ingestion [Ingestion & Extraction Layer]
A[Playwright Scrapers] --> B[GCS Raw Bucket]
C[REST APIs / Webhooks] --> D[Google Cloud Pub/Sub]
E[Scanned Invoices / PDFs] --> B
end
subgraph Processing [DataOps & Validation]
B --> F[Cloud Run Jobs]
D --> F
F --> G[Pydantic v2 Contract Validation]
F --> H[Gemini 1.5 Multimodal OCR]
end
subgraph Storage [Analytical Lakehouse]
G --> I[(BigQuery Partitioned & Clustered Tables)]
I --> J[(Snowflake DWH)]
end
subgraph Serving [AI & BI Serving Layer]
I --> K[LiteLLM API Gateway]
I --> L[NL-to-SQL Copilot]
I --> M[Connected Sheets / BI Dashboards]
end
Physical DDL defining date partitioning, multi-column clustering, and schema contracts to minimize scan costs and guarantee deterministic re-runs.
-- Partitioned by day with multi-column clustering for sub-second query pruning
CREATE OR REPLACE TABLE `enterprise_analytics.fct_ad_intelligence_daily`
(
ad_fingerprint STRING NOT NULL,
brand_id STRING NOT NULL,
creative_url STRING,
vision_taxonomy STRUCT<
category STRING,
sentiment STRING,
confidence FLOAT64
>,
spend_estimate NUMERIC,
captured_at TIMESTAMP NOT NULL,
ingested_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
)
PARTITION BY DATE(captured_at)
CLUSTER BY brand_id, ad_fingerprint
OPTIONS (
description = "Idempotent ad intelligence facts with partition pruning and scan controls",
require_partition_filter = true
);MERGE INTO `enterprise_analytics.fct_ad_intelligence_daily` T
USING `staging.stg_ad_events_batch` S
ON T.captured_at = S.captured_at
AND T.brand_id = S.brand_id
AND T.ad_fingerprint = S.ad_fingerprint
WHEN MATCHED THEN
UPDATE SET
vision_taxonomy = S.vision_taxonomy,
spend_estimate = S.spend_estimate,
ingested_at = CURRENT_TIMESTAMP()
WHEN NOT MATCHED THEN
INSERT (ad_fingerprint, brand_id, creative_url, vision_taxonomy, spend_estimate, captured_at)
VALUES (S.ad_fingerprint, S.brand_id, S.creative_url, S.vision_taxonomy, S.spend_estimate, S.captured_at);Strict upstream validation prevents corrupted records from contaminating analytical datasets.
from pydantic import BaseModel, Field, HttpUrl
from datetime import datetime
from typing import Optional
class VisionTaxonomyContract(BaseModel):
category: str = Field(..., min_length=2, max_length=50)
sentiment: str = Field(..., pattern="^(positive|neutral|negative)$")
confidence: float = Field(..., ge=0.0, le=1.0)
class IngestedAdPayload(BaseModel):
ad_fingerprint: str = Field(..., min_length=16, max_length=64)
brand_id: str
creative_url: Optional[HttpUrl] = None
vision_taxonomy: VisionTaxonomyContract
spend_estimate: Optional[float] = Field(None, ge=0.0)
captured_at: datetime
class Config:
frozen = True
extra = "forbid"Centralized proxy managing multi-provider routing (Gemini, Claude, GPT-4o), virtual API keys, team-level token quotas, and asynchronous FinOps telemetry streaming to BigQuery.
# litellm_config.yaml
model_list:
- model_name: enterprise-fast
litellm_params:
model: vertex_ai/gemini-1.5-flash
budget_duration: 30d
- model_name: enterprise-reasoning
litellm_params:
model: vertex_ai/gemini-1.5-pro
budget_duration: 30d- Storage & DWH: Google BigQuery, Snowflake, PostgreSQL, Google Cloud Storage (GCS)
- Processing & Streaming: Python 3.11, Google Cloud Pub/Sub, Eventarc, Cloud Run Jobs, FastAPI, PyArrow
- AI & LLMOps: Vertex AI, Gemini 1.5 Pro/Flash, LiteLLM, Pydantic v2
- Web Scraping & Automation: Playwright (Headless Chromium), Docker
Patrones de ingeniería de datos y esquemas de arquitectura para Google Cloud Platform (GCP) y Snowflake. Incluye pipelines idempotentes en BigQuery, gateways de LLMOps, extracción OCR multimodal y scrapers con Playwright.
graph LR
subgraph Ingesta [Capa de Ingesta y Extracción]
A[Scrapers Playwright] --> B[Bucket GCS Raw]
C[APIs REST / Webhooks] --> D[Google Cloud Pub/Sub]
E[Facturas Escaneadas / PDFs] --> B
end
subgraph Procesamiento [DataOps y Validación]
B --> F[Cloud Run Jobs]
D --> F
F --> G[Validación de Contratos Pydantic]
F --> H[OCR Multimodal Gemini 1.5]
end
subgraph Almacenamiento [Lakehouse Analítico]
G --> I[(Tablas Particionadas BigQuery)]
I --> J[(Data Warehouse Snowflake)]
end
subgraph Consumo [Capa de Servido y Analítica]
I --> K[Gateway LiteLLM]
I --> L[Copiloto NL-to-SQL]
I --> M[Connected Sheets / Dashboards]
end
DDL físico con particionamiento por fecha y clustering multicolumna para minimizar costos de escaneo y garantizar reejecuciones deterministas.
CREATE OR REPLACE TABLE `enterprise_analytics.fct_ad_intelligence_daily`
(
ad_fingerprint STRING NOT NULL,
brand_id STRING NOT NULL,
creative_url STRING,
vision_taxonomy STRUCT<
category STRING,
sentiment STRING,
confidence FLOAT64
>,
spend_estimate NUMERIC,
captured_at TIMESTAMP NOT NULL,
ingested_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP()
)
PARTITION BY DATE(captured_at)
CLUSTER BY brand_id, ad_fingerprint
OPTIONS (
description = "Hechos de inteligencia publicitaria con poda de particiones",
require_partition_filter = true
);La validación previa en la capa de ingesta asegura que registros corruptos nunca lleguen a las tablas analíticas finales.
Proxy centralizado para balanceo multi-modelo (Gemini, Claude, OpenAI), gestión de cuotas de tokens por equipo y telemetría de costos en BigQuery.
- Almacenamiento y DWH: Google BigQuery, Snowflake, PostgreSQL, Google Cloud Storage (GCS)
- Procesamiento y Streaming: Python 3.11, Google Cloud Pub/Sub, Eventarc, Cloud Run Jobs, FastAPI, PyArrow
- IA y LLMOps: Vertex AI, Gemini 1.5 Pro/Flash, LiteLLM, Pydantic v2
- Automatización y Web Scraping: Playwright, Docker