Marketing Data Ingestion Architecture — Simplicity Grade
Marketing Data Ingestion Architecture — Simplicity Grade
Target Architecture Proposal for Acme Marketing Group
Author: Kiril Iliev, Enterprise Architect
Version: 2.0 (simplified; replaces v1.0 and v1.1)
Status: Draft for review. The decisions in 02-Architectural-Rationales.md
are Proposed until the architect confirms them.
Deliverable Mapping: Addresses the case scenario
"Marketing Data Ingestion Architecture for Acme Marketing Group" (a
fictional company)
Audience: A marketing company with a small team. The
goal is the least architecture that is still reliable and privacy-aware.
The Enterprise
grade is the opposite end of the scale.
1. Summary
Acme wants Salesforce, HubSpot and Google Ads data in one place for reporting, campaign attribution and alerts.
The design has four moving parts and no server to babysit:
- Cloud Scheduler triggers three schedules.
- Cloud Run jobs run one container image: adapters pull the data, a transform job cleans it.
- Cloud Storage holds the raw files and the Silver/Gold tables.
- BigQuery serves the Gold tables to Looker Studio or Power BI.
There is no orchestration server, no message queue, no webhook endpoint and no separate network layer. Indicative cost is about $5–25 per month (section 7), mostly inside Google Cloud's free tiers.
1.1 Decisions at a glance
| Question | Decision | Record |
|---|---|---|
| Cloud | Google Cloud (recommended default for a marketing agency; hosting options in section 12) | ADR-S01 |
| Compute | Cloud Run jobs, scale to zero | ADR-S01 |
| Orchestration | Cloud Scheduler triggers jobs; no orchestration server. Dagster is the upgrade path | ADR-S02 |
| Code | Python DataFrames, notebook-friendly modules,
pytest |
ADR-S03 |
| Storage | Cloud Storage; Silver/Gold as Delta tables written with delta-rs; no Spark | ADR-S03 |
| Sources | One thin adapter class per source | ADR-S04 |
| Privacy | Keyed HMAC pseudonyms, no names in Silver, 21-day raw retention, erasure script | ADR-S05 |
| Serving | Gold loaded into BigQuery; Looker Studio (free) or Power BI | ADR-S06 |
2. Architecture
The simple picture
flowchart LR
S["<b>Your tools</b><br/>Salesforce, HubSpot,<br/>Google Ads"] -->|"every 30 min"| J["<b>Small scheduled job</b><br/>Cloud Run"]
J --> D[("<b>Data store</b><br/>Cloud Storage")]
D --> B[("<b>Reports database</b><br/>BigQuery")]
B --> R["<b>Dashboards</b><br/>Looker Studio or Power BI"]
J -. "if something fails" .-> A["<b>Alert</b><br/>e-mail or Slack"]
The same thing in more detail
Three storage zones: Landing (raw JSONL, deleted after 21 days), Silver (conformed, pseudonymised) and Gold (star schema, loaded into BigQuery for reporting).
flowchart TD
subgraph Sources["Source platforms"]
SF["Salesforce"]
HS["HubSpot"]
GA["Google Ads"]
NEW["Future sources"]
end
SCH["Cloud Scheduler<br/>3 schedules"]
subgraph Run["Cloud Run jobs (one image)"]
SYNC["sync job<br/>source adapters"]
BUILD["build job<br/>Silver and Gold"]
end
subgraph GCS["Cloud Storage"]
LAND["Landing<br/>raw JSONL, 21-day lifecycle"]
LAKE["Silver and Gold<br/>Delta tables"]
end
SM["Secret Manager<br/>API tokens, pseudonym key"]
BQ["BigQuery<br/>Gold tables"]
BI["Looker Studio or Power BI"]
MON["Cloud Monitoring<br/>failure alert to email or Slack"]
SCH --> SYNC
SCH --> BUILD
SF --> SYNC
HS --> SYNC
GA --> SYNC
NEW --> SYNC
SYNC --> LAND
LAND --> BUILD
BUILD --> LAKE
BUILD --> BQ
BQ --> BI
SM --> SYNC
SM --> BUILD
SYNC --> MON
BUILD --> MON
3. Ingestion Strategy per Source
| Aspect | Salesforce | HubSpot | Google Ads |
|---|---|---|---|
| Access | REST query (follows nextRecordsUrl); Bulk API 2.0 for
the first load |
CRM Search API v3 | GAQL via googleAds:searchStream |
| Approach | Incremental on SystemModstamp, no
LIMIT |
Keyset paging: modified-date window plus
hs_object_id > last_id, 200 per page |
Trailing 30-day pull by segments.date |
| Why | SystemModstamp also catches system updates. A
LIMIT would end the result set and truncate the
window. |
Search is capped at 10,000 results per query; keyset paging never reaches it. | Metrics restate after the fact; re-pulling overwrites old values. |
| Push or poll | Poll | Poll (webhooks are an optional later accelerator) | Poll only |
| Deletes | queryAll returns IsDeleted rows |
archived objects |
status = REMOVED |
| Modified-date field | SystemModstamp |
Contacts: lastmodifieddate; others:
hs_lastmodifieddate |
segments.date |
All adapters share retry with full-jitter backoff, a token-bucket rate limiter, one automatic token refresh on HTTP 401, and an exception (not a silent partial result) if a source reports more data without a cursor.
📝 Possible simplification to evaluate: Google Cloud's BigQuery Data Transfer Service has a Google Ads connector. If it covers the needed reports, it could replace the Google Ads adapter entirely. Check its report coverage and cost before building the adapter.
4. Schedules
Three Cloud Scheduler triggers, which fits the free tier of three jobs.
| Schedule | Cadence | What runs | Business need |
|---|---|---|---|
| CRM sync | every 30 minutes | Salesforce and HubSpot incremental sync, then Silver | Sales sees new leads and deals within about 30 minutes |
| Ads sync | hourly | Google Ads trailing window, then Silver; pacing check | Budget pacing; intraday numbers are preliminary |
| Daily build | 06:00 UTC | Closed-day ads numbers, Gold build, load into BigQuery, reconciliation | Finalised numbers for ROI and attribution |
A weekly run of the daily job also re-pulls a 90-day ad window to catch late attribution and checks source ids for hard deletes.
📝 Assumption: 30 minutes is a target to validate with Acme's sales team. Hourly is simpler and cheaper if it is enough.
5. Reliability, Recovery, Idempotency & Reconcile
- Immutable landing. Each API page becomes one new
file
/landing/{source}/{entity}/YYYY/MM/DD/run_{batch}_p{page}.jsonl, created with a conditional create that never overwrites. Each record carries_source_id,_ingested_at,_batch_id,_watermark. - Idempotent MERGE. Silver is updated with a Delta
MERGEon the business key. A row is replaced only if the incoming one is at least as new, so replays and late batches never move data backwards. Within one batch the newest source version wins. - Deletes are tombstones. A deleted or archived
source row is kept with
is_deleted = true; Gold and reports filter it out. A hard delete would let an older, late batch bring the row back. - Watermark. A per-source, per-entity timestamp. The window ends 5 minutes before now (safety lag). The watermark moves only after the window has landed, so a failed run is simply repeated.
- Recovery. Replay the transform over landing (no API calls) for the last 21 days. For older data or a changed source, reload the date range from the source. Silver and Gold can always be rebuilt from landing or the sources; there is nothing to restore except the bucket.
- Reconciliation (weekly). Compare the source with
landing for a settled window: Salesforce
COUNT()vs. distinct ids; HubSpot searchtotalvs. distinct ids; Google Ads daily clicks and cost totals vs. Gold for days older than the restatement window. A mismatch sends an alert and re-pulls that window once.
6. Historical Backfill vs. Incremental Sync
- Backfill: run the sync in 30-day chunks over the history (Salesforce Bulk API 2.0 for large objects), then build Silver and set the watermark. It is a manual run of the same job with a date range.
- Incremental: each scheduled run extracts from the watermark to now minus 5 minutes.
7. Cost
⚠️ To validate: planning estimates from public Google Cloud list prices and the assumed run profile. Confirm with the Google Cloud Pricing Calculator for the chosen region before quoting them.
| Component | Basis | Estimate (USD / month) |
|---|---|---|
| Cloud Run jobs | About 5,300 vCPU-seconds per day for syncs plus a 30-minute daily build; mostly inside the monthly free grant | 0 – 5 |
| Cloud Scheduler | 3 jobs (3 are free per billing account) | 0 – 1 |
| Cloud Storage | About 100 GB landing and Delta, plus operations | 2 – 6 |
| BigQuery | Small Gold tables; storage and queries inside the free tier | 0 – 5 |
| Secret Manager | A handful of secrets | 0 – 1 |
| Logging and monitoring | Normally inside the free allotment | 0 – 5 |
| Artifact Registry | One image | < 1 |
| Looker Studio / Power BI | Free / existing licences | 0 |
| Total | about 5 – 25 |
For comparison, the smallest realistic Microsoft Fabric capacity (F2) lists at about $263 per month (pay-as-you-go, US region). The saving is an order of magnitude on infrastructure.
What the saving costs: an engineer builds and owns the pipeline. If Acme has nobody for that, buying a managed connector service is the cheaper total (section 12, option E).
8. Source Limits
The base adapter handles these once.
- Salesforce: daily API request quota; large windows use Bulk API 2.0.
- HubSpot Search: per the HubSpot search guide, 5 requests per second per account, 200 objects per page, 10,000 results per query. The adapter uses 200 per page, limits itself to 4 requests per second and uses keyset paging.
- Google Ads: quotas depend on the developer-token access level (check the token Acme holds). The API version is configuration, because Google retires each version about a year after release.
9. Privacy and GDPR
📝 Position: keyed pseudonymisation reduces risk but does not make data anonymous. Pseudonymised data stays personal data under GDPR (Recital 26). The design minimises what is kept and makes erasure reliable; it does not claim exemption.
9.1 What reaches Silver
| Field class | Examples | Landing (21 days) | Silver / Gold |
|---|---|---|---|
| Identifier used for joins | e-mail, phone | verbatim | keyed HMAC pseudonym only |
| Identifier not needed | names, address, job title | verbatim | dropped |
| Free text | notes, descriptions | verbatim | dropped |
| IP address | verbatim | dropped or country only | |
| Marketing attributes | lifecycle stage, source, campaign, first-touch URL | verbatim | kept |
⚠️ Requires stakeholder input: Acme's data protection contact confirms this classification, the lawful basis and the maximum erasure time (assumed one month).
9.2 Pseudonymisation
pseudo_id = HMAC-SHA256(key, normalised value). The key
is a Secret Manager secret; if it is missing the job
fails, there is no default. The key is not rotated routinely
because every pseudonym would change and joins would break; on a
compromise, issue a new key version and reload from the sources. Only
the job's service account can read the key.
9.3 Erasure on request
- Run the erasure script with the person's e-mail. It writes the pseudonym to an erasure ledger (no plaintext) and deletes the person from Silver and Gold. The next Gold load removes them from BigQuery.
- The ledger makes sure that a replay from landing cannot bring them back.
- Landing files expire by lifecycle rule within 21 days; Delta file
history is removed by
VACUUMafter 7 days. Worst case about 28 days, inside one month. - Note the request, completion date and who ran it.
Source-side privacy deletions (HubSpot, Salesforce) arrive as
is_deleted rows; for those the same script path also adds
the ledger entry.
10. Serving Layer
- The last step of the daily build loads the Gold tables into BigQuery (truncate and reload; Gold is small).
- Looker Studio (free) and Power BI (BigQuery connector) both read BigQuery directly. BigQuery gives live SQL, so no separate SQL engine is needed.
- Dashboards are as fresh as the last load and the BI tool's cache setting. Fast signals (new lead, failure, pacing) go through alerts, not dashboards.
- Microsoft Fabric's Direct Lake is not an option here: it runs only on Fabric capacity.
⚠️ To validate: the BigQuery loader (
google-cloud-bigquery, about 10 lines) is not part of the reference skeleton.
11. Data Model & Attribution
| Table | Grain | Key |
|---|---|---|
dim_campaign |
campaign per platform | campaign_key = <channel>:<campaign_id> |
dim_customer |
pseudonymised person | email_pseudo_id |
fact_daily_spend |
campaign × day | campaign_key, metric_date |
fact_lead |
lead or contact | contact_id, source |
fact_attribution |
lead × touch | contact_id, campaign_key,
touch_ts |
Spend is joined to leads through the identifiers captured at the
touch: gclid and UTM parameters stored with the HubSpot
contact and the Salesforce lead, plus a mapping from UTM campaign values
to campaign_key. Default rule: last non-direct
touch within 30 days, with first touch kept alongside.
⚠️ Requires stakeholder input: marketing confirms the rule and that
gclid/UTM capture is in place in both CRMs. Without itfact_attributioncannot be built. The skeleton implementsdim_campaignandfact_daily_spend;fact_attributionis the next build item.
12. Hosting Options and Why Google Cloud
The pattern is the same everywhere: a scheduler, a container job, object storage, a secret store and a place to serve reports. Only the product names change.
| Component | Google Cloud (recommended) | Azure | AWS |
|---|---|---|---|
| Scheduler | Cloud Scheduler | Container Apps job schedule | EventBridge Scheduler |
| Job runner | Cloud Run jobs | Container Apps jobs | ECS Fargate scheduled task or Lambda |
| Object storage | Cloud Storage | ADLS Gen2 / Blob | S3 |
| Secrets | Secret Manager | Key Vault | Secrets Manager |
| Serving | BigQuery + Looker Studio | Power BI Import or Synapse serverless | Athena / Redshift + QuickSight |
| Alerts | Cloud Monitoring | Azure Monitor | CloudWatch |
| Option | Fits when | Main drawback |
|---|---|---|
| A. Google Cloud (recommended) | Acme is a marketing agency using Google Ads, GA4, Workspace or Looker Studio | New ecosystem if the company is Microsoft-based |
| B. Azure | Acme is a Microsoft 365 / Power BI company | More configuration than Cloud Run, and BigQuery's built-in serving is missing |
| C. AWS | Acme already runs on AWS and has staff for it | Most services to wire together; serving is not built in |
| D. GitHub Actions on a schedule | Very small volume, pilot or proof of concept | Time limits, runner reliability, weaker secret and storage story |
| E. Buy a connector service (Fivetran, Airbyte Cloud, Supermetrics) plus BigQuery | No engineer to own the pipeline | Monthly fee that grows with volume; custom privacy handling is limited |
Why Google Cloud is the recorded default. We do not yet know Acme's stack. A marketing agency very likely has Google Ads, probably GA4 or Workspace, and Looker Studio is free. BigQuery serves reports with plain SQL, so there is no extra serving component, and Cloud Run jobs plus Cloud Scheduler is the smallest runtime of the three clouds. The code is cloud-neutral (Python, containers, open table format), so changing cloud means replacing the storage sink, the secret client and the deploy script.
⚠️ Requires stakeholder input: ask Acme whether they run on Microsoft 365 / Azure or already have a cloud account. A Microsoft shop with Power BI points to option B; a team with no engineer points to option E.
13. Adding a New Source
- Write a subclass of
BaseSourceAdapterthat implements_fetch_records(one page) and, if tokens expire,_auth_headersand_refresh_credentials(1–2 days). Paging, retries, rate limiting, landing and provenance are inherited. - Add it to the sync schedule (minutes).
- Map it into Silver and classify its fields (section 9.1) before data reaches Silver (about 1 day).
- Backfill (an hour plus run time).
14. Operations
- Alerts: a Cloud Monitoring alert on a failed Cloud Run job execution sends e-mail or a Slack/Teams message. Reconciliation mismatches and schema-drift warnings use the same channel. The hourly ads job also posts a pacing alert when spend runs over the daily cap.
- Deploy: GitHub Actions builds one image, runs
pytest, pushes to Artifact Registry and updates the jobs. Infrastructure is a short script now; Terraform is recommended once more than a pilot is running. - Environments: developers work locally against sandbox data; there is one production project. A second project is added only when a test environment becomes necessary.
- Security baseline: a dedicated service account with least privilege, secrets only in Secret Manager, private bucket with uniform access control, no keys in the image.
- Backup: turn on bucket soft delete and object versioning. Landing is temporary, Silver and Gold are rebuildable, so recovery means a reload. BigQuery time travel covers accidental table changes for 7 days.
- Data quality: after each build, check freshness, key uniqueness and row-count bounds. A new, unknown source field is kept in landing, ignored in Silver and listed in a schema-drift warning for a person to classify.
15. Assumptions, Risks & Clarifications
Assumptions: volumes stay in the low millions of CRM rows and tens of millions of ad rows a year; reporting is by dashboard and alerts; Acme can name one person who owns the pipeline.
Risks and mitigations
- Cloud not confirmed: the stack is portable; section 12 shows the swap.
- Schema drift: landing keeps raw JSON; Silver ignores unknown fields and warns.
- Source throttling or outage: backoff with jitter; the watermark resumes from the last confirmed window.
- Personal data in landing: 21-day lifecycle and a private bucket.
- Unvalidated integrations: the Google Ads adapter and the BigQuery loader have not run against live systems; both need a short proof of concept.
- Owner dependency: a managed connector service (option E) is the fallback if nobody can own the pipeline.
16. Conclusion
Four moving parts (a scheduler, container jobs, a bucket and BigQuery) give Acme timely data, safe replays, privacy-aware storage and an easy way to add sources, for about $5–25 per month. Everything heavier in the Enterprise grade (orchestration server, event bus, private networking, formal governance) is deliberately left out and can be added later if Acme grows into it.