Acme Marketing Architecture

Architectural Rationales & Decision Records (ADRs)

Architectural Rationales & Decision Records (ADRs)

Simplicity Grade Architecture — Acme Marketing Group

Author: Kiril Iliev, Enterprise Architect
Version: 2.0 (simplified)
Decision rights: Self. The architect decides; there is no board.
Purpose: Short records of the decisions behind the Simplicity Grade. v1.0 and v1.1 had 6 and 11 records; v2.0 keeps six, because a small team needs fewer decisions written down, not more.

v2.0 record Replaces
ADR-S01 v1.0 S01, v1.1 S07 (cloud)
ADR-S02 v1.0 S02, v1.0 S06 (alerts), v1.1 S11 (environments)
ADR-S03 v1.0 S03, v1.1 S08 (engine and format)
ADR-S04 v1.0 S04
ADR-S05 v1.0 S05, v1.1 S10 (retention and erasure)
ADR-S06 v1.1 S09 (serving)

Index

ADR Decision Status
ADR-S01 Serverless containers on Google Cloud Run Proposed
ADR-S02 Cloud Scheduler instead of an orchestration server Proposed
ADR-S03 Python DataFrames and Delta tables, no Spark Accepted
ADR-S04 Adapter pattern for sources Accepted
ADR-S05 Keyed pseudonyms, 21-day landing, erasure script Proposed
ADR-S06 Serve Gold through BigQuery Proposed

ADR-S01: Serverless Containers on Google Cloud Run

Status

Proposed

Context & Problem

Acme is a marketing company. We need somewhere to run a few small Python jobs on a schedule and keep some files and tables. We do not yet know Acme's cloud. The first versions named Azure, AWS and GCP as equals and then picked Azure on an unconfirmed assumption about Power BI.

Decision

Run the jobs on Google Cloud Run jobs, with Cloud Storage for files, Secret Manager for secrets and BigQuery for reporting. Record Azure and AWS as equivalent alternatives (Architecture/01 section 12) and change cloud if Acme's stack points elsewhere.

Rationale & Trade-offs

  1. Likely fit. A marketing agency very probably uses Google Ads, often GA4 or Workspace, and Looker Studio is free. BigQuery is the natural reporting store for that world.
  2. Smallest runtime. Cloud Run jobs plus Cloud Scheduler needs the fewest components to configure. Jobs bill per second and mostly fit the free tier.
  3. Cost. About $5–25 per month, against about $263 for the smallest realistic Microsoft Fabric capacity (F2, pay-as-you-go list price). Fabric also brings a SQL endpoint and governance that this design does not need.
  4. Portable code. Python, containers and an open table format; a move to another cloud replaces the storage sink, the secret client and the deploy script.
  5. Trade-off. If Acme turns out to be a Microsoft shop, Azure (Container Apps, Blob/ADLS, Key Vault, Power BI Import) is the better fit. If nobody can own a pipeline, buying a connector service (option E in section 12) is cheaper in total than building one.

⚠️ Requires stakeholder input: confirm Acme's existing cloud and BI tools before this record is accepted.


ADR-S02: Cloud Scheduler instead of an Orchestration Server

Status

Proposed

Context & Problem

Earlier versions used Dagster with a PostgreSQL metadata database, an always-on container and a webhook receiver with a queue. That is the most expensive and most operations-heavy part of the design, for three schedules.

Decision

Cloud Scheduler triggers Cloud Run jobs directly: CRM sync every 30 minutes, ads sync hourly, a daily build. Each job runs the same image with different arguments, extracts, then builds Silver. Failures alert through Cloud Monitoring (e-mail or Slack/Teams). No orchestration server, no queue, no webhook receiver.

Rationale & Trade-offs

  1. Nothing to operate between runs and nothing that runs all month.
  2. The dependency graph is short: extract, then Silver, then (daily) Gold and BigQuery. A job can run those steps in order.
  3. Idempotent landing and MERGE make a repeated job safe, so retries are simple.
  4. Trade-off. No run-history UI, lineage graph or backfill button. Run history is the Cloud Run execution list and logs.
  5. Upgrade path. When there are many more sources, dependencies or people, move the same code into Dagster. The adapters and transforms do not change.
  6. HubSpot webhooks are left out; polling every 30 minutes meets the stated need. They can be added later as a nudge.

ADR-S03: Python DataFrames and Delta Tables, no Spark, no SQL-only ELT

Status

Accepted

Context & Problem

Marketing APIs return nested, changing JSON. SQL-only ELT turns this into long nested queries that are hard to debug, and Spark is too heavy for a few gigabytes.

Decision

Transformations are plain Python modules that work on DataFrames (pandas now; Polars or DuckDB if a step outgrows memory). Silver and Gold are written as Delta tables with delta-rs in Cloud Storage. Modules can be run cell by cell in a notebook for debugging; production runs are scripts in the container.

Rationale & Trade-offs

  1. Intermediate data can be inspected; functions are unit-tested with pytest on small fixtures.
  2. delta-rs gives ACID writes and MERGE with no cluster.
  3. Trade-off. Analysts who prefer SQL use BigQuery (ADR-S06). Small Delta files need an occasional OPTIMIZE.

ADR-S04: Adapter Pattern for Sources

Status

Accepted

Context & Problem

Three sources today, more planned (TikTok Ads, Meta Ads, Dynamics 365). One bespoke pipeline per source duplicates retry logic, paging and file layout.

Decision

BaseSourceAdapter implements the shared plumbing; each source is a thin subclass.

BaseSourceAdapter (abstract)
  + test_connection()                                   abstract
  # _fetch_records(entity, start, end, cursor) -> page  abstract, ONE page
  # _auth_headers() / _refresh_credentials()            optional hooks
  + execute_http_request()   rate limit, retry with full jitter, one 401 refresh
  + extract_window()         follow paging, one landing file per page
  + extract_historical()     chunked backfill
        ^                ^                 ^
 SalesforceAdapter  HubSpotAdapter  GoogleAdsAdapter  (future adapters)

Rationale & Trade-offs

  1. The rest of the system sees only the base interface.
  2. Rate limiting, backoff, token refresh, paging and landing are written once and tested.
  3. A new source is a subclass of about 50–100 lines, 1–2 days, if it has a documented REST API with stable paging.
  4. An adapter that is told there is more data but gets no cursor raises an error instead of returning a partial window.
  5. Trade-off. A small in-house module to maintain.

ADR-S05: Keyed Pseudonyms, 21-Day Landing and an Erasure Script

Status

Proposed

Context & Problem

Salesforce and HubSpot hold personal data and GDPR gives people the right to erasure. An external token-vault database would be one more system to run. Earlier versions also claimed "zero plaintext" while keeping names, and deleted raw files after 14 days while promising replays from them.

Decision

Rationale & Trade-offs

  1. No lookup service; the pseudonym is computed in memory.
  2. This is pseudonymisation, not anonymisation; the data is still personal data. The key is access-controlled and not rotated routinely, because rotation would change every pseudonym. On a key compromise, issue a new key version and reload from the sources.
  3. 21 days covers a transformation bug found within three weeks while keeping raw personal data short-lived.
  4. Trade-off. A bug found after day 21 costs a reload and API quota.

⚠️ Requires stakeholder input: Acme's data protection contact confirms the field classification, the lawful basis and the one-month erasure assumption.


ADR-S06: Serve Gold through BigQuery

Status

Proposed

Context & Problem

Reports need a SQL-queryable store. Power BI's Direct Lake works only on Microsoft Fabric capacity, and Power BI has no DirectQuery connector for raw Delta files (to be confirmed in a proof of concept). Reading Delta files directly from BI tools generally needs an engine in front.

Decision

The daily build loads the Gold tables into BigQuery (truncate and reload, because Gold is small). Looker Studio (free) or Power BI (BigQuery connector) read BigQuery.

Rationale & Trade-offs

  1. No extra serving component; BigQuery gives live SQL to analysts.
  2. Cost stays inside the free tier at this size.
  3. Trade-off. One more copy of Gold (it is rebuildable, so it needs no backup). If Acme is Microsoft-based, the equivalent is Power BI Import or Synapse serverless (option B).