Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

📌 Task Manager API

A REST API where users can manage their daily tasks — built with FastAPI, PostgreSQL, and SQLAlchemy.

This is a more realistic follow-up to the Student API project, adding priority levels, due dates, and completion status.


🛠️ Tech Stack

  • Python 3.10+
  • FastAPI — web framework
  • PostgreSQL — database
  • SQLAlchemy — ORM
  • Pydantic — data validation
  • Swagger UI — interactive API docs (built into FastAPI)
  • Postman — for manual API testing

📂 Project Structure

Task-Manager-API/
│
├── app/
│   ├── __init__.py
│   ├── main.py          # FastAPI app & route definitions
│   ├── database.py       # SQLAlchemy engine/session setup
│   ├── models.py         # ORM models (Task table)
│   ├── schemas.py        # Pydantic request/response schemas
│   ├── crud.py            # DB access logic (Create/Read/Update/Delete)
│   └── config.py          # App settings & environment variables
│
├── .gitignore
├── requirements.txt
└── README.md

🗄️ Task Model

Field Type Notes
id UUID Primary key, auto-generated
title string Required
description string Optional
completed boolean Defaults to false
priority enum: Low, Medium, High Defaults to Medium
due_date date (YYYY-MM-DD) Optional
created_at datetime Auto-set on creation

Example request body:

{
  "title": "Complete FastAPI Course",
  "description": "Finish FastAPI CRUD section",
  "completed": false,
  "priority": "High",
  "due_date": "2026-08-10"
}

📡 API Endpoints

Method Endpoint Description
POST /tasks Create a new task
GET /tasks Get all tasks (supports filters + pagination)
GET /tasks/{id} Get a single task by ID
PUT /tasks/{id} Update an existing task (partial updates OK)
DELETE /tasks/{id} Delete a task

Query parameters for GET /tasks:

  • skip (int, default 0) — pagination offset
  • limit (int, default 100, max 500) — page size
  • completed (bool) — filter by completion status
  • priority (Low / Medium / High) — filter by priority

🚀 Getting Started

1. Clone & set up a virtual environment

git clone <your-repo-url>
cd Task-Manager-API
python -m venv venv
source venv/bin/activate      # Windows: venv\Scripts\activate

2. Install dependencies

pip install -r requirements.txt

3. Configure your database

Create a PostgreSQL database (e.g. task_manager_db), then create a .env file in the project root:

DB_USER=postgres
DB_PASSWORD=your_password
DB_HOST=localhost
DB_PORT=5432
DB_NAME=task_manager_db

Or set DATABASE_URL directly to override everything:

DATABASE_URL=postgresql://postgres:your_password@localhost:5432/task_manager_db

4. Run the server

uvicorn app.main:app --reload

Tables are created automatically on startup (via Base.metadata.create_all).

5. Explore the API


⭐ What's new vs. the Student API

  • Priority field (Low / Medium / High)
  • Due Date tracking
  • Completed status flag
  • ✅ Filtering & pagination on GET /tasks

🔮 Possible Next Steps (v2 ideas)

  • User authentication (JWT) so tasks belong to specific users
  • Sorting by due_date / priority
  • Alembic migrations instead of create_all
  • Unit tests with pytest + a test database
  • Dockerfile + docker-compose.yml for one-command setup

About

Task Management REST API built with FastAPI, PostgreSQL, SQLAlchemy, and Pydantic.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages