All practice tasks

Coding (Platform)

Project Directory Adapter

React + Fastify · Easy · Api Integration

The supplied browser picker and HTTP directory both work. The connecting client adapter does not preserve query text and turns failed requests into successful empty lists. Repair that boundary and verify the result through the running screen and service.

Task

Connect the existing directory to the browser: encode queries, map items and propagate HTTP failures without changing either application.

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 types into the existing Search projects control. Use the supplied initial list; this task does not require an API request.
  • 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

  • Show non-archived projects whose title contains the trimmed search text, ignoring letter case.
  • An empty or whitespace-only query shows every active project.
  • Order the visible projects by ASCII ID.
  • Show No projects when nothing matches.
  • Editing the query updates the list without replacing the whole screen or losing the input state.
  • Keep the existing control labels and stable row identity.
  • 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.
  • Retry HTTP 503 at most once, with the exact same request body and key.
  • Do not retry HTTP 400, 401 or 409, or an aborted operation.

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/tests/candidate.test.js — Add DOM-level regression tests using fixture(t), deferred() and assert.
  • 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

Project Directory Adapter 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 easy 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.