
- Set up project structure and FastAPI application - Create database models with SQLAlchemy - Set up Alembic for database migrations - Create API endpoints for todo CRUD operations - Add health check endpoint - Add unit tests for API endpoints - Configure Ruff for linting and formatting
Simple Todo App
This is a FastAPI-based Todo application with SQLite as the database backend. The application provides a REST API for managing todo items.
Features
- Create, read, update, and delete todo items
- SQLite database for data persistence
- Alembic for database migrations
- Health check endpoint
- API documentation with Swagger UI and ReDoc
Project Structure
├── alembic.ini # Alembic configuration
├── app # Application package
│ ├── api # API routes
│ │ ├── api.py # Main API router
│ │ └── endpoints # API endpoints
│ │ └── todos.py # Todo endpoints
│ ├── core # Core functionality
│ │ └── config.py # Application configuration
│ ├── db # Database related modules
│ │ └── session.py # Database session management
│ ├── models # SQLAlchemy models
│ │ └── todo.py # Todo model
│ └── schemas # Pydantic schemas
│ └── todo.py # Todo schemas
├── main.py # Application entry point
├── migrations # Alembic migrations
│ ├── env.py # Alembic environment
│ ├── README # Migrations README
│ ├── script.py.mako # Script template
│ └── versions # Migration versions
│ └── 001_create_todos_table.py # Initial migration
├── requirements.txt # Project dependencies
└── tests # Tests
└── test_api.py # API tests
Getting Started
Prerequisites
- Python 3.8 or higher
Installation
-
Clone the repository
-
Install dependencies:
pip install -r requirements.txt
-
Run database migrations:
alembic upgrade head
-
Start the application:
uvicorn main:app --reload
-
Access the API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
Method | Endpoint | Description |
---|---|---|
GET | /health | Health check endpoint |
GET | /todos | Get all todo items |
GET | /todos/{id} | Get a specific todo item |
POST | /todos | Create a new todo item |
PUT | /todos/{id} | Update an existing todo item |
DELETE | /todos/{id} | Delete a todo item |
Testing
Run tests with pytest:
pytest
License
This project is licensed under the MIT License.
Description
Languages
Python
96.6%
Mako
3.4%