๐ FastAPI Task Manager API
A simple, secure, and production-ready Task Manager REST API built with FastAPI, JWT Authentication, Argon2 Password Hashing, and SQLAlchemy ORM. This project is perfect for learning backend development, FastAPI, authentication, and CRUD APIs.
๐ Features
User Registration & Login (JWT Authentication)
Secure password hashing using Argon2
Create, read, update, delete tasks (CRUD)
SQLite database (easy to run locally)
Protected routes using OAuth2 Bearer Tokens
Pydantic models for validation
Auto-generated API documentation (Swagger UI)
Clean, modular project structure
๐ฆ Tech Stack
FastAPI
SQLAlchemy ORM
Pydantic
Argon2 (argon2-cffi)
SQLite
Python-Jose (JWT)
Uvicorn
โ๏ธ Installation & Setup
1๏ธโฃ Clone the repository
git clone https://github.com/nahidulhasan/fastapi-task-manager.git
cd fastapi-task-manager
2๏ธโฃ Create & activate virtual environment
python3 -m venv .venv
source .venv/bin/activate
3๏ธโฃ Install dependencies
pip install -r requirements.txt
4๏ธโฃ Run the API
uvicorn app.main:app --reload
API will be available at: http://127.0.0.1:8000
Interactive API docs (Swagger UI): http://127.0.0.1:8000/docs
๐ Authentication Flow
1๏ธโฃ Register a user
POST /auth/register
Body:
{ "email": "test@example.com", "password": "123456" }
2๏ธโฃ Login to get JWT token
POST /auth/token
Form-data:
username=test@example.com password=123456
Response:
{
"access_token": "<JWT_TOKEN>",
"token_type": "bearer"
}
Use this token for all protected routes:
Authorization: Bearer
๐ Task Endpoints
โ Create a Task
POST /tasks/ Requires authentication.
Example:
{
"title": "Buy groceries",
"description": "Milk, eggs, bread",
"priority": "HIGH",
"due_date": "2025-01-31T10:00:00" }
๐ Get All Tasks
GET /tasks/
๐ Get Single Task
GET /tasks/{task_id}
โ๏ธ Update Task
PUT /tasks/{task_id}
Example:
{
"title": "Updated title",
"completed": true
}
๐ Delete Task
DELETE
/tasks/{task_id}
๐ Database
SQLite is used by default:
app/tasks.db
โค๏ธ Contributing
Pull requests are welcome! Feel free to open issues or suggest new features.
๐ License
MIT License.