This document outlines the development of a full-stack application for Task Management system comprising of a React frontend and a Django backend. Essentially, the system should allow the users to perform CRUD operations on tasks with required additional functinalities including marking a task completed.
To create a basic task management application with the following features:
- RESTful APIs to perform CRUD operations on "Task" entity
- Python Django based backend containing core business logic
- Basic Authentication & Authorisation for User Management using Django's built-in authentication system
- Support for Additional functionalities like ability to mark a task completed, with a completed task having a visibly different UI
- Robust system with proper validations and error handling
- Quality of output ensured with unit tests using Django's testing framework
- ReactJS based frontend and user interface with core business logic powered by backend APIs
- Ability to list tasks, create new tasks, update existing tasks, and delete tasks
- UI should use proper state Management techniques to manage UI and keep it responsive
- Quality of output ensured with unit tests for frontend components using Jest or any other testing library
Architecture Choice: Monolithic
Given the scope of this project, a monolithic approach is appropriate for faster development and ease of deployment. The architecture includes:
-
Framework: Django
-
APIs: RESTful
-
Database: SQLite (for simplicity; can scale to PostgreSQL for production)
-
Key Apps:
- /apps/tasks: App for handling task-related data and business logic.
- /apps/users: App for user authentication and management.
- Framework: React Javascript
- Styling: CSS for UI responsiveness and distinct task statuses.
- State Management: React Context API for global state handling.
TBA
id
: Primary Keytitle
: String, max length 255description
: Text, optionalpriority
: Enum(String)completed
: Boolean, default Falsecreated_at
: Timestampupdated_at
: Timestampdeleted_at
: Timestamp, nullableparent_task_id
: Foreign Key, nullableassignee_id
: Foreign Key , nullablecreated_by
: Foreign Keyupdated_by
: Foreign Key
- Django’s default User model is used for authentication and authorization.
git clone [email protected]:piyushgupta27/task-management-app.git cd task-management-app
cd backend python3 -m venv venv source venv/bin/activate
pip install -r requirements.txt
python manage.py makemigrations python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
cd frontend
npm install
npm start
Visit http://localhost:3000 in your browser to see the React app.
Use the Postman Collection provided in the repository for API testing:
POST /tasks/
Request:
curl -X POST http://localhost:8000/tasks/ \ --header 'Authorization: ••••••' \ -H "Content-Type: application/json" \ -d '{ "title": "Finish Documentation", "description": "Complete the task management API documentation" }'
Response:
{ "id": 1, "title": "Initial Task", "description": "Write a detailed description for the initial task.", "completed": false, "created_at": "2024-12-16T05:32:28.002166Z", "updated_at": "2024-12-16T05:32:28.002224Z", "created_by": 1, "updated_by": 1 }
GET /tasks/
Request:
curl --location 'http://localhost:8000/api/v1/tasks/' \ --header 'Authorization: ••••••' \ --header 'Content-Type: application/json' \
Response:
[ { "id": 1, "title": "Initial Task", "description": "Write a detailed description for the initial task.", "completed": false, "created_at": "2024-12-16T05:32:28.002166Z", "updated_at": "2024-12-16T05:32:28.002224Z", "created_by": 1, "updated_by": 1 }, { "id": 2, "title": "Initial Task", "description": "Write a detailed description for the initial task.", "completed": false, "created_at": "2024-12-16T05:33:26.409208Z", "updated_at": "2024-12-16T05:33:26.409236Z", "created_by": 1, "updated_by": 1 }, { "id": 3, "title": "Initial Task", "description": "Write a detailed description for the initial task.", "completed": false, "created_at": "2024-12-16T05:34:00.526801Z", "updated_at": "2024-12-16T05:34:00.526838Z", "created_by": 1, "updated_by": 1 } ]
GET /tasks/{id}/
Request:
curl --location 'http://localhost:8000/api/v1/tasks/1/' \ --header 'Authorization: ••••••' \ -H "Content-Type: application/json"
Response:
{ "id": 1, "title": "Initial Task", "description": "Write a detailed description for the initial task.", "completed": false, "created_at": "2024-12-16T05:32:28.002166Z", "updated_at": "2024-12-16T05:32:28.002224Z", "created_by": 1, "updated_by": 1 }
PUT /tasks/{id}/
Request:
curl --location --request PATCH 'http://localhost:8000/api/v1/tasks/5/' \ --header 'Content-Type: application/json' \ --header 'Authorization: ••••••' \ --data '{ "description": "This is updated detailed description for the new task to test mark-completed API." }'
Response:
{ "id": 5, "title": "New Task", "description": "This is updated detailed description for the new task to test mark-completed API.", "completed": true, "created_at": "2024-12-21T12:13:12.271280Z", "updated_at": "2024-12-23T03:23:49.033556Z", "created_by": 2, "updated_by": 2 }
PUT /tasks/{id}/mark-completed
Request:
curl --location --request PATCH 'http://localhost:8000/api/v1/tasks/5/mark-completed' \ --header 'Content-Type: application/json' \ --header 'Authorization: ••••••' \
Response:
{ "id": 5, "title": "New Task", "description": "Detailed description for the new task to test mark-completed API.", "completed": true, "created_at": "2024-12-21T12:13:12.271280Z", "updated_at": "2024-12-23T03:23:49.033556Z", "created_by": 2, "updated_by": 2 }
DELETE /tasks/{id}/
Request:
curl -X DELETE http://localhost:8000/tasks/1/ \ -H "Content-Type: application/json"
Response:
{ "status": "success", "message": "Task deleted successfully." }
- Use Django’s built-in test suite to run tests.
- Run the following command to execute tests:
cd backend pytest --cov=tasks --cov-report=html
TBA
- Write unit tests for the frontend components using Jest and React Testing Library.
- Deploy the application to production (optional).
- Integrate task categories, notifications, or advanced filtering as future enhancements.