This is a FastAPI-based task management application that allows users to register and manage tasks with CRUD (Create, Read, Update, Delete) functionality. The application supports user registration with hashed passwords and tasks with statuses such as "pending," "in-progress," and "completed."
-
User Registration:
- Registers users with hashed passwords for security.
- Ensures uniqueness of email and username during registration.
-
Task Management:
- Create Tasks: Add new tasks with title, description, due date, and status.
- Retrieve Tasks: Fetch all tasks with pagination support or retrieve a task by its ID.
- Update Tasks: Modify task details, including title, description, due date, and status.
- Delete Tasks: Remove a task by its ID.
-
Homepage:
- Provides a simple welcome message at the root endpoint.
- GET
/
- Response: A welcome message.
- POST
/users/register/
- Request Body:
{ "username": "string", "email": "string", "password": "string" }
- Response:
- Success:
"Registration successful"
- Error:
HTTP 400 - Email or Username already registered
- Success:
- Request Body:
- POST
/tasks
- Request Body:
{ "title": "string", "description": "string", "dueDate": "datetime", "status": "pending | in-progress | completed" }
- Response:
- Success: Task data with HTTP 201.
- Error:
HTTP 400
for validation issues.
- Request Body:
- GET
/tasks
- Query Parameters:
page
(default: 0)limit
(default: 10)
- Response:
- Success: List of tasks with pagination.
- Error:
HTTP 404
if no tasks found.
- Query Parameters:
- GET
/tasks/{id}
- Path Parameter:
id
: Task ID (integer)
- Response:
- Success: Task data.
- Error:
HTTP 404
if task not found.
- Path Parameter:
- PUT
/tasks/{id}
- Path Parameter:
id
: Task ID (integer)
- Request Body:
{ "title": "string", "description": "string", "dueDate": "datetime", "status": "pending | in-progress | completed" }
- Response:
- Success: Updated task data.
- Error:
HTTP 404
if task not found.
- Path Parameter:
- DELETE
/tasks/{id}
- Path Parameter:
id
: Task ID (integer)
- Response:
- Success:
"Deleted Successfully"
- Error:
HTTP 404
if task not found.
- Success:
- Path Parameter:
- Python 3.9 or later
- Dependencies listed in
requirements.txt
- Clone the repository:
git clone https://github.com/TYDev01/HNG_CRUD_CHALLENGE.git cd <repository-folder>
pip install -r requirements.txt
Create a .env file and set the necessary database connection details.
- Initialize the database:
from .database import init_db init_db()
- Starting the server
fastapi dev main.py