Skip to content

rhoda-lee/Todo-App

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Todo API

Python FastAPI PostgreSQL SQLAlchemy

A scalable RESTful API built with FastAPI and PostgreSQL. This project demonstrates backend architecture using standard CRUD operations, database migrations and strict data validation.

Key Features

  • Full CRUD Operations: Create, Read (All & By ID), Update and Delete tasks.
  • Smart Updates: Implementation of PATCH method for partial updates (specifically for toggling the is_complete status).
  • Due Dates: Implementation of datetime sorting to prioritize tasks.
  • Subtasks: Relational mapping to allow nested tasks (One-to-Many).
  • Data Validation: Strict schema validation using Pydantic V2.
  • Database Persistence: robust data storage using PostgreSQL.
  • ORM Layer: Clean database interaction using SQLAlchemy.
  • Migrations: Database schema version control using Alembic.
  • Modular Architecture: Codebase organized into distinct layers (Routers, CRUD, Models, Schemas) for maintainability.

Tech Stack

  • Framework: FastAPI
  • Database: PostgreSQL
  • ORM: SQLAlchemy
  • Migrations: Alembic
  • Serialization/Validation: Pydantic
  • Server: Uvicorn (ASGI)

Project Structure

This project follows a modular pattern to ensure scalability and separation of concerns:

├── alembic/                # Database migration scripts
├── crud/
│   └── todo_crud.py        # Database interaction logic (Create, Read, Update, Delete)
├── database/
│   └── connections.py      # Database session and connection setup
├── models/
│   └── todo_model.py       # SQLAlchemy database models
├── schema/
│   └── todo_schema.py      # Pydantic models for request/response validation
├── routers/
│   └── todo_router.py      # API Endpoint definitions
├── main.py                 # Application entry point
├── .env                    # Environment variables (Database credentials)
└── alembic.ini             # Alembic configuration

Getting Started

Follow these steps to set up the project locally.

Prerequisites

  • Python 3.10+
  • PostgreSQL installed and running

1. Clone the repository

git clone https://github.com/rhoda-lee/Todo-App.git
cd your-repo-name

2. Create a Virtual Environment

python -m venv venv
# Windows
venv\Scripts\activate
# Mac/Linux
source venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

4. Configure Environment Variables

Create a .env file in the root directory and add your PostgreSQL credentials:

DATABASE_URL=postgresql://username:password@localhost:5432/your_database_name

Note: Make sure to create the database in PostgreSQL before running migrations.

5. Run Database Migrations

Use Alembic to create the tables in your database:

alembic upgrade head

6. Run the Server

uvicorn main:app --reload

The API will be available at http://127.0.0.1:8000.

API Documentation

FastAPI provides automatic, interactive documentation. Once the server is running, visit:

Endpoints Overview

Method Endpoint Description
GET /todos/ Retrieve all todo items
POST /todos/ Create a new todo item
GET /todos/{id} Retrieve a specific item by ID
PATCH /todos/{id} Update an item (e.g., mark as done)
DELETE /todos/{id} Delete an item

Future Improvements

This project is currently in active development. Upcoming features include:

  • Tagging System: Many-to-Many relationships for task categorization.

Author

Rhoda Oduro-Nyarko

Built with ❤️ using Python and FastAPI.

About

A RESTful API built with FastAPI and PostgreSQL. This project demonstrates backend architecture using standard CRUD operations, database migrations and strict data validation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors