Skip to content

Repository files navigation

fastapi-task-api

A REST API for managing tasks, built with FastAPI and PostgreSQL. Handles auth with JWT, full CRUD on tasks, and runs cleanly in Docker. Nothing fancy, just solid.

Quick Start (Docker Compose)

cp .env.example .env
docker compose up --build

API is at http://localhost:8000. Docs at http://localhost:8000/docs.

API Endpoints

Method Path Auth Description
POST /api/v1/auth/register No Create account
POST /api/v1/auth/login No Get JWT token
GET /api/v1/tasks Yes List your tasks (paginated)
POST /api/v1/tasks Yes Create a task
GET /api/v1/tasks/{id} Yes Get single task
PUT /api/v1/tasks/{id} Yes Update task
DELETE /api/v1/tasks/{id} Yes Delete task
GET /health No Health check

Query params on GET /tasks: skip, limit, status (todo/in_progress/done).

Local Development

python -m venv venv
source venv/bin/activate  # windows: venv\Scripts\activate

pip install -r requirements.txt

cp .env.example .env
# edit .env with your local postgres connection

Run migrations (once you have postgres running):

alembic upgrade head

Start the server:

uvicorn app.main:app --reload

The lifespan handler auto-creates tables if they don't exist — handy for quick local hacks, but use alembic for anything real.

Running Tests

Tests use SQLite in memory so you don't need postgres running.

pytest -v

Notes

  • Tokens expire after 30 minutes (configurable via ACCESS_TOKEN_EXPIRE_MINUTES)
  • Users can only see and modify their own tasks
  • SECRET_KEY in .env.example is a placeholder — generate a proper one for prod: openssl rand -hex 32 # might need to tweak this for prod

About

REST API built with FastAPI, PostgreSQL, and Docker

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages