All practice tasks

Coding (Platform)

Reliable Project Search

Express + React · Medium · Async State

The React screen and Express service already run separately. Their integration contains transport and state regressions. Prioritize tenant isolation and the service consistency boundary. Verify the user-visible result through the existing React client.

Task

Deliver one working browser-to-service flow, not two disconnected implementations. Deliver a search screen that keeps the results for the user’s latest query even when an older request finishes later, and clearly shows whether that latest search is loading, empty or failed. Repair tenant isolation and pagination as one consistent pipeline. Preserve existing authentication and error behavior.

Contract

  • Browser — Starting data: initialRows is the supplied project list. Do not mutate it. id identifies a project; title is its visible name; archived hides it from the active list. seats is the available seat count; version identifies the last server version of that project.
  • Browser — User action: The user changes the Search projects text. The initial screen starts with an empty query.
  • Browser — Provided search API: api.list(query, {signal}) returns a Promise of project rows. Pass the trimmed query and an AbortSignal. A successful result is the next project list. A failure is an error, not an empty successful result.
  • Browser — Timing guarantees: API operations may resolve or reject in any order, even after cancellation. The fixture controls completion order; no real network is used.
  • API — Request: GET /projects reads the supplied project repository. Query parameters are optional.
  • API — Query parameters: q — title text to search for. Default: empty string. Trim whitespace; maximum length: 80 characters. limit — number of rows requested. Default: 20; allowed integers: 1..50. offset — number of matching rows to skip. Default: 0; allowed integers: 0..10000. Numeric parameters must contain digits only. For example, 1.5, -1 and abc are invalid.
  • API — Authentication: Authorization: Bearer fixture-alpha identifies tenant alpha; fixture-bravo identifies tenant bravo. The supplied authentication helper resolves the tenant. A query/body field is not an identity source.
  • API — Repository records: Each project has id, title, tenant, archived, seats and version. The fixture provides the data. Use its repository; no external database is required.
  • Connecting the two layers: web/src/api-client.js is the browser-to-HTTP adapter. api.list reads the HTTP response’s items array. api.reserve maps the HTTP receipt’s remaining field to the component’s seats field.

Acceptance criteria

  • Start the initial empty-query search and a new search whenever the query changes.
  • Clear the previous error and show Loading while the current request is pending.
  • Cancel the superseded request.
  • Only the latest request may replace the rows or show an error.
  • Latest request succeeds: display its active rows and stop loading; an empty list shows No projects.
  • Latest request fails: show Search failed and stop loading.
  • An older success or error must not change the current screen.
  • At component unmount, cancel outstanding work.
  • Ignore later results; do not update a closed or disposed screen.
  • Return HTTP 200 with {total, items, nextOffset}.
  • items contains only {id, title, seats, version}. Do not expose the internal tenant field.
  • Keep only the authenticated tenant’s non-archived projects.
  • Match the title against the trimmed query without regard to letter case.
  • Sort matching projects by ASCII ID before taking the requested page.
  • total is the number of all matching projects before pagination, not the page length.
  • Skip offset matches and return at most limit items.
  • nextOffset is offset + items.length only when another matching item remains; otherwise it is null.
  • An exhausted page has items: [] and nextOffset: null, while keeping the full total.
  • Invalid query: HTTP 400 with {code: "INVALID_QUERY"}.
  • Missing or unknown bearer token: HTTP 401 with {code: "UNAUTHORIZED"}.
  • URL-encode search text; it must not become extra query parameters.
  • Reject failed HTTP responses with their status. Do not hide errors as an empty successful list.

Constraints

  • At most 200 rows; IDs are unique ASCII strings and seats are non-negative integers. Input props must not be mutated.
  • Keep the Search projects label, data-id row identity and accessible status messages.
  • At most 10000 projects in the repository; query length at most 80; page size at most 50.
  • Use the supplied repository and authenticated tenant resolver. No external database, network service or production credential is needed.
  • Directory reads must not mutate stored records or expose the internal tenant field.
  • All services run inside the test process on loopback. No external deployment, database or cloud account is required.

Editable files

  • web/src/ProjectApp.jsx — Repair the component state, lifecycle and API coordination.
  • web/src/ProjectRows.jsx — Provided row rendering; preserve identity, accessibility and button semantics.
  • web/src/helpers.js — Optional pure helpers; not a replacement for framework lifecycle handling.
  • web/tests/candidate.test.js — Add DOM-level regression tests using fixture(t), deferred() and assert.
  • server/src/app.js — Framework router/controller, middleware and error response integration.
  • server/src/service.js — Repair filtering/pagination or the reservation consistency boundary.
  • server/src/helpers.js — Optional helpers; import from service when needed.
  • server/tests/candidate.test.js — Add the required regression tests here using fixture(t), assert and node:test.
  • web/src/api-client.js — Repair URL encoding, error propagation and response DTO mapping.
  • integration/candidate.test.js — Add cross-layer regressions; reuse the local integration fixture.

What this task practices

Reliable Project Search is a coding (platform) interview exercise that trains prompt interpretation, explicit assumptions, a concrete response, and a clear explanation of tradeoffs. The catalog marks it as medium difficulty. It focuses on Technical Reasoning, Testing, Validation. The signed-in workspace provides the tools for the round and evaluates the attempt against task-specific criteria. Reference solutions, hidden checks, evaluator instructions, and candidate work remain private.

Sign in to startThe workspace and evaluation open after sign in.