Project Workshop — Job Board Frontend (Next.js 14)
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
Next.js 14 · TypeScript · App Router · Server Actions · TanStack Query
Expected effort: 4–7 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 | page.tsx/layout.tsx/loading.tsx/error.tsx/not-found.tsx produces the specified behavior inside App Router architecture | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.2 | route groups: (group) folders produces the specified behavior inside App Router architecture | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.3 | dynamic routes: [id]/[...slug]/[[...slug]] produces the specified behavior inside App Router architecture | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.4 | parallel routes: @modal produces the specified behavior inside App Router architecture | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.5 | intercepting routes for modals produces the specified behavior inside App Router architecture | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.1 | Server Components: default, no hooks, async fetch() produces the specified behavior inside Server vs Client components | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.2 | Client Components: 'use client' directive, interactive produces the specified behavior inside Server vs Client components | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.3 | composition: Server wraps Client produces the specified behavior inside Server vs Client components | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.1 | 'use server' directive in functions produces the specified behavior inside Server Actions & data fetching | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.2 | form actions + useFormState + useFormStatus produces the specified behavior inside Server Actions & data fetching | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.3 | revalidatePath() and revalidateTag() produces the specified behavior inside Server Actions & data fetching | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.4 | useOptimistic for optimistic UI produces the specified behavior inside Server Actions & data fetching | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.5 | fetch() caching: force-cache/no-store produces the specified behavior inside Server Actions & data fetching | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.6 | ISR: revalidate: 60 produces the specified behavior inside Server Actions & data fetching | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.7 | Suspense streaming boundaries produces the specified behavior inside Server Actions & data fetching | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.1 | route.ts GET/POST handlers produces the specified behavior inside Route handlers & middleware | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.2 | NextRequest and NextResponse produces the specified behavior inside Route handlers & middleware | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.3 | middleware matcher configuration produces the specified behavior inside Route handlers & middleware | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.4 | Edge vs Node runtime constraints produces the specified behavior inside Route handlers & middleware | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.5 | authentication redirect vs authorization in the handler produces the specified behavior inside Route handlers & middleware | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-5.1 | dynamic rendering triggers produces the specified behavior inside Rendering & asset optimization | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-5.2 | Promise.all parallel server fetching produces the specified behavior inside Rendering & asset optimization | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-5.3 | Image sizing/priority/remotePatterns produces the specified behavior inside Rendering & asset optimization | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-5.4 | next/font self-hosting and layout shift prevention produces the specified behavior inside Rendering & asset optimization | 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 | App Router architecture | page.tsx/layout.tsx/loading.tsx/error.tsx/not-found.tsx; route groups: (group) folders; dynamic routes: [id]/[...slug]/[[...slug]] | Demonstration plus focused tests |
| 2 | Server vs Client components | Server Components: default, no hooks, async fetch(); Client Components: 'use client' directive, interactive; composition: Server wraps Client | Demonstration plus focused tests |
| 3 | Server Actions & data fetching | 'use server' directive in functions; form actions + useFormState + useFormStatus; revalidatePath() and revalidateTag() | Demonstration plus focused tests |
| 4 | Route handlers & middleware | route.ts GET/POST handlers; NextRequest and NextResponse; middleware matcher configuration | Demonstration plus focused tests |
| 5 | Rendering & asset optimization | dynamic rendering triggers; Promise.all parallel server fetching; Image sizing/priority/remotePatterns | 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
1// app/jobs/[id]/page.tsx — Server Component2import { Suspense } from 'react';3import { revalidateTag } from 'next/cache';4
5export default async function JobPage({ params }: { params: { id: string } }) {6 const job = await fetch(process.env.API_URL + '/jobs/' + params.id, {7 next: { tags: ['job:' + params.id], revalidate: 60 },8 }).then(response => response.json());9 return <Suspense fallback={<p>Loading application…</p>}><JobDetail job={job} /></Suspense>;10}11
12export async function withdraw(formData: FormData) {13 'use server';14 const user = await requireUser();15 const applicationId = String(formData.get('applicationId'));16 await api.withdraw(user, applicationId);17 revalidateTag('applications:' + user.id);18}Expected result
1The page caches job data for 60 seconds; the authorized action invalidates only the user's application list.Code reading
| Line | Code | Explanation |
|---|---|---|
| 1 | // app/jobs/[id]/page.tsx — Server Component | Implements the next tsx statement in the example's data flow. |
| 2 | import { Suspense } from 'react'; | Imports the named dependency; import executes the module once per interpreter cache and binds selected names here. |
| 3 | import { revalidateTag } from 'next/cache'; | Imports the named dependency; import executes the module once per interpreter cache and binds selected names here. |
| 5 | export default async function JobPage({ params }: { params: { id: string } }) { | Implements the next tsx statement in the example's data flow. |
| 6 | const job = await fetch(process.env.API_URL + '/jobs/' + params.id, { | Starts or resumes asynchronous I/O and yields control until the awaited operation completes. |
| 7 | next: { tags: ['job:' + params.id], revalidate: 60 }, | Implements the next tsx statement in the example's data flow. |
| 8 | }).then(response => response.json()); | Computes or receives a value and binds it for the next step; the referenced object remains separate from the name. |
| 9 | return | Returns the observable result to the caller and ends this invocation. |
| 10 | } | Implements the next tsx statement in the example's data flow. |
| 12 | export async function withdraw(formData: FormData) { | Implements the next tsx statement in the example's data flow. |
| 13 | 'use server'; | Implements the next tsx statement in the example's data flow. |
| 14 | const user = await requireUser(); | Starts or resumes asynchronous I/O and yields control until the awaited operation completes. |
| 15 | const applicationId = String(formData.get('applicationId')); | Binds a JavaScript value used by the component or operation. |
| 16 | await api.withdraw(user, applicationId); | Starts or resumes asynchronous I/O and yields control until the awaited operation completes. |
| 17 | revalidateTag('applications:' + user.id); | Implements the next tsx statement in the example's data flow. |
| 18 | } | Implements the next tsx statement in the example's data flow. |
Risk register
| Area | Failure to reproduce | Required design response |
|---|---|---|
| App Router architecture | Route complexity can obscure browser history and direct-link behavior; test both soft and hard navigation. | Keep layouts stable and colocate route-specific boundaries. |
| Server vs Client components | Passing non-serializable values or importing server-only code into a client graph fails or leaks architecture. | Fetch close to the server component that owns the UI and keep client islands narrow. |
| Server Actions & data fetching | ISR means Incremental Static Regeneration here, not Kafka's in-sync replica set; a hidden form or server function name is not authorization. | Authorize every action, choose cache behavior per data source, use targeted invalidation, and design streaming fallbacks that preserve layout and accessibility. |
| Route handlers & middleware | Order matters; broad exception swallowing and body buffering can break streaming. | Use it for correlation, security headers, timing, and protocol-level concerns. |
| Rendering & asset optimization | Middleware authentication redirects are not object authorization, and choosing Edge while importing Node-only libraries fails at build/runtime. | Keep authorization inside the final handler/action, constrain middleware scope, declare remote image patterns, and reserve dimensions. |
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?