Full-Stack Project: Task Board with React and .NET
On this page
Learning Objective
Deliver one complete vertical slice of the task board, from a database migration to a tested React component with live updates, applying the contracts, authorization, concurrency, validation, and security habits from all six phases so far.
Concept Explanation
This project is the checkpoint for everything before it, and it is deliberately a vertical slice, not a set of layers built in isolation. The feature is a kanban board for a project: tasks appear in columns by status, members can move a task between columns, and everyone viewing the project sees changes live. It touches every layer: a SQL Server table and migration, EF Core mapping, authorized and validated API endpoints, an OpenAPI contract and generated client, TanStack Query state, an accessible React interface, and a SignalR notification. Building it end to end shows how the earlier lessons interlock, and reveals where the seams are.
Work through the slice in a fixed order, verifying each step before moving on. Start with the data: add a Status and a Position to tasks, a rowversion column, and an index on project and status, then generate and read the migration as Day 34 taught. Next, the API: list tasks for a project the caller belongs to, create a task, and change a task's status with an If-Match header. Each endpoint filters by membership inside the query and returns 404 for anything the caller cannot see. Then publish the contract, regenerate the TypeScript types, and let the compiler tell you where the client no longer matches. Only then build the React board, with query hooks, an optimistic status change that rolls back on failure, and error states from Day 57.
Decide up front what done means, with a checklist that mirrors the earlier phases. Functionally, a member can view, create, and move tasks. For security, a non-member cannot list, read, or move tasks; a viewer cannot change status; requests are validated for length and allowed status values; the ETag protocol prevents lost updates; and hub joins require membership. For quality, integration tests run against SQL Server in a container, there is a component test with a mocked API, and the OpenAPI drift check passes. For operations, requests carry a correlation identifier and errors show a trace identifier. Treat any unchecked item as unfinished, regardless of how good the demo looks.
Keep the scope small so the quality can be high. Position ordering within a column can be a simple integer with reordering out of scope, drag and drop can be replaced with a select or buttons, and permissions can be the three roles you already have. The value is in the integration and the discipline, not the features. When the slice works, you will have a template that you can copy for the next feature, and the checklist becomes your definition of done for everything else in the course.
| Layer | Deliverable | Verified by |
|---|---|---|
| Database | Migration adding Status, Position, RowVer, index | Reviewed migration, applied in container |
| API | List, create, change-status endpoints with membership checks | Integration tests including the negative cases |
| Contract | OpenAPI document and generated types | CI drift check, TypeScript compiles |
| Client state | Query hooks, optimistic move with rollback | Component tests with mocked responses |
| Interface | Accessible board with loading and error states | Tests by role and label, keyboard use |
| Real time | Hub join with membership check, notify and refetch | Hub tests, Origin test |
Worked Example: The Slice in Five Cuts
The listings show the essential pieces: the endpoint, the hook, the component, and the tests. Reuse the helpers from earlier lessons for the details they cover.
// 1. API: change a task's status. Membership is in the query; concurrency is via If-Match.
public record MoveTaskRequest([property: Range(0, 3)] int Status);
app.MapPatch("/api/tasks/{taskId:guid}/status", async (Guid taskId, MoveTaskRequest body, HttpRequest req,
AppDb db, ClaimsPrincipal user, BoardNotifier notifier, CancellationToken ct) =>
{
var me = user.GetUserId();
// Only members who can edit see the task at all: everyone else gets a 404.
var task = await db.Tasks
.Where(t => t.Id == taskId && t.Project.Members.Any(m => m.UserId == me && m.Role >= ProjectRole.Editor))
.FirstOrDefaultAsync(ct);
if (task is null) return Results.NotFound();
if (!req.Headers.TryGetValue("If-Match", out var ifMatch) || string.IsNullOrEmpty(ifMatch))
return Results.Problem("If-Match header is required.", statusCode: StatusCodes.Status428PreconditionRequired);
db.Entry(task).Property(t => t.RowVer).OriginalValue = Convert.FromBase64String(ifMatch.ToString().Trim('"'));
task.Status = (TaskState)body.Status;
try { await db.SaveChangesAsync(ct); }
catch (DbUpdateConcurrencyException)
{
return Results.Problem("This task was changed by someone else.", statusCode: StatusCodes.Status412PreconditionFailed);
}
await notifier.TaskChangedAsync(task.ProjectId, task.Id); // notify only after the commit
return Results.Ok(TaskDto.From(task)); // includes the new ETag via the version field
}).RequireAuthorization();// 2. Client hook: optimistic move with rollback, conflict handling, cache keyed by user.
export function useMoveTask(userId: string, projectId: string) {
const qc = useQueryClient();
const key = taskKeys.byProject(userId, projectId);
return useMutation({
mutationFn: ({ task, status }: { task: Task; status: TaskStatus }) =>
request(`/api/tasks/${task.id}/status`, TaskSchema, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json', 'If-Match': task.etag, 'X-CSRF': '1' },
body: JSON.stringify({ status: STATUS_CODE[status] }),
}),
onMutate: async ({ task, status }) => {
await qc.cancelQueries({ queryKey: key });
const previous = qc.getQueryData<Task[]>(key);
qc.setQueryData<Task[]>(key, (old) => old?.map((t) => (t.id === task.id ? { ...t, status } : t)));
return { previous };
},
onError: (_e, _v, ctx) => ctx?.previous && qc.setQueryData(key, ctx.previous),
onSettled: () => qc.invalidateQueries({ queryKey: key }),
});
}// 3. Component: columns by status, an accessible control to move a task.
const COLUMNS: { id: TaskStatus; label: string }[] = [
{ id: 'todo', label: 'To do' }, { id: 'inProgress', label: 'In progress' },
{ id: 'review', label: 'Review' }, { id: 'done', label: 'Done' },
];
export function Board({ projectId }: { projectId: string }) {
const { data: user } = useUser();
const { data: tasks = [], error, refetch } = useTasks(user!.id, projectId);
const move = useMoveTask(user!.id, projectId);
useBoardEvents(projectId, user!.id);
if (error) return <ErrorState error={error} onRetry={refetch} />;
return (
<section aria-label="Task board" className="board">
{COLUMNS.map((col) => (
<div key={col.id} role="group" aria-labelledby={`col-${col.id}`}>
<h2 id={`col-${col.id}`}>{col.label}</h2>
<ul>
{tasks.filter((t) => t.status === col.id).map((task) => (
<li key={task.id}>
<span>{task.title}</span> {/* text, escaped by React */}
<label>
<span className="visually-hidden">Move {task.title}</span>
<select value={task.status} onChange={(e) => move.mutate({ task, status: e.target.value as TaskStatus })}
disabled={!user?.can.editTasks}>
{COLUMNS.map((c) => <option key={c.id} value={c.id}>{c.label}</option>)}
</select>
</label>
</li>
))}
</ul>
</div>
))}
</section>
);
}// 4. Integration tests: the negative cases matter most.
[Fact] public async Task Viewer_cannot_move_a_task() =>
Assert.Equal(HttpStatusCode.NotFound, (await Patch(Viewer, taskId, status: 2, etag: CurrentEtag)).StatusCode);
[Fact] public async Task Outsider_cannot_move_a_task() =>
Assert.Equal(HttpStatusCode.NotFound, (await Patch(Outsider, taskId, status: 2, etag: CurrentEtag)).StatusCode);
[Fact] public async Task Missing_if_match_returns_428() =>
Assert.Equal((HttpStatusCode)428, (await Patch(Editor, taskId, status: 2, etag: null)).StatusCode);
[Fact] public async Task Stale_etag_returns_412() { await Patch(Editor, taskId, 1, CurrentEtag); Assert.Equal(HttpStatusCode.PreconditionFailed, (await Patch(Editor, taskId, 2, CurrentEtag)).StatusCode); }
[Theory, InlineData(-1), InlineData(4), InlineData(99)]
public async Task Out_of_range_status_is_a_400(int status) =>
Assert.Equal(HttpStatusCode.BadRequest, (await Patch(Editor, taskId, status, CurrentEtag)).StatusCode);// 5. Component test: a failed move rolls back and explains itself.
it('rolls back the move and shows a conflict message on 412', async () => {
server.use(http.patch('/api/tasks/:id/status', () => HttpResponse.json({ status: 412, title: 'Changed' }, { status: 412 })));
renderWithProviders(<Board projectId="p1" />);
const select = await screen.findByLabelText('Move Write report');
await userEvent.selectOptions(select, 'done');
expect(await screen.findByText(/changed while you were working/i)).toBeVisible();
expect(select).toHaveValue('todo'); // rolled back
});Finish by running the security matrix from Day 47 against the new endpoints and adding the rows that are missing. If the checklist passes, the slice is done, and you have a template for every later feature.
Real-World Examples
- Kanban, the card-and-column method for visualizing work in progress, originated in the 1940s and 1950s at Toyota, developed by Taiichi Ohno as a way to signal production needs, and was adapted to software teams in the 2000s. The Trello product, launched in 2011, made the board a mainstream interface, which is why users expect boards to update live and to allow moving cards with a single action.
- Vertical slice delivery is widely recommended for teams learning a new stack, because it forces every layer and the seams between them to work together early, exposing integration problems such as contract mismatches, authorization gaps, and deployment assumptions when they are cheap to fix rather than at the end. It is also the core idea behind vertical slice architecture, which Day 61 uses to structure the backend.
Review Questions & Answers
Doing it in the query means a task the caller may not edit is never loaded, so there is no code path where it could be modified or leaked, and the caller gets a 404 that reveals nothing about its existence. A check after loading depends on every developer remembering it, and tends to return a distinguishable 403.
It makes the interface feel instant by moving the card before the server confirms. It must be paired with a rollback to the previous state if the request fails and a final invalidation that refetches the truth, otherwise a rejected move would leave the screen showing something that never happened.
If the event is sent before the commit, clients may refetch and see the old data, or the change may fail and the notification would announce something that never happened. Sending after the commit guarantees that a refetch triggered by the event sees the new state.
Working demos hide missing protections, since the happy path passes whether or not authorization and concurrency are implemented. A checklist that requires tests for outsiders, viewers, stale versions, and invalid input forces you to prove the protections exist, and builds the habit of treating them as part of the feature and not as optional extras.