Practice assignment

Fintech backend take-home (ledger / holds)

A payments team needs a service that places holds on account funds before a card or transfer payment is settled. Two requests must never reserve the same money twice, and clients retry on timeouts. The app runs on PostgreSQL; schema is owned by Flyway; integration tests use Testcontainers (Docker required).

The starter

assignment/
├── pom.xml
├── src/main/java/com/example/holds/
│   ├── HoldService.java TODO
│   ├── HoldController.java
│   └── Model.java
├── src/main/resources/db/migration/
│   └── V1__schema.sql
└── src/test/java/com/example/holds/
    ├── HoldsIntegrationTest.java
    ├── HoldsHardeningIntegrationTest.java
    └── HoldsCaptureRaceStrictTest.java

Requirements

  1. GET /api/accounts/{id} → {id, balance, reserved, available} where available = balance - reserved.
  2. POST /api/accounts/{id}/holds {reference, amount} — amount > 0, max 2 decimals; 409 INSUFFICIENT_FUNDS if available is too small; 201 with an ACTIVE hold. Idempotent by reference (unique across accounts): same reference + account + amount → 200 with the existing hold; any other reuse → 409 REFERENCE_CONFLICT.
  3. Concurrency-safe in the database, not with a JVM lock. Several instances share one PostgreSQL. Increasing reserved and inserting the hold is one transaction.
  4. POST /api/holds/{id}/capture and /release — only ACTIVE holds move; the rest are 409 INVALID_HOLD_STATE. Parallel capture/release: exactly one succeeds, the account is debited at most once.

Grading rubric

AreaPoints
Correctness (integration tests including concurrency)30
Concurrency & transaction design (locking, retries, isolation)20
Idempotency including concurrent retries (unique constraint)10
Own tests (Testcontainers; races, rollback)15
Schema & migrations (constraints, indexes, money as numeric)10
NOTES.md: optimistic vs pessimistic, expiry of stale holds, outbox15

Levels: junior ≥ 60, mid ≥ 75, senior ≥ 85 (and a strong NOTES.md).

What reviewers look for

Common mistakes

How to run it

Docker must be running. mvn verify starts PostgreSQL with Testcontainers and runs the integration tests.

Generate a practice assignment from a payments or ledger job posting, or browse the other fintech-style tasks.

Generate one from a job ad

Related practice tasks

Frequently asked questions

Is this a real take-home from a payments company?
No. It is an original practice service in a problem space you often see in fintech-style backend roles (authorisations, ledgers, retries). It is not a company's actual hiring task.
Why Testcontainers instead of H2?
Holds and races depend on real constraints, isolation and row locks. An in-memory stand-in will not tell you if the design is safe.
What does senior look like here?
Provided tests green is not enough. Senior needs a justified locking story, a unique constraint for retries, and NOTES.md on expiry and an outbox.

Practice only. This is an original HireCheck practice assignment, not a real employer's take-home, and it is not affiliated with any company mentioned as a role example.