This is a Django REST framework-based Task Management API that allows user registration, authentication, task management, and user retrieval. It includes token-based authentication, rate limiting, and an AWS Lambda simulation for task completion notifications.
- Python 3.x
- Django 3.x or later
- Django REST Framework
- PostgreSQL or SQLite (default)
-
Clone the repository:
git clone git@github.com:rahulg0/task-management.git cd task-management -
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Apply migrations:
python manage.py migrate
-
Create a superuser:
python manage.py createsuperuser
-
Run the development server:
python manage.py runserver
POST /api/register/Request Body:
{
"username": "testuser",
"email": "test@example.com",
"password": "securepassword"
}Response:
{
"message": "Successfully created user.",
"token": "<authentication_token>"
}POST /api/login/Request Body:
{
"email": "test@example.com",
"password": "securepassword"
}Response:
{
"token": "<authentication_token>",
"id": 1
}GET /api/get-users/Headers:
Authorization: Token <authentication_token>Response:
{
"users": [
{
"id": 1,
"username": "testuser",
"email": "test@example.com"
}
]
}GET /api/tasks/?status=Headers:
Authorization: Token <authentication_token>Response:
{
"tasks": [
{
"id": 1,
"title": "Task 1",
"status": "pending",
"assigned_to": 1
}
]
}POST /api/tasks/Headers:
Authorization: Token <authentication_token>Request Body:
{
"title": "New Task",
"description": "Task description",
"assigned_to": 2
}Response:
{
"message": "Successfully created task: New Task"
}PUT /api/tasks/{task_id}/Headers:
Authorization: Token <authentication_token>Request Body:
{
"status": "completed"
}Response:
{
"message": "Successfully updated task: New Task"
}DELETE /api/tasks/{task_id}/Headers:
Authorization: Token <authentication_token>Response:
{
"message": "Task deleted successfully"
}- Provides a structured and scalable approach for API development.
- Token-based authentication ensures secure access.
- Enhances maintainability and code reuse.
- Simplifies handling different HTTP methods.
permissions.IsAuthenticatedensures only authorized users can access certain endpoints.permissions.AllowAnyallows open access for login and registration.TokenAuthenticationsecures API requests.
- Superusers can create, assign, and delete tasks.
- Regular users can only update the status of their assigned tasks.
- Query parameters allow task filtering by status.
UserRateThrottleprevents API abuse.- Unit tests validate throttling behavior.
statusandassigned_tofields inTaskmodel havedb_index=True.- Improves filtering and lookup speed.
- Optional feature to simulate a Lambda function call when a task is completed.
- Useful for event-driven processing.
- Users are uniquely identified via email.
- Only superusers can manage tasks and user data.
To run tests for tasks throttling, execute:
python manage.py testThis API balances security, scalability, and maintainability, making it efficient for managing tasks with proper access control.