Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan

Build Idempotent Payment API Pipeline

EasyPipelines00:00
Practice interviewer
In session
5 left
00:00

Your question is Build Idempotent Payment API Pipeline. Take a moment with it on the right.

Talk me through your thinking if you like. When you're confident, submit your answer and I'll grade it like a real screen (7/10 or better passes).

You need to log in / sign up to chat or submit.

Problem

Context

PayFlow, a B2B payments platform, currently receives charge requests from web and mobile clients through a synchronous API backed by PostgreSQL. During client retries, network timeouts, and Airflow-triggered replay jobs, the system occasionally creates duplicate payment records and downstream settlement events.

You need to design an idempotent API ingestion pattern that guarantees a payment request is processed once per client-supplied idempotency key while still supporting retries, auditability, and downstream ETL into the analytics warehouse.

Scale Requirements

  • Traffic: 2,500 API requests/second peak, 400 requests/second average
  • Payload size: 1-4 KB JSON per payment request
  • Latency target: API response p95 < 250 ms
  • Duplicate prevention window: 24 hours per idempotency key
  • Storage: 50M payment requests/day, 2 TB/month raw + audit logs
  • Downstream freshness: analytics tables updated within 5 minutes

Requirements

  1. Implement an API endpoint that accepts an Idempotency-Key header and safely handles client retries.
  2. Persist request state so the same key returns the original response instead of creating a second transaction.
  3. Prevent race conditions when two identical requests arrive concurrently.
  4. Publish successful payments to the event pipeline for downstream ETL and reconciliation.
  5. Store raw requests, processing status, and response payloads for audit and replay.
  6. Add data quality checks to detect duplicate transactions, mismatched payloads for reused keys, and missing downstream events.
  7. Describe how orchestration would backfill failed warehouse loads without re-charging customers.

Constraints

  • AWS-based stack only; no multi-region active-active requirement
  • PCI-sensitive fields must be tokenized; raw card data cannot be stored in logs or Kafka
  • Incremental infrastructure budget: $15K/month
  • Existing team uses Python, Airflow, PostgreSQL, and Kafka; avoid introducing niche tooling
  • Payment records must be retained for 7 years for audit