This assessment is for a Mid-Senior Backend Engineer role focused on production systems.
- Primary stack:
Node.js(TypeScript recommended) - Databases: PostgreSQL or MySQL
- Expected effort: 5-7 hours
AI tools are allowed and encouraged. We are evaluating backend fundamentals, system thinking, and production readiness, not speed alone.
Build a backend service for a multi-tenant FlashSale Inventory & Orders platform used by multiple stores.
Each tenant should be able to:
- Manage products and inventory
- Configure flash-sale campaigns
- Accept customer orders during campaign windows
The system must handle high-concurrency purchase attempts without overselling.
Implement product management with tenant isolation.
Minimum product fields:
idtenant_idskunamepricestock
Requirements:
- Tenant isolation must be enforced server-side
pricemust be stored safely for monetary operations (avoid floating-point errors)
Implement campaign creation and activation logic.
Minimum campaign fields:
idtenant_idproduct_idstart_timeend_timemax_per_user(optional)
Requirements:
- Campaign windows must be time-bound and validated
- Time values must be stored in UTC and returned in ISO 8601 format with timezone
- Boundary behavior must be explicitly documented and implemented consistently (
start_time/end_timeinclusivity rules)
Implement order placement for active campaigns.
Order requirements:
- No overselling (
stockmust never go below zero) - Respect
max_per_userwhen configured - Support idempotent retries from clients using an idempotency key
- Ensure there is exactly one source of truth for stock deduction
Support these statuses:
PENDINGCONFIRMEDREJECTED
Requirements:
- Rejected orders must include a machine-readable reason code
- Error responses must include:
code,message,request_id
Provide order listing per tenant with:
- Pagination
- Filtering by status
- Filtering by date range
Requirements:
- Pagination must be deterministic and stable across pages
- Sorting behavior must be documented
- Design for concurrent requests on the same product/campaign
- Demonstrate how race conditions are prevented
- Handle transient DB/network failures gracefully
- Document retry behavior and where retries are safe
- Define an idempotency key retention/TTL strategy
- Structured logging
- Health endpoint
- At least 2 meaningful metrics (examples: request rate, rejection reason counts, p95 latency)
- Support request correlation ID from header; generate one if missing
- Solution should support at least 200 req/s burst locally, or include a reasoned design and bottleneck analysis
- Explain horizontal scaling strategy and likely bottlenecks
- Input validation on all write endpoints
- Tenant access checks must not rely on client-provided trust alone
- Containerized local setup (
Docker/docker-compose) - DB schema + migrations included
- API documented (OpenAPI spec or Postman collection)
- Tests:
- Unit tests for critical business rules
- Integration tests for high-risk flows (especially order placement and idempotency)
You may use AI tools.
Include:
-
AI_USAGE.md- Which tools you used
- High-level prompt categories
- What you accepted/changed/rejected and why
-
Ownership statement in your submission:
- "I can explain and defend every architectural and implementation decision in this solution."
Submit a repository containing:
- Source code
README.mdwith setup/run instructionsARCHITECTURE.mdcovering:- Data model and indexing choices
- Concurrency strategy
- Scaling strategy
- Failure modes and mitigations
AI_USAGE.md- Tests and test run instructions
- API specification/collection
- Keep assumptions explicit and documented.
- Prioritize production-ready decisions over excessive framework complexity.
- We value clear thinking and consistent behavior under load more than feature volume.