Prerequisites
Before you begin, ensure you have the following installed:Node.js
Version 18 or higher
npm
Version 9 or higher
Installation
Clone the Repository
First, clone the Task Manager repository to your local machine:This downloads the complete application including both the API backend and web frontend.
Install Dependencies
Install all required npm packages:This installs:
- express (5.1.0) - Web framework
- db-local (3.1.0) - JSON database
- zod (4.1.12) - Schema validation
- cors (2.8.5) - Cross-origin support
- dotenv (17.2.3) - Environment configuration
Configure Environment Variables
Create a Add the following configuration:
.env file in the project root directory:The PORT variable determines which port the Express server listens on. You can change this to any available port if 3000 is already in use.
Start the Server
Launch the application in development mode:You should see:For production, use:
Development mode uses Node.js watch mode (
--watch flag), automatically restarting the server when source files change.Creating Your First Task
Now that Task Manager is running, let’s create a task using both the API and the web interface.Option 1: Using the REST API
Create a Task via POST Request
Use curl or any HTTP client to create your first task:The API validates your request using the Zod schema defined in
src/schemas/task.js:3:Examine the Response
The API returns a 201 Created status with the complete task object:Notice:
_idis automatically generated using UUID v4 (src/models/task.js:7)createdAttimestamp is set automaticallycategoryIddefaults to empty string (“uncategorized”)completedis false as specified
Option 2: Using the Web Interface
Open the Application
Navigate to
http://localhost:3000 in your browser. You’ll see the main task management interface with:- Header: “Gestor de tareas”
- ”+ Crear tarea” button
- “Gestionar Categorías” button
- Empty task list (initially)
Click Create Task
Click the green ”+ Crear tarea” button. This opens a modal dialog with a task form.The modal is managed by
public/js/controllers/Modal.js and the form is rendered by public/js/views/Task.js.Fill in Task Details
In the modal form, enter:
- Title: “My First Task” (required, 3-25 characters)
- Description: “Learning Task Manager” (optional, max 25 characters)
- Finished: Leave unchecked (defaults to false)
- Category: Select “uncategorized” (default option)
Save the Task
Click the “Guardar” (Save) button. The form data is sent to the API using the TaskService class (The modal closes and your new task appears in the task list.
public/js/services/Task.js:26):Interact with Your Task
Your task now appears in the interface. You can:
- View details - Click on the task to see full information
- Mark complete - Check the completion checkbox to update status
- Edit - Click the edit icon to modify title or description
- Delete - Click the delete icon to remove the task
Working with Categories
Organize your tasks using categories:Common API Operations
Here’s a quick reference for essential API operations:Get All Tasks
Get Single Task
Create Task
Update Task
Delete Task
List Categories
Validation and Error Handling
Task Manager uses Zod for runtime validation. Understanding validation helps you handle errors gracefully:Common Validation Errors
Title Too Short
Title Too Short
Error: Title must be at least 3 charactersResponse:
400 Bad Request with Zod error detailsTitle Too Long
Title Too Long
Error: Title cannot exceed 25 charactersResponse:
400 Bad RequestTask Not Found
Task Not Found
Error: Attempting to update or delete a non-existent taskResponse:
404 Not Found with message “Task not found”This check happens in the controller (src/controllers/task.js:14):Next Steps
Now that you have Task Manager running:Explore the API
Learn about all available endpoints, request formats, and response codes
Architecture Deep Dive
Understand the modular design and how components interact
Task Management Features
Learn about task CRUD operations and completion tracking
Category Management
Organize your tasks with custom categories
Troubleshooting
Port Already in Use
Port Already in Use
If port 3000 is already in use:
- Change the PORT in your
.envfile - Restart the server
- Update the API base URL in
public/js/config.jsif accessing the frontend
Database Not Persisting
Database Not Persisting
Ensure the
./src/DB/ directory exists and is writable. The db-local library creates JSON files here:CORS Errors in Browser
CORS Errors in Browser
The application includes CORS middleware (
src/middlewares/cors.js). If you’re accessing from a different origin, you may need to configure allowed origins.Module Not Found Errors
Module Not Found Errors
Ensure all dependencies are installed: