AI for IT Certification
Aware · M47 · lesson 47 of 120 · queued
Preview — browse every lesson free. Enroll to mark lessons complete, open partner links and save your progress. Login & enroll →
Data Architecture For Ai
📖
now learning

Data Architecture For Ai

15 min

Hook

Your data scientist asks: "Can you send me a clean dataset to train the model?"

You start looking for the data. It lives in three different systems (CRM, ERP, and a legacy accounting system). The definitions don't match (one system calls it "customer ID," another calls it "account number"). The quality is poor, half the records are missing the key field you need. The most recent data is from last month because the nightly extraction process failed last week and no one noticed.

Your data scientist waits two weeks for the data. She spends another week cleaning it. She finally trains the model, but it performs worse than expected because the data is stale. She asks: "Can you get me fresher data?" You realize you have no pipeline to refresh the data automatically.

This is the reality at most organizations. Data architecture is the unsexy foundation that determines whether AI succeeds or fails. Without good data pipelines, governance, and quality controls, you can have the best ML engineers and the fanciest infrastructure in the world, but your models will be garbage.

Purpose

Data architecture for AI is different from traditional data architecture. Traditional systems optimize for transactions (fast writes, ACID compliance). AI systems optimize for analytics and model training (historical data, batch processing, integration across sources).

A good data architecture for AI enables:

  • Data Collection, Ingesting data from various sources reliably
    - Data Transformation, Cleaning, validating, and enriching data
    - Data Serving, Making data available to AI systems quickly
    - Data Governance, Knowing what data exists, where it's stored, who can access it
    - Data Quality, Ensuring data is accurate, complete, and consistent

Without this foundation, AI projects fail silently.

Why This Matters

Data quality directly impacts model quality. A model trained on garbage data makes garbage predictions. Yet most organizations have no way to measure or improve data quality.

First, bad data architecture wastes ML time. 50-80% of ML engineering time is spent cleaning and preparing data, not building models. With better data architecture, this drops to 20-30%.

Second, bad data quality ruins model quality. Models trained on incomplete, inconsistent, or stale data make poor predictions. Organizations blame "AI doesn't work" when the problem is data.

Third, bad data governance creates compliance risk. You don't know where personal data is stored, who can access it, or how it's used. GDPR, HIPAA, and CCPA violations happen.

Fourth, bad data architecture limits scalability. You can't deploy models to production because you have no way to serve fresh data at inference time. Or inference is slow because data retrieval is a bottleneck.

Organizations that succeed invest heavily in data architecture first, before building complex models.

Core Concepts

Key Insight: The Data Pipeline Layers

A robust data architecture has five layers:

Layer 1: Ingestion

Get data from source systems (CRM, ERP, logs, APIs, databases) into a central location (data lake, data warehouse).

Components:

  • Batch ingestion, Nightly exports from source systems (common, simpler)
  • Real-time ingestion, Continuous data streams using Kafka, Pulsar, kinesis (more complex, fresher data)
  • Change Data Capture (CDC), Capture only changed records instead of full exports (more efficient)

Tools: Apache NiFi, Talend, Airflow, Kafka, cloud-native ETL

Common problem: Ingestion breaks silently. Source system changed schema, API changed, or network issue occurred. No one notices until data scientist asks for data and it's stale.

Solution: Monitoring and alerting on ingestion pipelines. Alert if last successful ingest was >24 hours ago.

Layer 2: Raw Data Storage

Store ingested data as-is, before transformation. This is your source of truth.

Components:

  • Data Lake (cloud), S3, GCS, Azure Blob Storage with Parquet/Avro files
  • Data Lake (on-prem), HDFS with Parquet/Avro files
  • Data Warehouse, Snowflake, BigQuery, Redshift (more structured, queryable)

Decision: Use a data lake if you ingest diverse data sources with varying schemas. Use a warehouse if you want SQL-queryable, structured data. Increasingly, warehouses are doing both.

Common problem: "Data swamp": raw data with no documentation, no one knows what tables mean, no one knows quality.

Solution: Data catalog and documentation. Document each table: what it contains, when it's updated, who owns it.

Layer 3: Transformation

Clean, validate, and enrich data. This is where most of the work happens.

Components:

  • Data cleaning, Fix missing values, remove duplicates, fix formatting
  • Data validation, Check that values are within expected ranges, required fields are present
  • Data enrichment, Join data from multiple sources, add calculated fields
  • Feature engineering, Transform raw data into features for ML models

Tools: Apache Spark, dbt (data build tool), Dataflow, custom Python

Common problem: Transformation logic lives in notebooks or custom scripts. It's not reproducible or maintainable.

Solution: Use a dbt or similar tool to version control transformation logic.

Layer 4: Feature Store (Optional but Increasingly Important)

A dedicated system for managing features (input variables for ML models).

Why:

  • Features are reused across multiple models. Instead of each model computing the same feature, compute once and reuse.
  • Features need to be available at both training time and inference time.
  • Features can go stale (yesterday's feature value isn't useful for today's inference).

Example: "customer_30day_spend" is a feature used by churn model, propensity model, and recommendation model. Instead of computing it three times, compute once in feature store.

Tools: Tecton, Feast, Hopsworks

Common problem: Training-serving skew. Feature computed one way for training, different way at inference. Model performs great in lab, poorly in production.

Solution: Feature store ensures same feature definition for training and inference.

Layer 5: Data Serving

Make data available to AI systems at inference time.

Components:

  • Batch serving, Export data weekly/nightly for batch inference
  • Real-time serving, Return feature values instantly for real-time inference (needs sub-second latency)
  • Cache layers, Redis, Memcached for fast feature retrieval

Common problem: Inference requests are slow because retrieving features from the data warehouse takes 5 seconds.

Solution: Feature cache (Redis) stores frequently-used features in memory, returning values in milliseconds.

Key Insight: Data Quality Framework

Data quality has five dimensions:

1. Completeness - Are all required fields present? Are there missing values?

  • Measure: % of non-null values
  • Example: Customer addresses might be 95% complete (5% missing)

2. Accuracy - Are values correct? Do they match ground truth?

  • Measure: % of values that are correct (requires validation against known-good sources)
  • Example: Email addresses might be 98% accurate (2% typos or fake addresses)

3. Consistency - Do values match across systems? If customer appears in CRM and ERP, do the names match?

  • Measure: % of records that are consistent across sources
  • Example: Customer names match 94% of the time; 6% have spelling differences

4. Timeliness - Is data fresh enough for its use case?

  • Measure: How old is the data? Is it acceptable for the use case?
  • Example: Yesterday's customer transaction data is acceptable for demand forecasting. Last month's data is not.

5. Validity - Do values conform to expected format or range?

  • Measure: % of values in valid format or range
  • Example: Zip codes should be 5 digits; 99% comply, 1% have extra characters

For each dimension, define minimum acceptable thresholds:

  • Completeness: >95%
  • Accuracy: >95%
  • Consistency: >95%
  • Timeliness: daily refresh acceptable
  • Validity: >99%

Monitor these continuously. If any dimension drops below threshold, alert and investigate.

Key Insight: Data Governance Framework

Data governance answers four questions:

1. What data exists?

  • Maintain a data catalog listing all datasets, their location, what they contain
  • Example: "Customer demographics table in Snowflake, updated daily, contains 10M customer records"

2. Who owns each dataset?

  • Assign owners accountable for data quality
  • Owners ensure quality thresholds met, update documentation, handle access requests

3. Who can access what data?

  • Implement access controls based on role and need
  • Example: Data scientists can access anonymized customer data, not personally identifiable information
  • Finance team can access financial data, not customer data

4. How is data used?

  • Track which models and systems use which data
  • Important for compliance (if data is used in lending decisions, must meet regulatory requirements)

Implementation: Data catalog tool (Alation, Collibra) + access control system + metadata documentation

Practical Use Cases

Use Case 1: Building Data Architecture for a Predictive Maintenance Model

Scenario: Manufacturing company wants to predict equipment failures.

Data Sources:

  • Sensor data (temperature, vibration, pressure): 10,000 sensors, readings every minute (14GB/day)
  • Maintenance logs: Equipment failure dates and repair types (SQL database, 10K records/day)
  • Equipment metadata: Equipment type, age, model (static file, 500 equipment records)

Data Pipeline:

Ingestion:

  • Sensor data: Real-time stream via IoT gateway → Kafka
  • Maintenance logs: Daily batch export from maintenance system
  • Metadata: Weekly batch (static, slow-changing)

Raw Storage:

  • Sensor data: Data lake (Parquet, organized by date, compressible)
  • Maintenance logs: Data warehouse table
  • Metadata: Simple lookup table

Transformation:

  • Clean sensor data (remove outliers, handle missing values)
  • Aggregate sensor data (5-minute rolling averages, hourly stats)
  • Join with maintenance logs to label failures
  • Create features: "equipment temperature trended up 10% in last day", "vibration exceeded threshold", etc.

Feature Store:

  • equipment_temperature_1hr_avg
  • equipment_vibration_1hr_std
  • days_since_last_maintenance
  • equipment_age

Data Serving:

  • Batch: Export feature matrix weekly for model training
  • Real-time: Cache latest sensor aggregates in Redis for instant inference

Governance:

  • Data owner: Maintenance team lead
  • Access: Data scientists and ML engineers only
  • Data quality: >95% completeness, timeliness <1 minute for sensor data
  • Catalog: Document each feature, refresh schedule, dependencies

Use Case 2: Building Data Architecture for Customer Churn Model

Scenario: SaaS company wants to predict which customers will churn.

Data Sources:

  • Customer metadata: Name, company, sign-up date (customer database, 10K customers)
  • Usage data: Daily active usage, features used (event stream, 100K events/day)
  • Billing data: Monthly charges, payment history (accounting system)
  • Support tickets: Number and sentiment of support interactions (helpdesk system)

Data Pipeline:

Ingestion:

  • Customer metadata: Daily batch export
  • Usage data: Real-time event stream (Kafka)
  • Billing data: Daily batch
  • Support tickets: Daily batch

Raw Storage:

  • All data in data warehouse (Snowflake, BigQuery)
  • Usage events in separate table for time-series analysis

Transformation:

  • Aggregate daily usage to user-level monthly metrics
  • Calculate customer lifetime value from billing data
  • Count and score support tickets
  • Create labels: churned = no activity for 30 days after contract end

Feature Store:

  • monthly_active_days
  • monthly_feature_usage_count
  • monthly_spend
  • months_since_support_ticket
  • support_sentiment_score
  • customer_age_months

Data Serving:

  • Batch: Monthly exports for retraining
  • Real-time: Prediction requested by customer success team, needs features within <1 second

Governance:

  • Data owner: Analytics team
  • Access: ML engineers, customer success (limited to their own customer data)
  • Data quality: >95% completeness, monthly refresh acceptable
  • Compliance: Customer data subject to GDPR/CCPA, implement right-to-delete

Use Case 3: Fixing a Broken Data Architecture

Scenario: Company has been doing AI for 2 years. Models exist but are unmaintained. Data quality is terrible.

Current State:

  • Training data prepared manually by ML engineer (not reproducible)
  • Data is 3 months old (model trained quarterly)
  • No documentation of features or data sources
  • Data scientists argue about what "churn" means (different definitions in different models)
  • No idea what data quality is (could be 50%, could be 90%)

Refactoring Plan:

Phase 1 (Month 1): Assess and Document

  • Inventory all data sources
  • Document existing models and their features
  • Measure current data quality
  • Identify biggest pain points

Phase 2 (Months 2-3): Build Pipelines

  • Implement automated data ingestion (batch jobs)
  • Implement data validation (alert if quality drops)
  • Create data catalog with documentation
  • Assign data owners

Phase 3 (Months 4-6): Implement Transformations

  • Move feature logic from notebooks to dbt
  • Create feature store for shared features
  • Establish data quality thresholds
  • Retrain models with fresh, documented data

Phase 4 (Months 6+): Continuous Improvement

  • Monitor data quality
  • Track model performance vs data freshness
  • Optimize pipeline performance
  • Expand feature store with new features

Expected Benefits:

  • Model performance improves (fresher data, less training-serving skew)
  • Model development time drops (don't spend time cleaning data)
  • Compliance risk decreases (know where data is, who can access it)
  • Models in production go from "unmaintained" to "actively maintained"

Examples

Example 1: Data Quality Monitoring Dashboard

Dataset: customer_events

Last updated: 2 hours ago ✓ (acceptable: <24 hours)
Completeness: 94% (warning: below 95% threshold)
- Missing email: 200 records
- Missing user_id: 50 records

Accuracy: 98% (healthy)
Consistency: 97% (healthy)
Timeliness: 2 hours (healthy)
Validity: 99.5% (healthy)

Alerts:
⚠️ Completeness below threshold. Review incoming data.
✓ No other issues.

Recent Changes:
- Data volume increased 20% yesterday (investigate if expected)
- New field added: customer_segment (review quality)

Example 2: Feature Store Definition

Feature: monthly_active_days

Namespace: customer_metrics
Owner: analytics_team
Definition: Number of days in the current month where customer had ≥1 event
Formula: COUNT(DISTINCT DATE(timestamp))
WHERE customer_id = ?
AND DATE(timestamp) >= DATE_TRUNC('month', CURRENT_DATE)

Freshness: hourly
Availability: real-time cache (Redis), warehouse (Snowflake)
Used by: churn_prediction_model, ltv_model

Tags: customer_engagement, real-time, high-volume
Documentation: https://wiki/features/monthly_active_days

Anti-Patterns

Anti-Pattern 1: "Data Lake" That's Really a Data Swamp

You build a data lake and dump all data into it. No documentation, no governance, no one knows what anything means. It becomes useless.

Instead: Data lake needs documentation, catalog, and governance. Use a data catalog tool and assign owners.

Anti-Pattern 2: Transformation Logic in Notebooks

Data scientists keep transformation logic in Jupyter notebooks. It's not version controlled, not reproducible, hard to maintain.

Instead: Move transformation logic to dbt or equivalent. Version control it, test it, document it.

Anti-Pattern 3: No Monitoring of Data Pipelines

Ingestion fails silently. Data is 2 months old, but no one knows. Models are training on stale data.

Instead: Monitor all data pipelines. Alert if last successful ingestion was >24 hours ago.

Anti-Pattern 4: Training-Serving Skew

Feature computed differently for training vs. inference. Model is great in lab, poor in production.

Instead: Use feature store or ensure exact same feature definitions for training and inference.

Anti-Pattern 5: No Data Quality Measurement

"Our data quality is probably fine." You have no idea. Half the records might have missing values.

Instead: Measure quality dimensions (completeness, accuracy, consistency, timeliness, validity) continuously.

Human Judgment Checkpoints

Checkpoint 1: Can You Explain Your Data Pipeline in Five Minutes?

If you can't, it's too complicated. Good data architecture is simple and understandable.

Checkpoint 2: Who Owns the Data Quality?

If no one is assigned to own data quality, it will degrade. Assign an owner.

Checkpoint 3: How Do You Know When Data Is Fresh Enough?

Define data freshness requirements for each use case. If no requirement, how do you know you have stale data?

Checkpoint 4: Can You Find and Access Data Easily?

Data scientists should be able to find data via a catalog, not by asking around. If finding data is hard, governance is weak.

Checkpoint 5: Are You Measuring Data Quality?

If you don't measure it, you can't manage it. Implement quality monitoring.

Key Takeaways

Build data architecture in layers: ingestion, raw storage, transformation, feature store, serving. Each layer has a specific purpose. Weak layers downstream create problems everywhere.

Treat data pipelines as production systems. They break, they need monitoring, they need owners. Implement alerting and SLAs.

Implement data governance from the start. A catalog, owners, and access controls prevent compliance risk and enable data discovery.

Measure data quality continuously. Completeness, accuracy, consistency, timeliness, validity. If quality drops, know immediately.

Use a feature store for shared features. Prevents redundant computation and training-serving skew. High-ROI investment.

Document everything. Data sources, transformations, features, quality standards. Documentation is part of the architecture.

Invest in data architecture before building complex models. 80% of model improvement comes from better data, not better algorithms.