A simple FastAPI + SQLModel project built to practice REST API design, authentication, and database handling.
This project uses SQLite as the database for simplicity.
✅ JWT-based Authentication
✅ User Signup & Login
✅ Get Current User (/users/me
)
✅ CRUD for Tasks (per user)
✅ Admin-only User Management
Method | Endpoint | Description |
---|---|---|
POST | /auth/signup |
Create a new user account |
POST | /auth/login |
Login and receive JWT token |
Method | Endpoint | Description |
---|---|---|
GET | /users/ |
Get all users (admin only) |
GET | /users/{user_id} |
Get user by ID (admin only) |
DELETE | /users/{user_id} |
Delete user (admin only) |
GET | /users/me |
Get current logged-in user info |
Method | Endpoint | Description |
---|---|---|
GET | /tasks/ |
Get all tasks for the authenticated user |
GET | /tasks/{task_id} |
Get a specific task (must belong to user) |
POST | /tasks/ |
Create a new task for the authenticated user |
PATCH | /tasks/{task_id} |
Update a specific task (must belong to user) |
DELETE | /tasks/{task_id} |
Delete a specific task (must belong to user) |
DELETE | /tasks/ |
Delete all tasks of the authenticated user |
Clone the repository:
git clone https://github.com/abdall05/QuickTodoAPI.git
cd QuickTodoAPI
Install dependencies:
pip install -r requirements.txt
Run the app:
uvicorn app.main:app --reload
Open in your browser: http://127.0.0.1:8000/docs (Swagger UI)
Here you can interactively explore all endpoints, see request and response schemas, try example requests, and check
model structures.
{ "username": "john123", "email": "john@example.com", "name": "John Doe", "password": "strongpassword", "password_confirm": "strongpassword" }
POST /auth/login
Content-Type: application/x-www-form-urlencoded
Fields:
- username: Your username
- password: Your password
Example using curl:
curl -X POST "http://127.0.0.1:8000/auth/login"
-H "Content-Type: application/x-www-form-urlencoded"
-d "username=john123&password=strongpassword"
Example Response:
{ "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwicm9sZSI6InVzZXIiLCJleHAiOjE3NTg1MjcyMDV9.4D0TNpjUxRSulNCogLYyuLfKLj6zPFXnahr3_JkJ47M", "token_type": "Bearer" }
Use the returned access_token from login in the Authorization header:
Authorization: Bearer
POST /tasks/
JSON Payload:
{ "title": "Buy groceries", "description": "Milk, Bread, Eggs" }
Example Response:
{ "title": "Buy groceries", "description": "Milk, Bread, Eggs", "id": 3, "completed": false, "created_at": "2025-09-22T07:15:47.040381" }
PATCH /tasks/{task_id}
JSON Payload:
{ "completed": true }
Example Response:
{ "title": "Buy groceries", "description": "Milk, Bread, Eggs", "id": 3, "completed": true, "created_at": "2025-09-22T07:15:47.040381" }
GET /tasks/
Header: Authorization: Bearer
Example Response:
[ { "title": "CP", "description": "30 minutes", "id": 2, "completed": false, "created_at": "2025-09-22T07:02:13.563533" }, { "title": "Buy groceries", "description": "Milk, Bread, Eggs", "id": 3, "completed": false, "created_at": "2025-09-22T07:15:47.040381" } ]
DELETE /tasks/{task_id}
Header: Authorization: Bearer
Example Response: 204 No Content
DELETE /tasks/
Header: Authorization: Bearer
Example Response: 204 No Content
GET /users/me
Header: Authorization: Bearer
Example Response: { "username": "ali99", "name": "ali", "id": 1, "role": "user" }
users
Column | Type | Notes |
---|---|---|
id | int (PK) | Auto-increment |
username | str | Unique, required |
name | str | Required |
password_hash | str | Stored as hash |
role | enum | USER or ADMIN, default = USER |
tasks
Column | Type | Notes |
---|---|---|
id | int (PK) | Auto-increment |
title | str | Required |
description | str | Optional |
completed | bool | Default = False |
created_at | datetime | Default = UTC now |
user_id | int (FK) | References users.id, CASCADE on delete |
Relationships
User.tasks
→ list of tasks for that user (back_populates="user"
)Task.user
→ the owner user of the task (back_populates="tasks"
)
-
Add email-based password recovery (forgot password) functionality.
Users can request a password reset link via email to securely update their password. -
Implement email verification upon signup to ensure valid user accounts.
-
Add pagination and filtering for tasks and users endpoints.
MIT License - free to use for learning and personal projects.