Workbench / Volume 2 Exercises: The Web Frontend
V2·33
Frontend Projects
Exercises for Volume 2, chapter 33: checkpoints for the eight frontend projects that grow one tiffin-centre ordering product (an accessible static menu site, a plain-JavaScript cart, the ordering SPA, an offline-first PWA, a server-rendered storefront with a performance budget, a small design system, live order tracking, and the production pipeline), plus the working method and portfolio. 9 theory questions, 9 programming checkpoints, 3 integration projects, the practices the chapter leaves out, and 5 senior-level exercises.
Start here: how this chapter's exercises work
This chapter is projects, so its exercises work differently, as in Volume 1's projects chapter. They don't ask you to build the eight projects again. They're checkpoints: each one checks that you understood a project's hard part before you build it (theory) and while you build it (programming).
- Theory (one per project, plus the working method): the decisions and failure modes each project exists to teach, tied back to the chapters that cover them.
- Programming checkpoints: a small, self-contained piece of each project, often its test harness or its trickiest part, with real output. Most outputs are measurements this volume's labs and exercises already made (each one names its source). The cart's money table was computed for this chapter. If your checkpoint passes, the project's foundation is sound.
- Integration projects join several projects into one system. They're the cumulative set for this chapter and draw on all of Volume 2's chapters 12–32 (plus Volume 1).
Senior exercises are about reviewing, scoping, presenting and defending the work.
Coverage map.
| Chapter component | Theory | Checkpoint |
|---|---|---|
| the working method; definitions of done | T1 | P9 |
| Project 1: accessible static menu site | T2 | P1 |
| Project 2: interactive cart in plain JavaScript | T3 | P2 |
| Project 3: the ordering SPA | T4 | P3 |
| Project 4: offline-first PWA | T5 | P4 |
| Project 5: server-rendered storefront with a performance budget | T6 | P5 |
| Project 6: a small design system | T7 | P6 |
| Project 7: live order tracking | T8 | P7 |
| Project 8: the production pipeline | T9 | P8 |
| portfolio checklist and mastery levels | T1 | P9, S5 |
Theory
T1. The working method and definitions of done
- The chapter asks you to write the definition of done before coding, build the thinnest end-to-end slice first, measure instead of guessing, keyboard- and screen-reader-test every screen, and write a README per project. For each, give the failure it prevents (building the wrong thing, integration surprises at the end, "it feels fast" claims, accessibility retrofits, unexplainable portfolio work).
- Rewrite these vague goals as measurable checks: "the menu should be accessible", "the cart should be fast", "checkout should be reliable", "the app should work offline", "deploys should be safe".
- The mastery mapping says projects 1–3 with their checks are L2, stretch goals with explained measurements are L3–L4, and defending the architecture decisions of projects 5–8 is L5. What distinguishes L4 from L5 in an interview about these projects?
T2. Project 1: an accessible static menu site
- The project is plain HTML and CSS with no JavaScript. Why start there (semantic HTML gives keyboard support, accessibility, performance and resilience for free: chapters 12, 13, 20), and which choices matter most: landmarks and headings, the menu as a list or table, a real
<form>with labels andautocomplete, and images with dimensions? - The definition of done includes 0 axe violations, keyboard completion of the booking form, no horizontal scrolling at 320 px, working at 200% text zoom, Lighthouse Accessibility 100 and Performance ≥ 95, and no validator errors. Which of these does axe check, and which need manual or other tools (chapter 20's lab: axe caught five of nine problems)?
- Design the menu markup: is a dish list better as
<ul>of<article>s or a<table>? How do you show veg/non-veg, spice level and price accessibly?
T3. Project 2: an interactive cart in plain JavaScript
- The milestones are state in a plain object, one
render()(UI = f(state): chapter 21), event delegation,localStoragepersistence, coupon validation and money in integer paise withIntl.NumberFormat. Explain why each matters and what goes wrong without it. - P2 computed the money table: in floating point,
0.1 + 0.2is0.30000000000000004; in paise, ₹55 with a 10% coupon is ₹49.50 and its 5% GST (247.5 paise) rounds to ₹2.48, total ₹51.98; 3 × ₹19.99 = ₹59.97 → coupon ₹53.97 (5,397.3 paise rounded) → total ₹56.67;Intl.NumberFormat('en-IN')formats ₹12,34,567.50 with Indian grouping (en-US gives ₹1,234,567.50). Which rounding rule do you use and where (per line or on the total), and how do you document it? - "No
innerHTMLwith user-provided data" and "screen readers announce cart updates through a polite live region": how do you implement each in plain JavaScript (chapters 28 and 20)?
T4. Project 3: the ordering SPA
- The milestones: a typed API layer with runtime validation (Zod), a mock API with MSW, routing with deep links, server state through TanStack Query or Angular
httpResource, loading/error/empty states, checkout validation, and optimistic favourites with rollback. Map each to the chapter that taught it and the bug it prevents. - The definition of done includes "no race conditions when switching dishes quickly (chapter 22's lab)" and "the Profiler shows no component re-rendering on unrelated state changes". Explain how each is tested, using chapter 22's fetch race ("Masala dosa" shown for dish 2 without the ignore flag) and chapter 25's selector results (3 needless renders vs 0).
- The stretch goal builds the SPA in both React and Angular. What should the comparison measure (code size, bundle size, test effort, accessibility outcomes, how each framework's defaults helped or hurt: chapter 23's C2), and what conclusions are fair?
T5. Project 4: an offline-first PWA
- The milestones: manifest and icons, a service worker with cache-first shell and network-first menu data, an offline banner, offline orders queued in IndexedDB, and an "update available, reload" prompt. Using chapter 29's results, list the bugs each milestone must avoid (P1: reload didn't activate the waiting worker; P2: network-first cached a 500 and served it offline; the lab: first visit not controlled without
clients.claim()). - "An order placed offline is delivered exactly once after reconnecting." Explain the idempotency key flow end to end (client generates, stores with the queued order, sends on every retry; server stores processed keys and returns the original result for repeats), and how you test it (chapter 29's P3).
- "Deploying a new version never leaves a tab broken" links to chapter 31's lab. What must both the deploy (asset retention) and the service worker (update flow) do for this to hold?
T6. Project 5: a server-rendered storefront with a performance budget
- Choose a rendering strategy per route (home, menu, dish pages, reviews, cart, checkout) using chapter 24's T5 table, and justify streaming for reviews and islands or Server Components for static content.
- The budget: on a throttled mid-range phone, LCP < 2.5 s, CLS < 0.1, INP < 200 ms for adding to cart, menu route < 100 KB of compressed JavaScript, no hydration mismatch warnings, and Lighthouse CI failing the build on budget breaches. Which chapter results tell you where the time and bytes usually go (chapter 24's lab: islands 132 ms vs full hydration 1,395 ms; chapter 27's lab: LCP 10,904 → 172 ms; chapter 27's P4: lodash 72 KB vs 2.9 KB)?
- Chapter 26's P7 measured 16–22% run-to-run variance in lab LCP. How do you make the budget gate reliable (medians, deterministic byte budgets as errors, timing budgets as warnings with headroom, comparing to the base branch)?
T7. Project 6: a small design system
- Tokens as CSS custom properties with light and dark themes, accessible primitives (Button, Input, Select, Dialog, Tabs, Toast) using native elements or headless libraries, Storybook with every state, visual regression tests, and a package consumed from the app in a monorepo. Map each to chapter 21's T3–T4 and S1 and chapter 30's T2–T3.
- "Visual tests catch a deliberate 1-pixel padding change": chapter 26's P5 measured a 10 → 11 px padding change as 809 differing pixels at Playwright's default threshold of 0.2 (caught), but a colour change from
#8a4b08to#9a5b18as 0 at 0.1. What does that mean for your design system's visual test configuration? - Stretch: ship primitives as Web Components for a second framework. What did chapter 21's P9 find about form association, events and accessibility across shadow roots, and what must you add for
<tb-qty>to be a proper spinbutton?
T8. Project 7: live order tracking
- Milestones: SSE with
Last-Event-IDresume for customers, a WebSocket (or SSE + POST) for the kitchen, status as a shared state machine, and reconnection with backoff and a visible indicator. Why SSE for customers and what does the kitchen need beyond it (chapter 19's T8)? - "Killing and restarting the server mid-order loses no status update": what server-side design makes resume work (event ids from a persistent log, replaying events after
Last-Event-ID, heartbeats), and what client-side behaviour (EventSource's automatic reconnect,retryfield, resync on reconnect: chapter 17's P9)? - "The UI never shows impossible states (cooking and delivered at once)": how does a shared state machine (chapter 25's T5, P8) enforce this on both client and server, and how do you handle out-of-order events?
T9. Project 8: the production pipeline
- List the pipeline's gates (type-check, lint, unit/component/E2E tests, axe, bundle budgets, security headers, dependency checks, preview deployments) and their order, using chapter 26's C1 and chapter 30's C1. What runs on every PR and what nightly?
- "A deliberate error in production appears in the tracker with an un-minified stack trace and the release name; you can roll back in under a minute." Which chapters' outputs show what goes wrong without each piece (chapter 30's P5 raw vs mapped stack, chapter 31's lab on atomic deploys, chapter 32's P1 grouping)?
- "The CSP report-only rollout shows no violations before enforcing": walk through the rollout (chapter 28's T3) and the violations you're likely to see in this product (inline scripts from the framework, analytics, the payment SDK, a
<base>-sensitive relative script: chapter 28's P2).
Programming checkpoints
P1. Project 1: an accessibility and layout harness
Before building the menu site, build its checker: a Playwright script that runs axe on every page, completes the booking form using only the keyboard, checks for horizontal scrolling at 320 px and clipping at 200% text zoom and with text-spacing overrides, and validates the HTML. Run it against a deliberately broken page first.
P2. Project 2: the money table
Write totals(cart) in integer paise with a 10% coupon and 5% GST rounded half up to the paisa, format with Intl.NumberFormat('en-IN'), and test it with a table that includes ₹55 with the coupon, 3 × ₹19.99, and a case that rounds up to a whole rupee. Show the floating-point trap the paise design avoids, and make sure a Math.round → Math.floor mutant fails a test.
P3. Project 3: the race and re-render tests
For the SPA, write two tests before building features: (1) switching from dish 1 (slow, 600 ms) to dish 2 (fast, 100 ms) must end showing dish 2; (2) adding to cart must re-render only the badge and one card. Run them against a naive implementation first (fetch in useEffect without cleanup; a context with value={{ cart }}), then against the query-library and selector versions.
P4. Project 4: the offline order test
Build the test before the feature: go offline after one visit, check the app shell and last menu load, place an order offline, come back online, simulate a lost response on the first send, and assert exactly one order on the server. Then add a service worker update while the tab is open and check the update prompt.
P5. Project 5: the budget gate
Before migrating the storefront, set up the gate: size-limit per route as an error, Lighthouse CI (5 runs, throttled mobile) with LCP/CLS assertions and an INP proxy, a hydration-warning check (fail on React's hydration errors in the console), and a comparison with the base branch. Run it on the current SPA to get the baseline.
P6. Project 6: the design system's own test suite
Set up the design system's checks: axe and keyboard tests per story, APG keyboard behaviours for Tabs and Dialog, a token contrast test in light and dark themes, and visual tests with element screenshots. Prove the visual tests catch a 1 px padding change and a brand colour change, and that the keyboard tests catch a div button.
P7. Project 7: the resume test
Build the SSE endpoint with a persistent event log and Last-Event-ID replay, and a test that: connects, receives "cooking", kills the server, writes "ready" to the log while it's down, restarts it, and asserts the client receives "ready" without reloading and never shows two states at once. Add a test for out-of-order and duplicate events.
P8. Project 8: the pipeline's red-team
Before calling the pipeline done, try to break it: push a type error, an axe violation, a bundle over budget, a VITE_-prefixed secret, a CSP-violating inline script, an add_header that drops security headers, and a deploy that deletes old assets. Each must be blocked or detected. Then throw a deliberate production error and roll back.
P9. A project README that's worth reading
For one completed project, write the README: goal, screenshot or recording, architecture and key decisions (with alternatives considered), measurements against the definition of done (with methods and conditions), known limitations, and what you'd do next. Then review it against the portfolio checklist and rewrite any claim that isn't backed by a measurement.
Integration projects (chapters so far: Volume 1, and Volume 2's 00, 12–32)
C1. The whole product, end to end
Join projects 1–8 into one product: the static site's content and accessibility, the cart's money rules, the SPA's typed data layer, the PWA's offline ordering, the server-rendered public pages, the design system, live tracking, and the production pipeline, in one monorepo with shared packages (money, schemas, state machine, design system). Demonstrate one order's full journey: browse the server-rendered menu on a throttled phone, add items, go offline, place the order, reconnect, track it live through a server restart, while the kitchen tablet accepts it, with every step visible in RUM, errors, traces and logs.
Combines: all of Volume 2 (chapters 12–32) and Volume 1's systems foundations.
C2. Rebuild one project in a second stack and compare
Rebuild project 3 (the SPA) or project 5 (the storefront) in a second framework (React ↔ Angular, or Next.js ↔ Astro/SvelteKit), keeping features, tests and budgets identical. Compare with measurements: bundle sizes, LCP/INP under the same throttled profile, lines of code, dependencies, test effort, accessibility outcomes, and how much each framework's defaults helped. Write a decision memo for "which would we choose for TiffinBox's next product, and why".
Combines: React (ch 22), Angular (ch 23), full-stack frameworks (ch 24), state management (ch 25), testing (ch 26), performance (ch 27) and the comparisons in chapter 23's C2 and chapter 24's C2.
C3. A one-week hardening sprint on the finished product
Spend a week attacking your own product as a reviewer would: accessibility audit with a screen reader on Android and iOS, a security review (CSP, XSS sinks, server actions/route handlers, CORS, cookies, dependencies: chapter 28's C1), a performance review on a real budget phone in field conditions, a chaos session (offline, slow 3G, server restarts, deploys mid-session), and an observability check (can you answer chapter 32's T1 questions from your dashboards?). Fix what you find and write a hardening report.
Combines: accessibility (ch 20), security (ch 28), performance (ch 27), PWAs (ch 29), deployment (ch 31), observability (ch 32) and testing (ch 26).
What the chapter leaves out
Working with a design and product team
Real projects start from user research, product requirements and designs (Figma), not from a fixed spec. Skills that matter: turning designs into components and tokens (and pushing back on inaccessible or expensive designs early), clarifying edge cases (empty, error, loading, long text, Telugu and Hindi translations), estimating, demoing increments, and writing up decisions so non-engineers can follow. Practise by asking a friend to play product manager for one project and change a requirement mid-way.
Choosing scope and finishing
Portfolio projects fail more often by never finishing than by bad code. Cut scope deliberately (one kitchen, one city, a fake payment provider), timebox stretch goals, keep a running list of "not now" ideas, and ship each project to a public URL before starting the next. A finished project with honest limitations beats an ambitious half-finished one.
Code review and collaboration practice
Solo projects miss the collaboration skills interviews and jobs test: writing pull requests with context and screenshots, reviewing others' code kindly and specifically (the review exercises throughout this volume), handling feedback, and working in a shared codebase with conventions. Pair with someone on one project, review each other's PRs, or contribute a small fix to an open-source frontend library (axe, a headless UI library, a framework's docs).
Interview preparation from projects
Frontend interviews at senior levels include system design ("design the frontend of a food ordering app"), deep dives into your projects ("why streaming? what broke? what did you measure?"), debugging exercises, accessibility and performance questions, and coding. Prepare a 2-minute summary per project, one detailed story per project (a problem, your analysis, the measurement, the fix, the result), and be ready to draw the architecture and defend trade-offs (S2, S5).
Keeping skills current
The frontend platform changes quickly (Baseline features every few months, framework majors twice a year, new APIs like the Sanitizer API, View Transitions, speculation rules, CSS anchor positioning). Revisit your projects yearly: upgrade dependencies, adopt one new platform feature, re-measure, and update the README; it doubles as a record of your growth.
Senior exercises
S1. Review a teammate's portfolio project
A teammate shares their "ordering SPA" project: React with 40 components, Redux for everything including server data, no tests except snapshot tests, localStorage for the auth token, a Lighthouse score screenshot from their laptop, and a README listing 25 technologies. Write a kind, specific review that would help them reach L4.
S2. Design the frontend of a food-ordering product in an interview
You're asked: "Design the frontend for a food-ordering app like TiffinBox for 1 million daily users in India." Using the eight projects as your evidence, structure a 45-minute answer: requirements and constraints, rendering strategy per surface, state and data architecture, real-time, offline, performance budgets, accessibility, security, deployment and observability, and the trade-offs you'd revisit at 10× scale.
S3. Choose which projects to do, deliberately
An engineer has 8 weeks and wants to reach L4 for a frontend role at a company using Angular for internal tools and React for its consumer app. Choose which projects and stretch goals to do, in what order, what to skip, and how to measure progress each week.
S4. Turn the projects into a team training programme
Your company hires five junior frontend engineers. Adapt the eight projects into a 12-week onboarding programme: team structure (pairs), code review rotations, definitions of done as CI checks, mentoring checkpoints, how you assess progress (mastery levels), and how the programme connects to real work (shipping small production changes from week 4).
S5. Tell a project story in an interview
Prepare a 3-minute story about one project using the structure: context, problem, analysis with measurements, decision and alternatives, result with numbers, what you'd do differently. Use a real finding from this volume (for example, chapter 29's P2 network-first cached a 500 and served it offline, or chapter 31's lab on deleted chunks breaking old tabs), and prepare answers to three follow-up questions.