Skip to content
API serviceIntermediate

Inventory Workflow Service

A small shop tracks stock in a shared spreadsheet, so counts drift, reorders are missed and nobody can say who changed what.

Estimated effort
18-24 hours
Difficulty
Intermediate
Stack
TypeScript or Python, REST API, SQL database, OpenAPI, Automated tests

Project brief

Brightwater Outfitters is a fictional shop selling outdoor clothing and equipment from one small warehouse and a shop floor. Three staff members record stock in a shared spreadsheet. Counts are often wrong because two people edit at once, returns are added twice, and nobody notices when a popular item is about to run out. The owner, Imogen Hale, wants a small service that her staff can use from a simple front end that another contractor will build later.

You are building the service only. It must record stock movements (goods received, sales, returns, manual corrections), keep the current quantity of each item, refuse any movement that would make stock negative, and report which items have fallen below their reorder level. Every movement records who made it, when and why, and the history can be queried. Reorder levels are set per item. Staff must never see an incorrect quantity because of two people acting at the same time.

Use only synthetic data: items such as BW-1042 'Trail rucksack 30L' or BW-2210 'Merino base layer', and fictional staff accounts. Do not use real products, people or contact details. Where the brief is silent, write the question down, make a stated assumption and carry on. Parts of this project suit AI assistance, such as drafting acceptance criteria or reviewing the API design. Record every prompt you use, review the output against the brief and justify what you accepted, changed or rejected.

Skills you will practise

  • Turning a business problem into requirements and acceptance criteria
  • Designing a small REST API and documenting it with OpenAPI
  • Modelling stock movements and enforcing invariants in a database
  • Handling concurrent updates safely
  • Reviewing AI-generated code and recording your decisions

Deliverables

  • A requirements note with acceptance criteria and open questions
  • An OpenAPI description of the service
  • A working service with a migration and seed script using synthetic data
  • An automated test suite covering the rules and error cases
  • A prompt log with your review notes for every AI-assisted change
  • A short README explaining how to run and test the service

Prerequisites

  • Comfortable building a small HTTP service in one language
  • Basic SQL, including transactions
  • Completed Problem Framing and Writing Requirements, or equivalent experience
  • A local database you can create and discard

Helpful lessons: Problem Framing, Stakeholders and Workflows, Requirements, Acceptance Criteria.

Suggested architecture

A layered service: HTTP handlers validate requests and translate errors, a service layer applies the business rules, and a repository layer talks to the database. Current stock is derived from, and checked against, an append-only table of movements.

ComponentResponsibility
API layerValidates input, maps domain errors to HTTP statuses and error bodies, and exposes the OpenAPI-described endpoints.
Stock serviceApplies rules: no negative stock, valid movement types, reason required for corrections.
RepositoryReads and writes items and movements, and runs each movement and quantity update in a single transaction.
DatabaseStores items, current quantities and the append-only movement history, with constraints as a second line of defence.
Reorder reportLists items at or below their reorder level, computed from current quantities.
Audit logRecords who made each movement, when and why, and supports queries by item and date range.
Main request path
  1. Request

    POST a movement for one item

  2. Validate

    Check fields, type and reason

  3. Apply rules

    Check the result would not be negative

  4. Transaction

    Insert the movement and update the quantity together

  5. Respond

    Return the new quantity or a clear error

Milestones and tasks

  1. 1

    Frame the problem

    Agree what the service must and must not do before writing code.

    • Write a problem statement and list the users and their workflows.
    • Write acceptance criteria for recording movements, reorder flags and history.
    • List open questions and the assumptions you will use until they are answered.
    • If you use an AI assistant, log the prompt and note which of its suggestions you kept and why.
  2. 2

    Design the contract and data model

    Fix the API and the schema so the rules can be enforced in one place.

    • Draft the endpoints and error responses in an OpenAPI file.
    • Design the tables and the constraints that stop negative quantities.
    • Review the contract for naming, pagination and retry behaviour, and record changes.
    • Write a short decision record for how you derive current stock.
  3. 3

    Build the core rules

    Implement movements and quantity checks safely.

    • Create the migration and a seed script with synthetic items.
    • Implement the movement endpoint with validation and a single transaction.
    • Handle two simultaneous movements for the same item without losing either.
    • Review any AI-generated code line by line before committing.
  4. 4

    Reporting and history

    Let staff see what needs reordering and what happened.

    • Implement the reorder report and the history query with filters and paging.
    • Return consistent errors for unknown items and invalid dates.
    • Check the report against hand-calculated values for the seed data.
  5. 5

    Test, document and hand over

    Prove the behaviour and make the service usable by someone else.

    • Complete the automated tests and check the error paths.
    • Write the README with set-up, run and test instructions you have followed from scratch.
    • Assemble the prompt log and your review notes.
    • Walk through the submission checklist.

Tests to write

  • T1Recording goods received increases the quantity by exactly the amount received.
  • T2A sale larger than the current quantity is refused and leaves the quantity unchanged.
  • T3A sale exactly equal to the current quantity is accepted and leaves zero.
  • T4Two simultaneous sales that together exceed stock result in only one succeeding.
  • T5A manual correction without a reason is rejected.
  • T6A movement for an unknown item returns a not-found error and writes nothing.
  • T7The reorder report includes items at the reorder level and excludes items above it.
  • T8The history for an item lists its movements in order, with who and why.
  • T9Invalid types, zero or negative amounts and missing fields return validation errors.

Submission checklist

Assessment rubric

Criteria, weights and descriptors for each level of performance
CriterionWeightStrongAdequateNeeds work
Requirements and acceptance criteria20%Problem, users and workflows are clear; criteria are testable with concrete values; open questions and assumptions are explicit.Criteria exist and mostly testable, but some are vague or assumptions are unstated.Requirements are a restatement of the brief; criteria cannot be tested.
API and data design20%Consistent contract with clear errors; schema constraints back up the rules; decisions are recorded.Contract works but has inconsistencies or unspecified failure behaviour.Endpoints are ad hoc; rules live only in application code with no constraints.
Correctness and concurrency25%Stock can never go negative, simultaneous movements are handled with evidence, and errors are consistent.Rules work in the single-user case; concurrency is considered but not demonstrated.Negative stock or lost updates are possible.
Testing20%Tests cover rules, boundaries, errors and a concurrency case, and fail when the code is broken.Main paths tested; few boundary or error cases.Little or no automated testing.
AI use, review and documentation15%Prompt log is complete; each accepted change is justified; README lets a stranger run the project.Prompt log exists but justifications are thin; README is partly complete.AI output is used without review or record; no usable README.
Written by
PromptFable Editorial
Last updated 13 Nov 2026
Review
Not yet reviewed
All practical projects

PromptFable is independent and is not affiliated with, endorsed by or sponsored by Anthropic, Google, OpenAI or any other vendor. Claude, Gemini, Google AI Studio and other product names are trademarks of their respective owners.