Design a Versioned Recipe Store with Search and Rollback
Design a Versioned Recipe Store with Search and Rollback
Design and implement the core logic for a recipe management service. The service should support basic CRUD operations, searching, and versioning with rollback capabilities.
Constraints & Assumptions:
- A recipe has at least a name and a body or payload.
- Recipe names identify logical recipes. Updating a recipe may create a new version depending on the requirements.
- You can choose in-memory data structures unless the interviewer asks for persistence.
- Prefer clear APIs and testable behavior over production infrastructure.
Part 1: Basic Recipe CRUD
Provide APIs to add, get, update, and delete recipes. Make recipe identity and name handling explicit. Consider how to manage logical recipes versus their versions.
Part 2: Search and List
Add the ability to list all recipes and search for recipes by name, content, or other relevant fields. For an assessment, a simple scan might be acceptable if you discuss when an index would be necessary.
Part 3: Users, Versions, and Rollback
Extend the design to support recipes belonging to specific users. Implement functionality to retrieve specific versions of a recipe and to roll back a recipe to a previous version.
Follow-up Questions:
- How would your design change if search needed to be fast over millions of recipes?
- How would you expose this as HTTP APIs?
- What would you store to audit who changed a recipe and when?
- How would you handle concurrent updates to the same recipe?
AI interview prep
Core dilemma
Managing the lifecycle of logical entities (recipes) while maintaining a history of their states (versions) and enabling efficient retrieval and manipulation of this history.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Design a Versioned Recipe Store with Search and Rollback
Design a Versioned Recipe Store with Search and Rollback
Design and implement the core logic for a recipe management service. The service should support basic CRUD operations, searching, and versioning with rollback capabilities.
Constraints & Assumptions:
- A recipe has at least a name and a body or payload.
- Recipe names identify logical recipes. Updating a recipe may create a new version depending on the requirements.
- You can choose in-memory data structures unless the interviewer asks for persistence.
- Prefer clear APIs and testable behavior over production infrastructure.
Part 1: Basic Recipe CRUD
Provide APIs to add, get, update, and delete recipes. Make recipe identity and name handling explicit. Consider how to manage logical recipes versus their versions.
Part 2: Search and List
Add the ability to list all recipes and search for recipes by name, content, or other relevant fields. For an assessment, a simple scan might be acceptable if you discuss when an index would be necessary.
Part 3: Users, Versions, and Rollback
Extend the design to support recipes belonging to specific users. Implement functionality to retrieve specific versions of a recipe and to roll back a recipe to a previous version.
Follow-up Questions:
- How would your design change if search needed to be fast over millions of recipes?
- How would you expose this as HTTP APIs?
- What would you store to audit who changed a recipe and when?
- How would you handle concurrent updates to the same recipe?