You are given a take-home assignment to build a small backend server. The goal is not algorithmic difficulty but demonstrating solid software engineering practices, project structure, and test design.
Design an HTTP service that exposes several APIs to perform operations on 2D matrices of integers. At minimum, support:
-
Matrix addition
-
Matrix subtraction
-
Matrix transpose
-
Horizontal flip (reverse columns)
-
Vertical flip (reverse rows)
Assume:
-
Clients send requests over HTTP using JSON.
-
A matrix is represented as a 2D JSON array of integers, e.g.
[[1, 2], [3, 4]]
.
-
For binary operations (like addition), the client sends two matrices in the request.
-
The service should validate input (e.g., shape compatibility for addition) and return clear error responses for invalid input.
-
Performance is not the primary concern; correctness, clarity, and testability are.
Describe in detail:
-
Overall architecture and project structure
for this server (layers, modules, packages, etc.).
-
API design
: the endpoints you would expose, HTTP methods, and example request/response payloads for each operation.
-
Validation and error handling
: how you handle malformed JSON, non-rectangular matrices, dimension mismatches, and unexpected server errors.
-
Testing strategy
: what unit tests, integration tests, and possibly end-to-end tests you would write, and how you would organize them.
-
Any
additional engineering considerations
you think are important (e.g., logging, configuration, extensibility for adding new matrix operations later).