KatInterview

Turning JSON Point Data into Lines via a Third-Party Drawing Service

System DesignModel answer
MediumModel answerSystem Designapi-integrationjson-parsingidempotency

Last updated

Describe how to parse JSON point data, decide how points connect, build the drawing service's request, and recover safely from failures without creating duplicate drawings.

You are given a JSON file containing point data and access to a documented drawing service. The service takes a request body and renders lines or a map from it. Write a small program (or describe its design) that reads the points and asks the service to draw them connected together.

The following details are not given up front. They live in the service's documentation and in a sample request body, which you are expected to read before deciding anything:

  • the service's endpoint, authentication method and request schema
  • the coordinate reference system (plain Cartesian plane versus latitude/longitude)
  • the rules for which points get connected

Walk through your approach to:

  1. Validating and interpreting the JSON input.
  2. Deciding how points are connected: input order, grouped paths, or explicit edges. Also decide whether a path closes back on its first point.
  3. Building the request body from the documented schema.
  4. Handling failures, including which ones are retried and how you avoid drawing the same thing twice.
  5. Confirming that the finished drawing is actually correct.

State which questions you would resolve from the documentation and which you would ask the interviewer.

Hints

Hint 1

Before writing any code, list the unknowns: coordinate order and units, connection rule, closed or open shape, and request schema. Take each answer from the docs and sample body, not from assumption.

Hint 2

Keep three layers apart: a validated internal model (points and segments), an adapter that converts it to the service's schema, and a client that handles transport, auth and retries. Then a schema change only touches the adapter.

Hint 3

Classify failures: invalid input and 4xx errors are not retried, 429 and 5xx and timeouts are retried with backoff. For a non-idempotent create call, use an idempotency key or check for an existing drawing before resending.