1. Courses
  2. JavaScript Deep Dive
  3. Capstone

Capstone project for JavaScript Deep Dive

Build the nightly store sales summary

Mangrove Market's head office wants one reliable number per store each morning. Build a small Node.js package in ES modules that pulls yesterday's sales for 12 stores from a fake local API (one store is slow, one fails with 503 now and then), works out each sale's business day in its store's own time zone (the stores are in three zones, east and west of UTC), skips voided sales, applies the festival and staff discount rules from the course, and totals everything in integer cents. Calls must run with a per-request timeout, one retry for temporary failures and at most 4 requests in flight, and a failing store must appear in the report as missing with its error instead of breaking the whole run. Print the summary sorted by total, formatted in US dollars and in one local currency of your choice, and back it with Vitest tests. Plan for 3 to 5 hours.

What you hand in

  1. A Git repository with package.json ("type": "module"), src/ with small named-export modules (api client, rules, summary, format) and a runnable bin script
  2. A Vitest test suite with behaviour-named tests and a coverage report of at least 90% of lines in src/
  3. A sample run of the summary printed to the terminal, including one store reported as missing
  4. A short README that states your rounding rule, where each store's time zone comes from, your timeout, retry and concurrency settings, and one bug you found and fixed with a test

Check your work

Tick each item when your project meets it. Be strict: this is the rubric the reviewer uses.

  • Every amount is an integer number of cents from parsing to the final total, and money is formatted only at the display step with Intl.NumberFormat
  • Each sale's business day is computed with Intl.DateTimeFormat and its store's own timeZone, with a test that covers an after-midnight sale and a late-evening sale west of UTC
  • No function mutates its input: a test deep-freezes or snapshots the input data and proves it is unchanged
  • Discount rules are pure functions made by small factories, and a rule without a cap cannot produce NaN
  • Store calls run with AbortSignal.timeout, retry only timeouts and 5xx responses, and never exceed the concurrency limit, which a test proves
  • One failing store does not stop the run: results are collected with Promise.allSettled and the failure is reported with a clear message
  • Errors from the API client are wrapped in a custom error class with the original kept as cause, and nothing is swallowed by an empty catch
  • Tests have behaviour-sentence names, use a mock or fake for the API, and the coverage threshold is enforced in the test config

0 of 8 checked

Model answer

The model answer opens once your capstone passes the review, so you can compare your work with an outline of a strong submission.

Hand in your capstone

Your links are checked automatically, then the work is scored against the rubric above, item by item, with comments. A pass counts toward the course certificate and shows on your profile.

Loading…