Skip to content

LeonardZG/fastapi-task-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📌 FastAPI Task Management API

A simple, clean RESTful backend API for managing tasks. Built for learning modern backend development with FastAPI, SQLAlchemy, and automated tests.


🚀 Features

  • Create, read, update, delete tasks (CRUD)
  • Persistent storage with SQLite
  • Strong input validation with Pydantic
  • Task status enforced via Enum (open, done)
  • Automatic API documentation (Swagger)
  • Fully tested with pytest (isolated in-memory DB)

🧱 Tech Stack

  • Python 3.10+
  • FastAPI
  • Uvicorn
  • SQLAlchemy (ORM)
  • SQLite
  • Pydantic v2
  • pytest + httpx

📁 Project Structure

app/
 ├─ api/        # API routes
 ├─ db/         # database, sessions, dependencies
 ├─ models/     # SQLAlchemy models
 ├─ schemas/    # Pydantic schemas
 └─ main.py     # FastAPI application entry point
tests/
 ├─ conftest.py # test DB + dependency overrides
 └─ test_tasks.py

⚙️ Setup

1️⃣ Create virtual environment

python3 -m venv .venv
source .venv/bin/activate

2️⃣ Install dependencies

pip install -r requirements.txt

(or install manually if no requirements.txt yet)


▶️ Run the application

uvicorn app.main:app --reload

Open in browser:


🔁 Example API Usage

Create a task

POST /tasks
{
  "title": "Learn FastAPI"
}

Update task status

PUT /tasks/1
{
  "status": "done"
}

🧪 Run Tests

pytest -q

✔ Uses an in-memory SQLite database ✔ Tests do not affect the production database


🧠 Learning Goals

This project demonstrates:

  • REST API design
  • ORM-based persistence
  • Dependency Injection
  • Automated testing
  • Clean backend architecture

🔮 Possible Extensions

  • Pagination & filtering
  • Authentication (JWT)
  • Alembic migrations
  • Docker setup
  • User management

📄 License

MIT


About

Learning project: FastAPI-based REST API using SQLAlchemy ORM, SQLite, and pytest.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages