Use cases
Different codebases. Different questions. One clearer picture.
Joining an unfamiliar project
You've joined the storefront team. Before your first ticket you want to understand authentication, API structure and data flow.
Know where auth, the API layer and the data model live.
- What you see
- A natural-language question, a contextual answer, the files it relies on and a suggested path to read next.
- Outcome
- A structured starting point for onboarding: where auth, the API layer and the data model live, and how they connect.
Where is authentication handled?
Authentication lives in lib/auth/session.ts. getSession reads the session cookie and verifies it; requireUser wraps it and throws a 401 response. Only the cart and checkout handlers call requireUser, so product pages are public.
- lib/auth/session.ts:6–10Cookie read + token verification
- lib/auth/session.ts:12–18Guard used by private handlers
- app/api/cart/route.ts:6Cart is authenticated
- app/api/checkout/route.ts:6Checkout is authenticated
- lib/auth/session.ts:2Inference: Token verification lives in ./tokens, which this sample does not include
- session.ts
- cart/route.ts
- checkout/route.ts
Investigating a bug
Checkout started failing after a change to cart logic. You have the symptom, not the cause.
POST /api/checkout returns 500 for signed-in users with a discount. Users without a discount can check out.
- What you see
- The reported symptom, the request handler, the functions it calls, a potential failure point and the evidence for it.
- Outcome
- A hypothesis to verify, with the lines that support it. Not a confirmed root cause.
Why might POST /api/checkout return 500 after the cart change?
A likely candidate: calculateTotals now multiplies by (1 − discountRate) without rounding, so subtotalCents can be fractional. createCheckout passes that value straight to payments.createIntent, and the checkout handler has no error handling, so a rejected amount would surface as a 500. This is a hypothesis, not a confirmed root cause.
- server/cart.ts:36No Math.round after applying the discount
- server/checkout.ts:13–14Amount forwarded as-is
- app/api/checkout/route.ts:5–9Errors are not caught or mapped
- CONTRIBUTING.md:9Integer-cents convention
- tests/cart.test.ts:4–16No test covers a non-zero discount
- server/checkout.ts:3Inference: That the payment provider rejects fractional amounts is not visible here. Confirm in logs.
- checkout/route.ts
- checkout.ts
- cart.ts
Understanding the impact of a change
A pull request changes apiFetch so failed responses resolve to null instead of throwing.
apiFetch in lib/api/client.ts no longer throws on non-2xx responses.
- What you see
- The changed function, the files that depend on it, related tests and the workflows that might be affected.
- Outcome
- A potential impact list to review against, scoped to the references RepoMind can see.
What could the apiFetch change affect?
Potential impact: callers that rely on ApiError stop seeing failures. getProduct would return null for any error, so a 500 could render as a 404 page. AddToCartButton's catch block would no longer run, so a failed add could look successful. The apiFetch error test is expected to fail. This list is based on direct references and may not be exhaustive.
- lib/api/products.ts:9–13Depends on ApiError being thrown
- app/products/[id]/page.tsx:11–13Treats null as not found
- components/AddToCartButton.tsx:11–16Error state relies on a throw
- tests/api-client.test.ts:12–15Will fail with the new behaviour
- lib/api/client.ts:15–17Inference: Callers outside this sample (if any) are not covered
- client.ts
- api/products.ts
- page.tsx
- AddToCartButton.tsx
- api-client.test.ts
Contributing to open source
You picked up an issue in storefront-app and want a focused, mergeable first pull request.
Allow each product to set its own maximum quantity per order.
- What you see
- Where the relevant feature lives, the project's conventions, the nearest tests and the shape of a focused change.
- Outcome
- A smaller, better-aimed first pull request.
Where would I add a per-product quantity limit?
The limit is enforced in addItem in server/cart.ts, where 10 is currently hard-coded. A focused change would add a maxPerOrder column to products in db/schema.ts, read it in addItem, and keep the route handler unchanged.
- server/cart.ts:8–10Current hard-coded rule
- db/schema.ts:3–10products table definition
- CONTRIBUTING.md:10Rules belong in server/
- cart/route.ts
- cart.ts
- schema.ts
Try each scenario.
Each scenario has its own questions, file relationships and explanations in the sample repository.
Joining an unfamiliar project
You've joined the storefront team. Before your first ticket you want to understand authentication, API structure and data flow.
storefront-app / main
Know where auth, the API layer and the data model live.
Reads the session cookie. requireUser() guards private routes.