A todo list is the "hello world" of front-end system design. Everyone has built one. But building one that survives a production code review — with persistence, drag reorder, voice input, and offline support — requires real architectural thinking.
A deep dive into designing, building, and shipping a performant todo list app — from CRUD operations and drag reorder to offline sync and conversational voice input.
FrontendX Engineering · System Design Series
A todo list is the "hello world" of front-end system design. Everyone has built one. But building one that survives a production code review — with persistence, drag reorder, voice input, and offline support — requires real architectural thinking.
The todo list follows a flat, composable hierarchy. There's no need for deep nesting because every piece has a single responsibility and they communicate through a central store.
The key insight is that TodoApp owns all state and passes slices down. No child talks to localStorage directly — they dispatch actions, and the reducer handles persistence through a write-through pattern. This keeps components pure and testable.
EditInline component at the bottom. Clicking a task title swaps it to an input field. Blurring or pressing Enter commits the edit. It's a small detail but eliminates the need for a separate edit modal entirely.Here's a principle I swear by: store the minimum, derive the rest. In a todo list, we only store the raw task data and a sort order. The counts (total, active, completed) are derived values — if we stored them, they'd inevitably drift.
Every task has exactly one source of truth: its entry in the tasks map. The taskOrder array controls display order and is what drag-and-drop manipulates. This separation lets us reorder without touching task data, and filter without losing order.
Record<string, Task> map instead of a flat array is deliberate. Lookup by ID is O(1), updates don't require searching, and deletion is a simple O(1) spread omit. Never store computed data.In the RADIO framework, the I defines the contracts — both between the browser and the server, and between components within the app. For a todo list that works offline, the server API is a sync target, not a live dependency.
The REST API is straightforward — standard CRUD endpoints with a batch sync endpoint for offline recovery. The key design choice is that every mutation returns the full updated task, so the client can reconcile local state without guessing.
Components communicate exclusively through the store. No props drilling, no callback pyramids. TodoApp subscribes to state, passes slices to children, and exposes a dispatch function.
Every CRUD operation follows the same pattern: dispatch optimistically, persist to localStorage, then fire the API call. If the API fails, rollback. If we're offline, queue the mutation.
The reducer is a pure function — given the same state and action, it always returns the same next state. This makes it trivially testable and safe for rollback replay.
The toggle is the most frequent user action. It needs to feel instant. Here's the full flow with error recovery:
Persistence is what separates a toy todo app from a real one. When the user refreshes the page and their tasks are still there, that's the moment they trust your app.
localStorage is synchronous, capped at ~5MB, and blocks the main thread. For a todo list with under 10,000 items, it's perfect. The serialization overhead of a few hundred tasks is under 1ms. If you anticipate 50,000+ tasks or need to store attachments, switch to IndexedDB with an async wrapper like Dexie.js.
On mount, the app reads persisted state and feeds it to the reducer as the initial value. If no persisted state exists, it starts fresh. The key detail: we run the hydration synchronously before the first render, so there's no flash of empty state.
useReducer. Zero flicker, zero complexity.Drag reorder is the most UX-intensive feature in the app. Users expect it to feel physical — items should track their finger (or cursor) with zero lag, snap into place, and animate the gap.
@dnd-kit is the gold standard for React drag-and-drop. It uses a collision detection algorithm (closest center, closest corners) to determine drop position, supports keyboard and screen reader interactions out of the box, and handles virtual list integration. It's also tiny — ~5KB gzipped if you tree-shake unused packages.
We use fractional indexing for order: each task gets a order value (e.g., 1000, 2000, 3000). When a task moves between two others, its new order is the average of its neighbors. This avoids re-indexing the entire list. The taskOrder array in our store gives us O(1) indexed access, and the sortable context in @dnd-kit directly manipulates this array via arrayMove.
createdAt breaks the tie.Filtering is where derived state shines. The filter and search query are stored as strings. The filtered task list is — you guessed it — computed on every render from the source of truth.
For a list of 10,000 tasks, the filter runs in under 2ms — well within a single frame budget. If the list grows to 100k, we'd memoize the filtered result with useMemo or switch to a virtualized list that only renders visible items. But for 99% of todo apps, the naive approach is fast enough.
(completed / total) * 100. Never store it. If the user completes a task, the percentage automatically updates because it's computed from live data.Offline support is the hardest part of the todo list. It's also the feature that turns a good system design answer into a great one. The architecture follows a local-first pattern: all mutations go to local state first, then attempt server sync.
When offline, mutations are serialized to a separate localStorage queue. Each mutation carries a UUID, type, payload, and timestamp. When the browser fires the online event, we flush the queue in order.
For a single-user todo list, conflicts are rare but possible (think: user adds a task on their phone while offline, then adds another on their desktop). We use Last-Writer-Wins (LWW) — the mutation with the latest timestamp wins. It's simple, predictable, and good enough for tasks. If you needed collaborative editing, you'd reach for CRDTs, but that's overkill here.
online event fires when the browser regains connectivity, but the first request may still fail (DNS delay, proxy, captive portal). Implement exponential backoff: 1s → 2s → 4s → 8s — cap at 30s. Never retry instantly.Voice input transforms the todo app from a typing interface into a hands-free capture tool. The Web Speech API provides browser-native speech recognition — no external SDKs, no monthly fees.
The implementation is a custom hook that wraps SpeechRecognition. It returns listening state and the transcribed text. When the user taps the mic button, recognition starts; when they stop speaking, the result is captured and used to populate the input field.
The voice experience is designed to be conversational: tap the mic, say "Buy milk and eggs," see the text appear in the input, then hit Enter or say "add it." The mic button shows a pulsing animation while listening, and an error state if the browser doesn't support the API (falling back gracefully to the text input).
A todo list with 50 items is trivial. A todo list with 50,000 items requires serious optimization. Here's how we handle both ends of the spectrum.
Past ~500 tasks, rendering every DOM node becomes expensive. Virtual scrolling (also called windowing) only renders the tasks that fit in the viewport, plus a small overscan buffer. Using TanStack Virtual (formerly react-virtual), we render 20 DOM nodes instead of 50,000. The scrollbar tracks the full list height but the DOM stays tiny.
Every TaskItem is wrapped in React.memo. The parent only passes primitive props (id, title, completed) — no inline objects or functions — so shallow comparison works. The dispatch function is stable across renders because useReducer guarantees it.
@dnd-kit uses transform: translate3d() for the dragging overlay — the GPU handles it without triggering layout. The sortable animation uses transition: transform 200ms ease on the placeholder gap. Both are composited properties, so drag feels 60fps smooth even on mid-range phones.
transform and opacity. Animating height, margin, or top triggers layout recalculations on every frame. One layout thrash and your 60fps becomes 15fps.The core todo list (without drag-and-drop or voice) is ~4KB gzipped — just React and the reducer. Add @dnd-kit for ~5KB and voice is native (0KB). Total: under 10KB. This is possible because we use no external state library — just useReducer + local storage.
The todo list is simple enough that most bugs come from edge cases — empty state, rapid toggling, sync conflicts. Here's how we cover them.
The todoReducer is a pure function. We test every action type, verifying state transitions. Edge cases: toggling a non-existent task, adding a task with an empty title, deleting the last task, and reordering a single-item list. These tests run in milliseconds with zero setup.
Integration tests verify the full pipeline: render, add a task, toggle it, filter, delete. We mock the localStorage adapter to verify persistence is called on every mutation. We also test the offline queue: go offline, add tasks, come back online, verify flush.
We use @dnd-kit's testing utilities to simulate drag operations. The test creates a sortable context, triggers a pointer-down on item A, pointer-move to position of item B, and pointer-up. We assert that taskOrder reflects the new arrangement. This catches regressions in the ordering logic without needing a real browser environment.
A todo list is used daily. If it's not accessible, you're making someone's daily routine harder. Here's how we build inclusive task management.
KeyboardSensor).role="listitem", the checkbox has aria-label=Toggle "'title{'}", and the delete button has aria-label=Delete "'title{'}". No generic "Delete" labels.aria-live="polite" region announces the change. Screen reader users hear "Task 'Buy milk' added" without interruption.<button> with aria-label="Add task by voice". While listening, the label updates to "Listening..." so screen readers reflect the state.After all that theory, here's a live todo list running in your browser. Add a task, toggle it, drag to reorder, try the voice input — everything we covered is running right here.
Keyboard shortcut: Tab to navigate, Space to toggle, Delete to remove. Try it without your mouse.
A todo list looks simple. A well-designed todo list is anything but. Here's what to remember:
Never store counts, percentages, or filtered lists. Compute them from the source of truth.
Write to local state first, persist synchronously, sync asynchronously. Offline is the default.
Capture snapshot, dispatch, call API. On error, restore snapshot. Users never see a spinner.
Avoid re-indexing the entire list. Use fractional indices or a separate order array.
Don't render tasks the user can't see. TanStack Virtual keeps DOM nodes constant.
Web Speech API adds delight but must degrade gracefully. Always support keyboard fallback.