Taskflow is a real-time, collaborative task queue system built to teach backend engineering from first principles.
This repository intentionally avoids backend frameworks so learners can understand exactly what happens under the hood in production systems. Routing, request parsing, state management, and API behavior are implemented manually using core Node.js APIs.
Most tutorials start with frameworks and hide core mechanics. Taskflow does the opposite:
- Build with core Node.js first.
- Understand architecture and tradeoffs before abstractions.
- Learn data structures and algorithmic complexity in context.
- Introduce advanced capabilities (streaming, worker threads, WebSockets) progressively.
The result is a learning-first codebase that teaches both implementation and reasoning.
The code currently includes Part 1 and Part 2 foundations:
- Raw Node.js HTTP server with manual routing
- Full CRUD endpoints for tasks
- Manual JSON body parsing from request stream
- In-memory task store using JavaScript Map (Hash Map)
- Singleton data-store pattern through Node module caching
- Big O benchmark script comparing Array search vs Map lookup
Planned parts are documented in the roadmap below and expanded in the learner guides.
- Runtime: Node.js
- Current external npm packages: none
- Planned single exception: ws (introduced in final WebSocket step)
Everything else is built with built-in Node.js modules.
- server.js: HTTP server, route handling, JSON parsing, response handling
- benchmarks.js: Big O demonstration (Array.find vs Map.get)
- src/store/TaskStore.js: In-memory task storage class and singleton export
- learner/README.md: Learning path and deep-dive documentation index
- Node.js 18+ recommended (crypto.randomUUID support)
node server.jsExpected startup output:
- TaskFlow server is running on http://localhost:3000
- Listening for requests... (Press Ctrl+C to stop)
node benchmarks.jsYou should observe significantly faster Map lookup timing compared to Array.find for large collections.
Base URL: http://localhost:3000
Returns all tasks.
Response 200 example:
[
{
"id": "5e9d2f1f-76f4-4f76-a6a6-2fba2dd22657",
"title": "Write README",
"description": "Document project",
"status": "pending",
"createdAt": "2026-03-26T07:00:00.000Z",
"updatedAt": "2026-03-26T07:00:00.000Z"
}
]Returns a single task by ID.
Success:
- 200 with task object
Failure:
- 404 with:
{ "error": "Task not found" }Creates a new task.
Request body (all fields optional in current implementation):
{
"title": "Prepare sprint board",
"description": "Create tasks for release",
"status": "pending"
}Defaults applied by store:
- title: Untitled Task
- description: empty string
- status: pending
Response:
- 201 with created task
- 400 with:
{ "error": "Invalid JSON payload format." }Updates an existing task by merging provided fields.
Request body example:
{
"status": "in-progress",
"title": "Prepare release board"
}Behavior:
- Existing task fields are merged with request fields.
- id cannot be overwritten.
- updatedAt is always refreshed.
Responses:
- 200 with updated task
- 404 with:
{ "error": "Task not found, update failed." }- 400 with:
{ "error": "Invalid JSON payload format." }Deletes a task.
Responses:
- 204 on success (no response body)
- 404 with:
{ "error": "Task not found, deletion failed." }- Unknown route: 404 { "error": "Route Not Found" }
- Unsupported method on /tasks routes: 405 { "error": "Method Not Allowed on this endpoint." }
curl -i -X POST http://localhost:3000/tasks \
-H "Content-Type: application/json" \
-d '{"title":"Implement auth middleware","description":"Part 5 prep","status":"pending"}'curl -i http://localhost:3000/tasksReplace TASK_ID with the id returned by create/list.
curl -i http://localhost:3000/tasks/TASK_IDcurl -i -X PUT http://localhost:3000/tasks/TASK_ID \
-H "Content-Type: application/json" \
-d '{"status":"in-progress"}'curl -i -X DELETE http://localhost:3000/tasks/TASK_IDEach task currently contains:
- id: UUID string generated by crypto.randomUUID
- title: string
- description: string
- status: string (pending, in-progress, completed are intended values)
- createdAt: ISO timestamp string
- updatedAt: ISO timestamp string
Note: status values are not yet validated by middleware. Validation is part of planned progression.
- Node http server accepts request.
- URL/method are parsed manually.
- For POST and PUT, request body is read from stream and parsed with JSON.parse.
- TaskStore methods are called.
- JSON response is sent with explicit status code and content-type.
TaskStore uses a JavaScript Map:
- get/set/delete/has operations are average-case O(1)
- predictable iteration order for getAll
- strong fit for ID-based lookup workloads
This aligns with real-world backend behavior where key-based access dominates.
TaskStore exports one instantiated object. Because Node caches modules after first require call, all imports share one in-memory task state for a process lifetime.
Implication:
- Data persists only while server process is running.
- Restarting server resets all tasks.
Taskflow’s intended progression covers:
- Raw HTTP API in Node.js without frameworks
- In-memory task store with Hash Map and complexity benchmark
- Priority queue for prioritized scheduling
- Linked-list dependency chains and recursive dependency resolution
- Middleware chain (authentication, authorization, validation)
- Global error handling and structured logging
- Intentional memory leak demonstration and remediation
- Worker Thread report generation for CPU-heavy processing
- Streaming CSV export via Node streams
- WebSocket live updates using ws
This repository currently has steps 1 and 2 implemented and provides learning material for the complete journey.
- Event Loop internals (Timers, Poll, Check phases)
- Call Stack and libuv responsibilities
- Memory model (stack vs heap) and V8 garbage collection behavior
- Leak patterns and prevention strategies
- Concurrency models: async I/O vs Worker Threads
- Big O notation for practical backend choices
- Core data structures: Arrays, Linked Lists, Hash Maps, Queues
- Algorithmic techniques: searching, sorting strategy selection, recursion
- Middleware as Chain of Responsibility
- Centralized error handling and logging discipline
- Streams for low-memory large response generation
- WebSockets for real-time synchronization
Detailed guides are available in learner/README.md.
- No persistence layer (in-memory only)
- No auth/permission middleware yet
- No schema validation middleware yet
- No global centralized error pipeline yet
- No worker threads, streams export, or WebSockets yet
- No automated tests yet
These are intentional for staged learning.
- Run server and call each endpoint manually.
- Read src/store/TaskStore.js and explain each operation’s time complexity.
- Run benchmark and discuss why complexity dominates at scale.
- Read learner guides in order from learner/README.md.
- Implement next roadmap step as an exercise.
- Add input validation for title and status without external libraries.
- Add a simple middleware runner function before route handlers.
- Add a global error responder that normalizes JSON error output.
- Extend benchmark script to compare Map vs Object for key lookup.
- Add pagination query support to GET /tasks.
Run server on a free port by changing PORT in server.js.
Verify request body is valid JSON and Content-Type is application/json.
Ensure the ID exists and was copied from a real create/list response.
Expected behavior. Store is in memory only.
A license file is not currently present in this repository. If this project is intended for public use, add a license to define usage rights.
Start here: learner/README.md
This folder contains clean, focused guides with practical examples designed for self-study, classroom use, and workshop delivery.