StudyMate Backend API is a RESTful backend project built using Node.js and Express.js. It is developed as part of DecodeLabs Full Stack Development Project 2, focused on backend API development, server-side logic, input validation, and REST API concepts.
This backend provides APIs to manage student study tasks such as adding tasks, fetching tasks, updating task details, marking tasks as completed, deleting tasks, and filtering tasks based on subject or completion status.
The main objective of this project is to build a simple and structured backend API that can handle application logic and manage data flow between a frontend application and the server.
The project uses JSON file-based storage, so task data is saved inside a local tasks.json file without using a database.
- Create a new study task
- Get all study tasks
- Get a single task by ID
- Update task details
- Mark task as completed
- Delete a task
- Filter tasks by subject
- Filter tasks by completed status
- Basic input validation
- Proper HTTP status codes
- JSON file-based data storage
- Clean folder structure using routes, controllers, and middleware
- CORS enabled for frontend connection
- Error handling for invalid routes and invalid task IDs
- Node.js
- Express.js
- JavaScript
- CORS
- Nodemon
- JSON
studymate-backend/
│
├── controllers/
│ └── taskController.js
│
├── data/
│ └── tasks.json
│
├── middleware/
│ └── validateTask.js
│
├── routes/
│ └── taskRoutes.js
│
├── node_modules/
│
├── .gitignore
├── package-lock.json
├── package.json
├── README.md
└── server.js
http://localhost:5000
GET /Response:
StudyMate Backend API is running...
GET /api/tasksResponse Example:
{
"success": true,
"message": "Tasks fetched successfully",
"count": 0,
"data": []
}GET /api/tasks/:idExample:
GET /api/tasks/1765460000000POST /api/tasksRequest Body:
{
"title": "Complete DBMS Assignment",
"subject": "DBMS",
"deadline": "2026-06-15",
"priority": "High"
}Response Example:
{
"success": true,
"message": "Task added successfully",
"data": {
"id": 1765460000000,
"title": "Complete DBMS Assignment",
"subject": "DBMS",
"deadline": "2026-06-15",
"priority": "High",
"completed": false,
"createdAt": "2026-06-11T18:00:00.000Z"
}
}PUT /api/tasks/:idExample:
PUT /api/tasks/1765460000000Request Body:
{
"completed": true
}You can also update other task fields:
{
"title": "Complete Operating System Notes",
"subject": "Operating System",
"deadline": "2026-06-20",
"priority": "Medium",
"completed": false
}DELETE /api/tasks/:idExample:
DELETE /api/tasks/1765460000000GET /api/tasks?subject=DBMSGET /api/tasks?completed=trueor
GET /api/tasks?completed=false{
"id": 1765460000000,
"title": "Complete DBMS Assignment",
"subject": "DBMS",
"deadline": "2026-06-15",
"priority": "High",
"completed": false,
"createdAt": "2026-06-11T18:00:00.000Z"
}The API validates required task fields before creating a new task.
Required fields:
title
subject
If required fields are missing, the API returns:
{
"success": false,
"message": "Task title is required"
}or
{
"success": false,
"message": "Task subject is required"
}git clone https://github.com/Avi-reck/studymate-backend.gitcd studymate-backendnpm installFor development mode:
npm run devFor normal mode:
npm startServer will start on:
http://localhost:5000
You can test the API using:
- Thunder Client
- Postman
- Browser for GET requests
Recommended testing order:
1. GET /
2. GET /api/tasks
3. POST /api/tasks
4. GET /api/tasks/:id
5. PUT /api/tasks/:id
6. DELETE /api/tasks/:id
Do not upload the node_modules folder to GitHub.
The .gitignore file should contain:
node_modules/
.envThrough this project, I learned:
- How to create a backend server using Express.js
- How to build RESTful API endpoints
- How to handle GET, POST, PUT, and DELETE requests
- How to validate user input using middleware
- How to organize backend code using routes and controllers
- How to store and manage data using a JSON file
- How to return proper HTTP status codes and API responses
- How frontend and backend communicate through API requests
Aviral Singh B.Tech CSE (AI & ML) Student Frontend & Full Stack Development Enthusiast
GitHub: Avi-reck