All academies
All projects

Task Manager

medium

Build a kanban-style task manager with boards, columns, drag-and-drop, and per-task assignees and due dates. This project pushes you into deeper typing territory: normalized state shapes with Record maps, discriminated unions for drag events, and utility types like Pick and Partial for update payloads.

Next.jsTypeScriptTailwind CSSZustanddnd-kit

Architecture

  • UI layer: Board, Column, and TaskCard components plus a task detail drawer, all fed by typed selectors
  • State layer: a normalized Zustand store (tasks by id, columns by id, ordered id arrays) to make reordering cheap and type-safe
  • Domain layer: pure functions for moving tasks between columns and reordering within a column, typed to reject invalid moves
  • Service layer: an optimistic-update wrapper that applies changes locally and reconciles with the API response
  • API layer: Next.js route handlers for tasks and columns with typed request and response bodies
  • Type layer: shared Task, Column, and Board types plus derived payload types built with Pick and Partial

Folder structure

src/
  app/
    page.tsx
    api/
      tasks/
        route.ts
      columns/
        route.ts
  components/
    Board.tsx
    Column.tsx
    TaskCard.tsx
    TaskDrawer.tsx
    AssigneePicker.tsx
  store/
    useBoardStore.ts
  lib/
    moves.ts
    api.ts
  types/
    board.ts

Domain type definitions

Start every project by defining its types — they become the contract for every component, service, and API call that follows.

export type Priority = "low" | "medium" | "high" | "urgent";

export interface Task {
  id: string;
  title: string;
  description: string;
  priority: Priority;
  assigneeId: string | null;
  dueDate: string | null;
  columnId: string;
}

export interface BoardColumn {
  id: string;
  title: string;
  taskIds: string[];
}

export interface BoardState {
  tasks: Record<string, Task>;
  columns: Record<string, BoardColumn>;
  columnOrder: string[];
}

export type NewTask = Pick<Task, "title" | "columnId"> &
  Partial<Pick<Task, "description" | "priority" | "assigneeId" | "dueDate">>;

export type TaskUpdate = Partial<Omit<Task, "id">> & { id: string };

Build steps

  1. 1Define the domain types — Task, BoardColumn, the normalized BoardState, and the NewTask and TaskUpdate payload types.
  2. 2Build the Zustand store with actions addTask, updateTask, moveTask, and reorderColumn, each with precise signatures.
  3. 3Write moves.ts with pure moveTask and reorder helpers that return new state and never mutate arrays in place.
  4. 4Render Board and Column from columnOrder and taskIds, resolving ids through the Record maps with explicit undefined checks.
  5. 5Integrate dnd-kit, typing drag-end events and translating them into moveTask calls.
  6. 6Build TaskDrawer for editing a task, submitting a TaskUpdate so untouched fields stay optional.
  7. 7Implement the API route handlers with typed JSON bodies and matching response types shared with the client.
  8. 8Add the optimistic-update wrapper in api.ts that rolls back store changes if the server rejects a move.
  9. 9Add priority badges and overdue highlighting derived from dueDate, keeping all date parsing in one helper.