KatInterview

Design a Time-Tracking and Wage Calculation Backend

System DesignModel answer
MediumModel answerSystem Designbackendscalabilitydata-modeling

Last updated

Build a backend that records employee time punches, computes hours worked per pay cycle, calculates wages, and handles burst traffic and external data feeds.

You're building the backend for a workforce time-tracking and wage calculation platform.

The system must support:

  • Recording employee time punches (clock in, clock out, break start, break end) from various sources: physical kiosks, mobile apps, web portals, and offline devices that sync later
  • Calculating total hours worked for each employee within a pay cycle
  • Computing gross wages based on hours worked, hourly rates, overtime rules, shift premiums, and holiday pay
  • Managing bursts of concurrent punch submissions (e.g., shift changes when hundreds of employees clock in simultaneously)
  • Ingesting time records from external systems or legacy databases without creating duplicates

Your design should address:

  1. API design: What endpoints do you expose, and what guarantees do they provide?
  2. Data modeling: How do you store time punches, shifts, wage rules, and payroll outputs?
  3. Architecture: What components do you need, and how do they interact?
  4. Consistency and correctness: How do you prevent lost or duplicate punches? How do you ensure payroll results are auditable and reproducible?
  5. Scalability: How does your system handle 10,000+ writes per second during peak times?
  6. Integration: How do you safely import records from external sources?

Discuss trade-offs, failure modes, and optimization strategies.

Hints

Hint 1

Think about idempotency: how can clients safely retry punch submissions without creating duplicates?

Hint 2

Separate the real-time punch ingestion path from the batch payroll computation path — they have different consistency and latency needs.

Hint 3

Consider using an event log or message queue to absorb traffic spikes and decouple write acknowledgment from downstream processing.