Project Workshop — React Admin Dashboard
This is a portfolio submission, not a copy-and-run tutorial. A reviewer must be able to clone it, configure it without guessing, execute the critical path, observe a deliberate failure, run the tests, and understand the most important…
- What you are building
- Architecture
- Acceptance criteria
- Suggested repository structure
- Build plan: vertical slices
React · Redux Toolkit · RTK Query · TanStack Query · TypeScript · Zod
Expected effort: 35–56 focused hours · Minimum meaningful tests: 12What you are building
This is a portfolio submission, not a copy-and-run tutorial. A reviewer must be able to clone it, configure it without guessing, execute the critical path, observe a deliberate failure, run the tests, and understand the most important design decision from the README.
Architecture
Critical interaction
Ownership table
| Boundary | Owns | Must not own |
|---|---|---|
| Interface | Parsing, protocol validation, identity extraction, status or presentation mapping | Core business invariants |
| Application/domain | Authorization inputs, state transitions, orchestration, transaction intent | Framework globals or raw transport objects |
| Repository/gateway | One persistence or external protocol, bounded retries, error translation | Product policy |
| Background/UI projection | Recoverable derived state and delivery progress | Hidden authoritative truth |
| Operations | Configuration, health, deployment, telemetry, recovery | Business decisions encoded only in dashboards |
Acceptance criteria
| ID | Required behavior | Evidence |
|---|---|---|
| AC-1.1 | useLocalStorage, useFetch, useDebounce produces the specified behavior inside 10 production custom hooks | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.2 | useThrottle, useIntersectionObserver, useMediaQuery produces the specified behavior inside 10 production custom hooks | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.3 | usePrevious, useClickOutside, useKeyPress, useWebSocket produces the specified behavior inside 10 production custom hooks | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.1 | createContext/useContext/Provider produces the specified behavior inside Context API & useReducer | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.2 | re-render performance + context splitting pattern produces the specified behavior inside Context API & useReducer | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.3 | useReducer: (state, action) → newState produces the specified behavior inside Context API & useReducer | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.4 | combining useReducer + Context (Redux-lite) produces the specified behavior inside Context API & useReducer | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.1 | createSlice: reducers/actions/initialState produces the specified behavior inside Redux Toolkit (RTK) & RTK Query | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.2 | configureStore + useSelector/useDispatch produces the specified behavior inside Redux Toolkit (RTK) & RTK Query | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.3 | RTK Query: createApi, query + mutation endpoints produces the specified behavior inside Redux Toolkit (RTK) & RTK Query | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.4 | optimistic updates + invalidatesTags produces the specified behavior inside Redux Toolkit (RTK) & RTK Query | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.1 | useQuery (queryKey/queryFn/staleTime) produces the specified behavior inside TanStack Query, TypeScript & Zod | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.2 | useMutation + invalidateQueries produces the specified behavior inside TanStack Query, TypeScript & Zod | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.3 | useInfiniteQuery for infinite scroll produces the specified behavior inside TanStack Query, TypeScript & Zod | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.4 | Zod + React Hook Form integration produces the specified behavior inside TanStack Query, TypeScript & Zod | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-5.1 | type vs interface for props produces the specified behavior inside TypeScript React mastery | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-5.2 | generic components and hooks produces the specified behavior inside TypeScript React mastery | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-5.3 | ComponentProps/Partial/Pick/Omit utility types produces the specified behavior inside TypeScript React mastery | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-5.4 | typed DOM events and refs produces the specified behavior inside TypeScript React mastery | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-5.5 | discriminated unions for reducer actions produces the specified behavior inside TypeScript React mastery | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
Suggested repository structure
1app/2├── routes-or-app-router/3├── components/{ui,features,errors}/4├── hooks/5├── lib/{api,auth,schemas,query-keys}/6├── state/7├── styles/8├── tests/{unit,integration,e2e}/9└── package.jsonBuild plan: vertical slices
| Milestone | Capability | First implementation | Exit condition |
|---|---|---|---|
| 1 | 10 production custom hooks | useLocalStorage, useFetch, useDebounce; useThrottle, useIntersectionObserver, useMediaQuery; usePrevious, useClickOutside, useKeyPress, useWebSocket | Demonstration plus focused tests |
| 2 | Context API & useReducer | createContext/useContext/Provider; re-render performance + context splitting pattern; useReducer: (state, action) → newState | Demonstration plus focused tests |
| 3 | Redux Toolkit (RTK) & RTK Query | createSlice: reducers/actions/initialState; configureStore + useSelector/useDispatch; RTK Query: createApi, query + mutation endpoints | Demonstration plus focused tests |
| 4 | TanStack Query, TypeScript & Zod | useQuery (queryKey/queryFn/staleTime); useMutation + invalidateQueries; useInfiniteQuery for infinite scroll | Demonstration plus focused tests |
| 5 | TypeScript React mastery | type vs interface for props; generic components and hooks; ComponentProps/Partial/Pick/Omit utility types | Demonstration plus focused tests |
| 6 | Hardening and delivery | Security, recovery, telemetry, performance, documentation | Full acceptance suite and recorded demonstration |
For each milestone, first create a failing acceptance test or a reproducible command. Implement the thinnest path to an observable result, add the nearest durable invariant, inject one expected failure, and refactor only after evidence protects the behavior.
Reference vertical slice
1const api = createApi({2 reducerPath: 'api',3 baseQuery: fetchBaseQuery({ baseUrl: '/api' }),4 tagTypes: ['Task'],5 endpoints: builder => ({6 tasks: builder.query<Task[], void>({7 query: () => 'tasks',8 providesTags: result => result ? [...result.map(({ id }) => ({ type: 'Task' as const, id })), 'Task'] : ['Task'],9 }),10 updateTask: builder.mutation<Task, Patch>({11 query: ({ id, ...body }) => ({ url: 'tasks/' + id, method: 'PATCH', body }),12 async onQueryStarted(patch, { dispatch, queryFulfilled }) {13 const undo = dispatch(api.util.updateQueryData('tasks', undefined, draft => {14 Object.assign(draft.find(item => item.id === patch.id)!, patch);15 }));16 try { await queryFulfilled; } catch { undo.undo(); }17 },18 }),19 }),20});Expected result
1The cache updates immediately and rolls back exactly that patch if the mutation fails.Code reading
| Line | Code | Explanation |
|---|---|---|
| 1 | const api = createApi({ | Binds a JavaScript value used by the component or operation. |
| 2 | reducerPath: 'api', | Implements the next tsx statement in the example's data flow. |
| 3 | baseQuery: fetchBaseQuery({ baseUrl: '/api' }), | Implements the next tsx statement in the example's data flow. |
| 4 | tagTypes: ['Task'], | Implements the next tsx statement in the example's data flow. |
| 5 | endpoints: builder => ({ | Computes or receives a value and binds it for the next step; the referenced object remains separate from the name. |
| 6 | tasks: builder.query | Implements the next tsx statement in the example's data flow. |
| 7 | query: () => 'tasks', | Computes or receives a value and binds it for the next step; the referenced object remains separate from the name. |
| 8 | providesTags: result => result ? [...result.map(({ id }) => ({ type: 'Task' as const, id })), 'Task'] : ['Task'], | Computes or receives a value and binds it for the next step; the referenced object remains separate from the name. |
| 9 | }), | Implements the next tsx statement in the example's data flow. |
| 10 | updateTask: builder.mutation | Begins a declarative database or protocol operation; subsequent lines refine its contract. |
| 11 | query: ({ id, ...body }) => ({ url: 'tasks/' + id, method: 'PATCH', body }), | Computes or receives a value and binds it for the next step; the referenced object remains separate from the name. |
| 12 | async onQueryStarted(patch, { dispatch, queryFulfilled }) { | Implements the next tsx statement in the example's data flow. |
| 13 | const undo = dispatch(api.util.updateQueryData('tasks', undefined, draft => { | Binds a JavaScript value used by the component or operation. |
| 14 | Object.assign(draft.find(item => item.id === patch.id)!, patch); | Computes or receives a value and binds it for the next step; the referenced object remains separate from the name. |
| 15 | })); | Implements the next tsx statement in the example's data flow. |
| 16 | try { await queryFulfilled; } catch { undo.undo(); } | Starts or resumes asynchronous I/O and yields control until the awaited operation completes. |
| 17 | }, | Implements the next tsx statement in the example's data flow. |
| 18 | }), | Implements the next tsx statement in the example's data flow. |
| 19 | }), | Implements the next tsx statement in the example's data flow. |
| 20 | }); | Implements the next tsx statement in the example's data flow. |
Risk register
| Area | Failure to reproduce | Required design response |
|---|---|---|
| 10 production custom hooks | The useClickOutside name does not invoke Python's Click CLI, and a throttle hook is not an API rate limiter. | Expose the smallest stable API, clean up every external subscription, handle SSR/browser boundaries, and test time, cancellation, and reconnect cases. |
| Context API & useReducer | React context is not GraphQL request context; one frequently changing mega-context can re-render a large tree. | Split contexts by change frequency, memoize provider values where useful, and model actions as discriminated unions with exhaustive handling. |
| Redux Toolkit (RTK) & RTK Query | Do not mirror query data into slices or invalidate every tag after every mutation. | Use Redux for cross-feature client state and the query layer for remote data. |
| TanStack Query, TypeScript & Zod | A query cache is not durable business state, and optimistic updates require rollback snapshots. | Validate API responses as well as forms and design stable key factories. |
| TypeScript React mastery | Casting with as silences evidence rather than validating data, and React.FC is not required for ordinary components. | Infer native props with ComponentProps, type event targets precisely, and use an exhaustive never check for reducer actions. |
Engineering checklist for this stack
- To do: provide keyboard and screen-reader operation
- To do: model loading, empty, error, and permission states
- To do: cancel obsolete requests and streams
- To do: validate network data at runtime
- To do: keep server and local UI state in appropriate owners
Test strategy
Implement at least 12 meaningful cases. A long list of shallow happy-path tests does not satisfy the requirement.
| Risk class | Minimum | Examples |
|---|---|---|
| Happy path and contract | 2 | Correct output, status/schema, durable state |
| Validation and boundaries | 2 | Empty, malformed, extreme, unsupported transition |
| Authorization or trust boundary | 1 | Missing identity, wrong tenant/role, injection or unsafe content |
| Failure and recovery | 2 | Timeout, retry, rollback, reconnect, dependency outage |
| Duplicate or concurrency | 1 | Same identity twice, racing update, redelivery |
| Performance and operations | 4 | Query bound, lag, p95, resource limit, telemetry |
Representative test scaffold
1import { render, screen } from '@testing-library/react';2import userEvent from '@testing-library/user-event';3
4it('shows a recoverable error when the mutation fails', async () => {5 server.use(http.post('/api/action', () => HttpResponse.json({ detail: 'failed' }, { status: 503 })));6 render(<Feature />);7 await userEvent.click(screen.getByRole('button', { name: /submit/i }));8 expect(await screen.findByRole('alert')).toHaveTextContent(/try again/i);9});Failure drills
- Stop the primary external dependency during the critical path. Capture the failure, cleanup, telemetry, and recovery.
- Repeat the same operation with the same stable identity. Prove one logical outcome or document why repetition is forbidden.
- Crash after durable state changes but before the response, acknowledgement, or projection. Re-run and reconcile.
- Submit the largest supported input and one slightly larger input.
- Remove one permission and prove denial without state change or information leakage.
- Roll back the change or restore the dependency, then run a smoke test and reconciliation check.
Performance experiment
State the dataset, payload distribution, concurrency, rate, duration, cache state, and resource limits before measuring. Publish p50, p95, p99, throughput, error rate, and the technology-specific correctness signal such as query count, consumer lag, duplicate effects, rendered updates, token cost, or recall. Change one variable at a time and retain raw output.
Submission package
- Complete source with a locked/reproducible environment.
- README.md with problem, architecture, setup, commands, configuration, assumptions, and trade-offs.
- Acceptance and risk-focused tests with a short explanation of what mocks intentionally do not cover.
- One design record explaining the most consequential choice and a rejected alternative.
- Security notes, sample non-secret configuration, and cleanup commands.
- A demonstration record: terminal transcript, screenshots, trace, query plan, or metrics dashboard.
- A 5–8 minute walkthrough following input → validation → state → failure → evidence.
Grading rubric
| Dimension | Weight | Full-credit evidence |
|---|---|---|
| Product behavior | 25 | Acceptance criteria pass through real public boundaries |
| Architecture and ownership | 20 | Responsibilities and state authority are explicit |
| Tests and recovery | 20 | Important negative, duplicate, concurrent, and outage cases pass |
| Security and data correctness | 15 | Least privilege, validation, constraints, and secret handling are demonstrated |
| Performance and operations | 10 | Reproducible measurement, useful telemetry, and rollback/recovery |
| Documentation and explanation | 10 | A new reviewer can reproduce and defend the result |
Mastery check
How well can you recall this?
Finished this lesson?