This is a Task Management API built with Go and MongoDB. It allows users to create, read, update, and delete projects and tasks, including support for subtasks.
- Project Management: Create, read, update, and delete projects. Get tasks by project.
- Task Management: Create, read, update, and delete tasks.
- Subtasks: Support for creating subtasks under main tasks.
- Search and Filter: Search tasks by name, status, or priority.
- Go (latest version)
- MongoDB
-
Clone the repository:
git clone https://github.com/iknizzz1807/task-management-api.git cd task-management-api -
Install dependencies:
go mod tidy
-
Set up MongoDB connection in
database.goclient, err = mongo.Connect(context.Background(), options.Client().ApplyURI("mongodb://localhost:27017"))
-
Run the application:
go run main.go
- Endpoint:
GET /projects - Response:
{ "status": "success", "count": 2, "projects": [ { "id": "60d5ec49f1e4c2d2f8f0e4b1", "name": "Study", "description": "Study related tasks", "created_at": "2023-01-01T00:00:00Z", "updated_at": "2023-01-01T00:00:00Z" } ] }
- Endpoint:
GET /project/{id} - Response:
{ "status": "success", "project": { "id": "60d5ec49f1e4c2d2f8f0e4b1", "name": "Study", "description": "Study related tasks", "created_at": "2023-01-01T00:00:00Z", "updated_at": "2023-01-01T00:00:00Z" }, "tasks": [ { "id": "60d5ec49f1e4c2d2f8f0e4b2", "name": "Complete homework", "description": "Finish math homework", "deadline": "2023-12-31T23:59:59Z", "priority": "High", "status": "Incomplete", "parent_id": null, "project_id": "60d5ec49f1e4c2d2f8f0e4b1", "created_at": "2023-01-01T00:00:00Z", "updated_at": "2023-01-01T00:00:00Z" } ], "count": 1 }
- Endpoint:
POST /project - Request Body:
{ "name": "Study", "description": "Study related tasks" } - Response:
{ "status": "success", "project": { "id": "60d5ec49f1e4c2d2f8f0e4b1", "name": "Study", "description": "Study related tasks", "created_at": "2023-01-01T00:00:00Z", "updated_at": "2023-01-01T00:00:00Z" } }
- Endpoint:
PUT /project/{id} - Request Body:
{ "name": "Study Updated", "description": "Updated study related tasks" } - Response:
{ "status": "success", "project": { "id": "60d5ec49f1e4c2d2f8f0e4b1", "name": "Study Updated", "description": "Updated study related tasks", "created_at": "2023-01-01T00:00:00Z", "updated_at": "2023-01-01T00:00:00Z" } }
- Endpoint:
DELETE /project/{id} - Response:
{ "status": "success" }
- Endpoint:
GET /tasks - Query Parameters:
name(optional)status(optional)priority(optional)
- Response:
{ "status": "success", "count": 2, "tasks": [ { "id": "60d5ec49f1e4c2d2f8f0e4b2", "name": "Complete homework", "description": "Finish math homework", "deadline": "2023-12-31T23:59:59Z", "priority": "High", "status": "Incomplete", "parent_id": null, "project_id": "60d5ec49f1e4c2d2f8f0e4b1", "created_at": "2023-01-01T00:00:00Z", "updated_at": "2023-01-01T00:00:00Z" } ] }
- Endpoint:
POST /task - Request Body:
{ "name": "Complete homework", "description": "Finish math homework", "deadline": "2023-12-31T23:59:59Z", "priority": "High", "status": "Incomplete", "parent_id": "60d5ec49f1e4c2d2f8f0e4b3", // Optional "project_id": "60d5ec49f1e4c2d2f8f0e4b1" // Required } - Response:
{ "status": "success", "task": { "id": "60d5ec49f1e4c2d2f8f0e4b2", "name": "Complete homework", "description": "Finish math homework", "deadline": "2023-12-31T23:59:59Z", "priority": "High", "status": "Incomplete", "parent_id": "60d5ec49f1e4c2d2f8f0e4b3", "project_id": "60d5ec49f1e4c2d2f8f0e4b1", "created_at": "2023-01-01T00:00:00Z", "updated_at": "2023-01-01T00:00:00Z" } }
- Endpoint:
PUT /task/{id} - Request Body:
{ "name": "Complete homework updated", "description": "Finish math homework updated", "deadline": "2023-12-31T23:59:59Z", "priority": "Medium", "status": "Ongoing", "parent_id": "60d5ec49f1e4c2d2f8f0e4b3", // Optional "project_id": "60d5ec49f1e4c2d2f8f0e4b1" // Required } - Response:
{ "status": "success", "task": { "id": "60d5ec49f1e4c2d2f8f0e4b2", "name": "Complete homework updated", "description": "Finish math homework updated", "deadline": "2023-12-31T23:59:59Z", "priority": "Medium", "status": "Ongoing", "parent_id": "60d5ec49f1e4c2d2f8f0e4b3", "project_id": "60d5ec49f1e4c2d2f8f0e4b1", "created_at": "2023-01-01T00:00:00Z", "updated_at": "2023-01-01T00:00:00Z" } }
- Endpoint:
DELETE /task/{id} - Response:
{ "status": "success" }
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License.
This README provides an overview of the project, installation instructions, and detailed API documentation.