Saltar a contenido

Arquitectura de Referencia — Plataforma Big Data + IA 2026

1. Vista C4 — Nivel 1 (System Context)

                        ┌─────────────────────────────────────────────┐
                        │            Plataforma de Datos              │
                        │  Lakehouse Iceberg + IA + Self-Service      │
                        └────────┬──────────────────────────┬─────────┘
                                 │                          │
   ┌──────────────┐  fuentes     │                          │  consumo
   │  Operacional │ ───────────► │                          │ ───────────► ┌───────────────┐
   │ (Postgres,   │              │                          │              │  Analistas /  │
   │  MongoDB,    │              │                          │              │  BI / NLQ     │
   │  Kafka topics)│             │                          │              └───────────────┘
   └──────────────┘              │                          │
                                 │                          │
   ┌──────────────┐              │                          │              ┌───────────────┐
   │  SaaS        │ ───────────► │                          │ ───────────► │  Data Science │
   │ (Stripe,     │              │                          │              │  ML / RAG     │
   │  HubSpot,    │              │                          │              └───────────────┘
   │  Salesforce) │              │                          │
   └──────────────┘              │                          │
                                 │                          │              ┌───────────────┐
   ┌──────────────┐              │                          │ ───────────► │  Apps / APIs  │
   │  IoT / Logs  │ ───────────► │                          │              │  (reverse ETL,│
   │  / Streams   │              │                          │              │  agentes IA)  │
   └──────────────┘              └──────────────────────────┘              └───────────────┘
                            ┌───────────────────────────────────────────────────────┘
                  ┌──────────────────────┐
                  │   Gobernanza, FinOps,│
                  │   Catálogo, Lineage  │
                  │   (DataHub, Atlan)   │
                  └──────────────────────┘

2. Vista C4 — Nivel 2 (Container)

┌─────────────────────────────────────────────────────────────────────────────────┐
│                              INGESTA & STREAMING                                │
├─────────────────────────────────────────────────────────────────────────────────┤
│  Fivetran/Airbyte (SaaS)    Debezium → Kafka (CDC)    Custom Python (APIs)      │
│  AWS DMS / Estuary Flow     Schema Registry           IoT / SFTP / Files        │
└────────────────────────────────────┬────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────┐
│                            STORAGE (LAKEHOUSE)                                  │
│         ┌─────────────────────────────────────────────────────────────┐         │
│         │  Object Storage: S3 / GCS / ADLS / MinIO                    │         │
│         │  Formato archivo: Parquet (Zstd)                            │         │
│         │  Formato tabla:   Apache Iceberg v3                         │         │
│         │  Layout:                                                    │         │
│         │    /bronze/{source}/{table}/   ← raw + minimal cast         │         │
│         │    /silver/{domain}/{table}/   ← cleaned, deduped           │         │
│         │    /gold/{product}/{table}/    ← contractual, modelado      │         │
│         └─────────────────────────────────────────────────────────────┘         │
│                              ▲                              ▲                    │
│                              │                              │                    │
│         ┌────────────────────┴────┐         ┌───────────────┴─────────┐        │
│         │   Catálogo Iceberg REST │◄────────┤  Active Metadata        │        │
│         │   (Polaris / Unity)     │ sync    │  (DataHub / Atlan)      │        │
│         └─────────────────────────┘         └─────────────────────────┘        │
└─────────────────────────────────────────────────────────────────────────────────┘
                              ▲              ▲              ▲
                              │              │              │
                              │  (todos consumen mismo catálogo)
                              │              │              │
┌─────────────────────────────────────────────────────────────────────────────────┐
│                                CÓMPUTO                                           │
│   ┌──────────────┐    ┌──────────────┐    ┌──────────────┐    ┌─────────────┐   │
│   │  Spark 4.0   │    │   Trino      │    │   Flink      │    │  Warehouse  │   │
│   │  (ETL batch) │    │  (federated  │    │  (streaming) │    │  Snowflake/ │   │
│   │              │    │   query)     │    │              │    │  BigQuery / │   │
│   └──────────────┘    └──────────────┘    └──────────────┘    │  Databricks │   │
│                                                                └─────────────┘   │
└─────────────────────────────────────────────────────────────────────────────────┘
                                     │  (transformaciones declarativas)
                       ┌─────────────┴──────────────┐
                       │       dbt + SQLMesh         │
                       │   (medallion bronze/silver/ │
                       │    gold, contratos, tests)  │
                       └─────────────┬──────────────┘
                       ┌─────────────────────────────┐
                       │   Capa Semántica            │
                       │   (dbt Semantic / Cube)     │
                       └─────────────────────────────┘
┌────────────────────────────────────┴────────────────────────────────────────────┐
│                                CONSUMO                                           │
│   ┌──────────────┐  ┌──────────────┐  ┌──────────────┐  ┌──────────────────┐   │
│   │  Power BI    │  │   Looker     │  │  ThoughtSpot │  │  Hex / Streamlit │   │
│   │  Tableau     │  │   Hex        │  │   NLQ        │  │  (notebooks BI)  │   │
│   └──────────────┘  └──────────────┘  └──────────────┘  └──────────────────┘   │
│                                                                                  │
│   ┌──────────────────────────────────────────────────────────────────────────┐ │
│   │              ML / AI Layer                                                │ │
│   │   ┌─────────┐  ┌──────────────┐  ┌─────────────┐  ┌───────────────────┐ │ │
│   │   │ MLflow  │  │ Feature Store│  │ Vector DB   │  │  LLM / RAG /      │ │ │
│   │   │ + BentoML│ │ (Feast/Tecton)│ │(pgvector/   │  │  Agents (LangChain│ │ │
│   │   │ + Triton │ │              │ │ Qdrant/Pine)│  │  / DSPy / MCP)   │ │ │
│   │   └─────────┘  └──────────────┘  └─────────────┘  └───────────────────┘ │ │
│   └──────────────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────────────────────────┐
│            ORQUESTACIÓN + OBSERVABILIDAD + GOBERNANZA (transversal)             │
│   Airflow / Dagster    Monte Carlo / Soda    Data Contracts    Lineage          │
│                        Acceldata / Bigeye    (YAML + CI)       (OpenLineage)    │
└─────────────────────────────────────────────────────────────────────────────────┘

3. Patrón Medallion

┌──────────────────────┐    ┌──────────────────────┐    ┌──────────────────────┐
│       BRONZE         │    │       SILVER         │    │        GOLD          │
│  (raw landing)       │    │  (cleaned, conformed)│    │  (modeled, business) │
├──────────────────────┤    ├──────────────────────┤    ├──────────────────────┤
│ • Schema-on-read     │    │ • Dedupe             │    │ • Star/Snowflake     │
│ • Append-only        │    │ • Conform types      │    │ • SCD2 snapshots     │
│ • Audit columns      │ ──►│ • Validate PK/FK     │ ──►│ • Aggregations       │
│   (_ingested_at,     │    │ • Business filters   │    │ • Metrics, KPIs      │
│    _source_file)     │    │ • PII redaction      │    │ • Contracts + SLAs   │
│ • Schema evolution   │    │ • Quality tests      │    │ • Owned by domain    │
│   automática         │    │ • Slowly Changing    │    │ • Consumido por BI/ML│
└──────────────────────┘    └──────────────────────┘    └──────────────────────┘
   Retention: 30-90d         Retention: 1-3 años         Retention: indefinida
   Owner: data platform      Owner: domain team           Owner: domain team
   Tests: schema only        Tests: dbt + GE              Tests: contract + GE

4. Flujo CDC + Streaming → Lakehouse

   Postgres (OLTP)
        │ logical replication (wal2json)
   Debezium Connector
        │ Avro + Schema Registry
   Kafka topic: <db>.<schema>.<table>
        │           │
        │           └───────────┐
        │                       ▼
        │                  Flink job (real-time enrichment)
        │                       │
        │                       │ writes every 30s
        │                       ▼
        │                  Iceberg Bronze (Flink Iceberg sink)
        │                       │
        │                       ▼
        │                  Compaction job (hourly)
   Spark Structured Streaming (batch micro)
        │ MERGE INTO Silver every 5min
   Iceberg Silver
   dbt incremental (every 15min)
   Iceberg Gold (contract-verified)
   Trino / Snowflake / BI / Feature Store

5. Stack ML/AI

                ┌─────────────────────────────────────────────┐
                │           Datos Gold (Iceberg)               │
                └─────────────────────┬───────────────────────┘
            ┌─────────────────────────┼─────────────────────────┐
            ▼                         ▼                         ▼
   ┌────────────────┐        ┌────────────────┐        ┌────────────────┐
   │ Feature Store  │        │  Embedding     │        │  Training Data │
   │ (Feast/Tecton) │        │  Pipeline      │        │  (parquet/iceb)│
   │                │        │  (Airflow DAG) │        │                │
   │ • offline: ice │        │                │        │                │
   │ • online: redis│        │ • batch        │        │                │
   └───────┬────────┘        │ • incremental  │        └────────┬───────┘
           │                 └────────┬───────┘                 │
           │                          │                         │
           │                          ▼                         ▼
           │                 ┌────────────────┐        ┌────────────────┐
           │                 │   Vector DB    │        │   MLflow       │
           │                 │  (pgvector/    │        │  Tracking +    │
           │                 │   Qdrant/Pine) │        │  Registry      │
           │                 │  + BM25 idx    │        │                │
           │                 └────────┬───────┘        └────────┬───────┘
           │                          │                         │
           ▼                          ▼                         ▼
   ┌────────────────────────────────────────────────────────────────────┐
   │                       Servicio de Inferencia                        │
   │   ┌──────────────┐  ┌──────────────┐  ┌──────────────────────────┐ │
   │   │  BentoML     │  │   Triton     │  │  Agent runtime (LangChain│ │
   │   │  (modelos)   │  │   (GPU LLM)  │  │   / DSPy / MCP)          │ │
   │   └──────────────┘  └──────────────┘  └──────────────────────────┘ │
   └────────────────────────────────────────────────────────────────────┘
                            ┌────────────────────┐
                            │  Apps / Bots / UI  │
                            └────────────────────┘

6. RAG Hybrid Pipeline

        Query del usuario ("¿Cuál es el churn Q1 en LATAM?")
                ┌──────────────────────────────┐
                │  Query Rewriter (LLM)        │  ← reformula + extrae filtros
                │  + Intent classifier          │
                └──────────────┬───────────────┘
                ┌──────────────┴───────────────┐
                │                              │
                ▼                              ▼
       ┌─────────────────┐          ┌─────────────────────┐
       │  Vector search  │          │  Keyword (BM25)     │
       │  (HNSW HYBRID)  │          │  + filtros metadata │
       └────────┬────────┘          └──────────┬──────────┘
                │                              │
                └──────────────┬───────────────┘
                ┌──────────────────────────────┐
                │  Cross-encoder Reranker      │
                │  (bge-reranker-v2-m3)        │
                └──────────────┬───────────────┘
                ┌──────────────────────────────┐
                │  Context Assembly             │
                │  + citation metadata          │
                └──────────────┬───────────────┘
                ┌──────────────────────────────┐
                │  LLM (con system prompt      │
                │  obligando citas)            │
                └──────────────┬───────────────┘
                ┌──────────────────────────────┐
                │  Guardrails:                  │
                │   - hallucination check       │
                │   - PII redaction             │
                │   - faithfulness score (RAGAS)│
                └──────────────┬───────────────┘
                       Respuesta + citas

7. Modelo de Despliegue (Producción)

7.1 Multi-cuenta / multi-proyecto (AWS ejemplo)

┌─────────────────────────────────────────────────────────────────┐
│                       AWS Organization                           │
├─────────────────────────────────────────────────────────────────┤
│   Account: org-data-prod        Account: org-data-stage          │
│   ┌─────────────────────┐       ┌─────────────────────┐         │
│   │ S3 lakehouse-prod   │       │ S3 lakehouse-stage  │         │
│   │ Glue / EMR / EKS    │       │ Glue / EMR / EKS    │         │
│   │ MSK / MWAA          │       │ MSK / MWAA          │         │
│   └─────────────────────┘       └─────────────────────┘         │
│                                                                  │
│   Account: org-data-dev         Account: org-data-shared-svc    │
│   ┌─────────────────────┐       ┌─────────────────────┐         │
│   │ S3 lakehouse-dev    │       │ DataHub             │         │
│   │ EMR / sandbox       │       │ Monte Carlo agents  │         │
│   └─────────────────────┘       │ MLflow tracking     │         │
│                                  └─────────────────────┘         │
└─────────────────────────────────────────────────────────────────┘

7.2 Redes

  • Privado: VPC privadas, PrivateLink/VPC Endpoints para S3, Glue, ECR, Secrets Manager.
  • Egress controlado: NAT Gateway con allowlist; no internet abierto desde clusters de datos.
  • BYOK: todas las S3 y RDS cifradas con KMS CMK; rotación cada 365 días.

8. Modelo de Datos (Decisiones)

8.1 Convenciones de nombres

  • Schemas: bronze_<source>, silver_<domain>, gold_<product>.
  • Tablas:
  • Bronze: <source>_<table>_raw (ej. stripe_customers_raw)
  • Silver: <entity> (ej. customer, order)
  • Gold: dim_<entity>, fct_<process> (ej. dim_customer, fct_orders_daily)
  • Columnas: snake_case, fechas como *_date o *_at (timestamp), keys *_id.

8.2 Convenciones Iceberg

  • Partition spec: transforms (day(created_at), bucket(16, customer_id)); evitar year/month/day Hive-style.
  • Write distribution: hash para escritura streaming; range para snapshots batch.
  • Properties recomendadas:
    TBLPROPERTIES (
      'write.format.default'='parquet',
      'write.parquet.compression-codec'='zstd',
      'write.target-file-size-bytes'='268435456',  -- 256 MB
      'write.delete.mode'='merge-on-read',
      'write.merge.mode'='merge-on-read',
      'write.metadata.delete-after-commit.enabled'='true',
      'write.metadata.previous-versions-max'='100',
      'format-version'='3'
    )
    

9. Decisiones Arquitectónicas Registradas (ADRs)

ADR-001 — Apache Iceberg como formato de tabla único

  • Status: Accepted (2026-05-20)
  • Context: "Open table format war" entre Iceberg, Delta y Hudi. Tras adquisición de Tabular por Databricks y release de Polaris por Snowflake, Iceberg es el estándar de facto. Iceberg v3 (2025) unifica capa de datos con Delta (Deletion Vectors, Row Lineage, VARIANT).
  • Decision: todas las tablas analíticas en formato Iceberg. Delta solo cuando Databricks lo requiera y siempre con UniForm habilitado para lectura como Iceberg.
  • Consequences: Multi-engine portability garantizada; mayor maturity dependency del catálogo REST.

ADR-002 — dbt sobre SQLMesh

  • Status: Accepted (2026-05-20)
  • Context: dbt es el estándar de la industria; SQLMesh ofrece virtual data environments superiores. Acuerdo de fusión dbt Labs + Fivetran anunciado 2025.
  • Decision: dbt para transformaciones. Reconsiderar tras 12 meses si la fusión cambia roadmap o si volumen de slow-changing dimensions justifica SQLMesh.
  • Consequences: Ecosistema grande, hiring sencillo, riesgo de vendor consolidation.

ADR-003 — DataHub como catálogo en self-hosted, Atlan como opción enterprise

  • Status: Accepted (2026-05-20)
  • Context: Catálogos activos: Atlan/Collibra/Alation (enterprise) vs DataHub/OpenMetadata (OSS).
  • Decision: DataHub para Fase 0–2; evaluar Atlan en Fase 2 si adopción supera 100 usuarios activos.
  • Consequences: Self-hosted requiere SRE; Atlan promete tiempo a valor menor.

ADR-004 — pgvector como vector DB inicial

  • Status: Accepted (2026-05-20)
  • Context: Vector DB es mercado en explosión (Gartner: 75.3% CAGR). pgvectorscale alcanza 471 QPS @ 99% recall en 50M vectores. Costo bajo, no introduce nueva BD.
  • Decision: pgvector (Postgres extension) hasta 50M vectores. Migrar a Qdrant/Weaviate self-hosted o Pinecone DRN cuando se supere.
  • Consequences: Simplifica stack inicial; no optimizado para multi-tenant SaaS.

ADR-005 — Medallion architecture sobre Data Vault para Fase 0–2

  • Status: Accepted (2026-05-20)
  • Context: Data Vault 2.0 es ideal para historización empresarial; medallion es más simple y standard en lakehouses.
  • Decision: Medallion bronze/silver/gold. Data Vault solo si auditoría regulatoria requiere insert-only completo en Silver.
  • Consequences: Curva de aprendizaje menor; menos rigidez de historización (mitigar con SCD2 + Iceberg time travel).

ADR-006 — Iceberg REST Catalog en lugar de Hive Metastore

  • Status: Accepted (2026-05-20)
  • Context: Iceberg REST es la spec abierta moderna; Hive Metastore es legacy.
  • Decision: Polaris (OSS) o Unity Catalog (Databricks) o Glue Iceberg REST endpoint (AWS).
  • Consequences: Mejor interop multi-engine; algunos clientes legacy aún requieren HMS shim.

ADR-007 — Monte Carlo en enterprise / Soda+Elementary en OSS

  • Status: Accepted (2026-05-20)
  • Context: Observability es crítica AI-ready. Monte Carlo líder; Soda+Elementary cubre 80% por 20% del costo.
  • Decision: Empezar con Soda + Elementary; migrar selectivo a Monte Carlo cuando SLA contractual de cliente externo lo requiera.
  • Consequences: OSS requiere ops; commercial requiere $30–100K/año.
  • Status: Accepted (2026-05-20)
  • Context: Confluent migró ksqlDB → Flink; Flink es de facto el motor stream-native.
  • Decision: Flink para use cases <30s; Spark Structured Streaming para micro-batches 1–10min cuando ya hay Spark batch.
  • Consequences: Curva aprendizaje Flink; mejor exactly-once semantics y windowing.

ADR-009 — Airflow 3 sobre Dagster como orquestador

  • Status: Accepted (2026-05-20). Revisitable Fase 2.
  • Context: CNCF/SlashData Q4 2025: Airflow #1 en usefulness. Dagster software-defined assets es superior conceptualmente.
  • Decision: Airflow 3 por ecosistema y hiring; revisar Dagster cuando catálogo activo se asiente.
  • Consequences: Compatibilidad ancha; lineage menos nativo (compensar con OpenLineage).

ADR-010 — Schema Registry obligatorio para todo Kafka topic

  • Status: Accepted (2026-05-20)
  • Context: Schemas no-versionados son la causa #1 de incidentes streaming.
  • Decision: Avro/Protobuf via Confluent/Apicurio Schema Registry. JSON solo en bordes externos.
  • Consequences: Setup mayor; previene incidentes producción.

10. Capa Semántica

┌──────────────────────────────────────────────────────────┐
│   Datos físicos (Iceberg Gold)                            │
│   ┌──────────────┐  ┌──────────────┐  ┌──────────────┐  │
│   │ fct_orders   │  │ dim_customer │  │ dim_product  │  │
│   └──────┬───────┘  └──────┬───────┘  └──────┬───────┘  │
└──────────┼──────────────────┼─────────────────┼──────────┘
           │                  │                 │
           └──────────────────┼─────────────────┘
        ┌──────────────────────────────────────────────────┐
        │   Capa Semántica (dbt Semantic Layer / Cube.dev) │
        │                                                   │
        │   metric_revenue_monthly:                         │
        │     description: "ARR mensual"                    │
        │     measure: sum(amount)                          │
        │     time_grain: month                             │
        │     dimensions: [customer_segment, region]        │
        │     filters: [status='active']                    │
        │                                                   │
        │   metric_churn_rate:                              │
        │     description: "Churn % MoM"                    │
        │     measure: count_distinct(churned_customers)    │
        │             / count_distinct(active_customers)    │
        │     ...                                           │
        └──────────────────────────┬────────────────────────┘
        ┌──────────────────────────────────────────────────┐
        │   API GraphQL / REST / JDBC                       │
        └──────────────────────────┬────────────────────────┘
        ┌──────────────────────────────────────────────────┐
        │   Consumidores:                                   │
        │   - Power BI Direct Query                         │
        │   - Hex / Streamlit / dashboards                  │
        │   - LLM / text-to-SQL (¡aquí gana RAG enterprise!)│
        │   - APIs operacionales                            │
        └──────────────────────────────────────────────────┘

11. Vista de Seguridad

┌─────────────────────────────────────────────────────────────────┐
│  Identity provider (Okta / Azure AD / Google Workspace)         │
└──────────────────┬──────────────────────────────────────────────┘
                   │  SAML / OIDC
   ┌───────────────────────────────────────────────────────┐
   │  Identity-aware proxies (AWS IAM Identity Center,     │
   │  GCP IAM, Azure AD)                                   │
   └───────┬───────────────────┬───────────────────┬───────┘
           │                   │                   │
           ▼                   ▼                   ▼
   ┌─────────────┐     ┌─────────────┐     ┌─────────────┐
   │  Catálogo   │     │  Warehouse  │     │  Object     │
   │  (DataHub)  │     │  / Compute  │     │  Storage    │
   │             │     │  RBAC + RLS │     │  bucket pol │
   └─────────────┘     │  + masking  │     └─────────────┘
                       └─────────────┘

   PII tagging y masking:
   - DataHub tags ─► policies en Snowflake/UC/BigQuery
   - Column-level masking dinámico por rol
   - Row-level security para multi-tenant

   Auditoría:
   - Snowflake Access History / UC audit logs / CloudTrail
   - Sink a SIEM (Datadog, Splunk, Elastic SIEM)
   - Retención 1 año mínima (3 años regulado)

12. Costos (modelo simplificado)

Costo total mensual = Storage + Compute + Network + Tools + LLM

Storage (S3 + Iceberg metadata):
  $0.023/GB-month (S3 Standard)
  + $0.01/GB-month (Iceberg metadata estimation)
  → 100 TB ≈ $2.3K/month

Compute (estimación empresa media 50-500 personas):
  Spark batch (Databricks/EMR/Glue):    $3-8K/month
  Trino (federated query):              $2-5K/month
  Flink streaming (24/7):               $3-7K/month
  Warehouse (Snowflake compute):        $5-15K/month

Network:
  Cross-region / cross-cloud:           $0.5-2K/month
  CDN / egress:                         $1-3K/month

Tools (SaaS):
  Fivetran/Airbyte:                     $2-8K/month
  dbt Cloud:                            $0.5-3K/month
  Monte Carlo / Atlan:                  $3-10K/month
  Tecton (si aplica):                   $5-15K/month

LLM / AI API:
  OpenAI / Anthropic / Cohere:          $2-10K/month
  Embedding API:                        $0.5-2K/month

TOTAL referencial: $30-100K/month para empresa media.

13. Anti-Patrones (no hacer)

  1. Crear data lake sin governance. "Data swamp" garantizado. → Empezar con catálogo + ownership.
  2. Replicar todo a un único DW gigante. Caro y poco flexible. → Lakehouse + federated query.
  3. Mocks de DB en tests. Detecta bugs falsos. → Containers ephemeral (Testcontainers).
  4. Streaming porque sí. Complejidad alta. → Solo si SLA <5min lo justifica.
  5. Catálogo sin ownership. Shelfware. → Cada dataset Gold tiene owner asignado en CI.
  6. Métricas duplicadas en cada herramienta BI. Inconsistencia. → Capa semántica única.
  7. RAG sin evaluación continua. Hallucinaciones invisibles. → RAGAS + golden set.
  8. Permisos S3 abiertos. Brecha asegurada. → IAM least privilege + bucket policies.
  9. Vendor lock-in invisible. Lock-in se nota al migrar. → Iceberg + exports periódicos.
  10. Optimización prematura. Spark tuning antes de datos en producción. → Mide, luego ajusta.

Versión: 1.0.0 — Última revisión: 2026-05-20. Cualquier cambio mayor abre PR con ADR nueva.