CodingNeed.

BUILD SOMETHING YOU CAN EXPLAIN

Project: a dependable expense API

A client loses the response to a successful write. How do you let it retry without creating a duplicate expense? Build a small API, test the failure story, and explain what changes when the service gains a second process.

What you will build

The reference implementation includes an authenticated create endpoint, input validation, idempotency conflicts, cursor pagination, a public health endpoint, bounded storage, and automated HTTP tests. It uses Node’s built-in libraries. Records are stored in memory and disappear on restart; it is a teaching application, not a durable production backend.

Your milestones

  1. Describe the contract. Write valid and invalid request examples. Store monetary amounts as integer cents.
  2. Make a write repeatable. Reuse a stable request key and return the stored result on a matching retry.
  3. Defend the boundaries. Reject unknown fields, missing credentials, oversized bodies and a key reused for different data.
  4. Run the tests. Use npm test with Node.js 22 or a supported newer LTS. Study the simultaneous-retry test.
  5. Deploy a separate learning instance. Follow the included README, configure its token privately, and verify the HTTPS health endpoint.
  6. Plan persistence. Design a transaction and unique owner/key constraint for the database version. Explain how two processes coordinate.

How to review your work

  • Show that two identical requests create one record.
  • Show a conflicting retry returning an error.
  • Demonstrate a zero-value expense and an invalid fractional value.
  • Explain the difference between browser validation, authentication and ownership checks.
  • Record the restart limitation and the database design needed to remove it.

Keep the API token out of browser code. A React client needs an authenticated server adapter. The download includes the source, tests, setup instructions and an MIT license for the project sample.

Continue learning

Read the idempotency guide or return to the JavaScript path. Use your interview transcript to rehearse the design trade-offs.

Essential cookies keep your account signed in. Optional analytics is not configured on this site. Your choice does not affect access to lessons.

Read the Privacy Policy. You can change this choice in the footer.