This project is a full-stack Todo application built using React with Tailwind CSS for the frontend, Node.js with Express for the backend, and MongoDB for the database. It includes Swagger for API documentation.
Check out the live demo here! : https://todos-react-app-xi.vercel.app/
- Frontend: React, Tailwind CSS
- Backend: Node.js, Express
- Database: MongoDB
- API Documentation: Swagger
- Prerequisites
- Installation
- Running the Frontend
- Running the Backend
- API Documentation with Swagger
- Testing
- Todo Application Development Stories
Make sure you have the following installed:
- Node.js (v18+)
- npm (v8+)
- Git
git clone https://github.com/Winateewii/todos-react-node
cd todos-react-nodeNavigate to the frontend folder and install the required packages:
cd web
npm installIn a separate terminal, navigate to the backend folder and install the required packages:
cd ../api
npm install- Navigate to the
frontenddirectory.
cd web- Start the development server:
npm start- Open http://localhost:3000 to view the app in your browser.
The frontend will start on port 3000.
- Navigate to the
backenddirectory:
cd api- Create an
.envfile in thebackenddirectory and add your environment variables (e.g., MongoDB URI).
Example .env file:
PORT=8080
MONGODB_URI=**********
NOTE: MONGODB_URI contains critical information so I will provide this separately
- Start the backend server:
npm run dev- The backend will be running on http://localhost:8080.
- After starting the backend, you can access the API documentation generated by Swagger at:
http://localhost:8080/api-docs
You can run tests for the frontend and backend as follows:
- Navigate to the
frontenddirectory. - Run the tests using:
npm test-
Render the Component
- Description: Ensures that the
TaskManagerPagecomponent renders without crashing.
- Description: Ensures that the
-
Add a New Task
- Description: Validates that a new task can be successfully added to the task list.
-
Edit an Existing Task
- Description: Checks that an existing task can be edited and the changes can be saved.
-
Toggle Task Status
- Description: Verifies that a task can be marked as done and then undone.
-
Delete a Task
- Description: Ensures that a task can be deleted from the task list.
Here's a breakdown of the problem statement into small user stories for the development of a Todo application
- Description: Develop the basic user interface to display the "My tasks" header, an input field to add a new task, and a list section for tasks that the user inputs.
- Tasks:
- Create a React component for the task input field.
- Implement a simple text input where users can type a task.
- Design a task list section using Tailwind CSS to display tasks.
- Add a "Add a task" placeholder with a suggestion like "Try typing 'Buy milk'".
- Description: Allow users to add tasks via the input field, which will be displayed in the list below once added.
- Tasks:
- Create a function to handle new task submission.
- Update the state to reflect added tasks and show them in the list.
- Use React hooks like
useStateto manage the list of tasks.
- Description: Create a backend API that will allow adding tasks to a MongoDB database.
- Tasks:
- Set up Express.js backend with a POST endpoint to add new tasks.
- Create a MongoDB schema for tasks.
- Store added tasks in the MongoDB database.
- Connect Frontend to Backend using Axios for task submission.
- Description: Fetch the task list from the backend and display it on the frontend upon page load.
- Tasks:
- Add a GET endpoint in the backend to retrieve all tasks.
- Fetch tasks using Axios on the frontend and store them in state.
- Render the tasks in the list on the UI.
- Description: Add an edit button next to each task that allows users to modify the task.
- Tasks:
- Implement an edit button (as shown in the UI).
- Upon clicking the edit button, allow the user to change the task.
- Description: Create a backend API to handle task updates when users edit a task.
- Tasks:
- Create an Express PUT endpoint to handle task updates.
- Write code to update the task in MongoDB.
- Connect the frontend to this PUT API to ensure that updates persist in the database.
- Description: Allow users to delete tasks from the list.
- Tasks:
- Add a delete button (or icon) for each task(The delete icon should show after task done).
- Handle the click event to remove the task from the frontend state.
- Create a DELETE API endpoint on the backend.
- Remove the task from the MongoDB database.
- Description: Make the task list visually appealing by improving the design and layout using Tailwind CSS.
- Tasks:
- Add spacing, borders, or backgrounds to make tasks easily distinguishable.
- Style the input field and task list using Tailwind utilities for a clean look.
- Description: Show a loading state while tasks are being fetched from the backend.
- Tasks:
- Implement a loading spinner or indicator using React state.
- Show the loader when tasks are being fetched and hide it after the tasks are loaded.
- Description: Integrate Swagger into the backend to document the APIs for adding, fetching, updating, and deleting tasks.
- Tasks:
- Add Swagger setup in the Express.js backend.
- Document each API endpoint.