FastAPI Todo App
A simple Todo REST API built with FastAPI and SQLite.
Features
- Create, read, update, and delete Todo items
- SQLite database with SQLAlchemy ORM
- Database migrations with Alembic
- API documentation with Swagger UI
- Health check endpoint
Project Structure
├── app
│ ├── api # API routes
│ │ └── routes
│ │ ├── health.py # Health check endpoint
│ │ └── todos.py # Todo CRUD operations
│ ├── core # Core application code
│ │ └── config.py # Application settings
│ ├── db # Database related code
│ │ └── session.py # Database session setup
│ ├── models # SQLAlchemy models
│ │ └── todo.py # Todo model
│ └── schemas # Pydantic schemas/models
│ └── todo.py # Todo schemas for request/response
├── migrations # Alembic migrations
│ ├── versions
│ │ └── e9bac9a7a1e3_create_todos_table.py # Initial migration
│ ├── env.py
│ └── script.py.mako
├── alembic.ini # Alembic configuration
├── main.py # Application entry point
└── requirements.txt # Python dependencies
Installation
- Clone the repository
- Install the dependencies:
pip install -r requirements.txt
Running the Application
Start the FastAPI application:
uvicorn main:app --reload
The API will be available at http://localhost:8000.
API Documentation
Once the application is running, you can access the API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
Health Check
GET /health
- Check API health
Todo Operations
GET /api/todos
- List all todosPOST /api/todos
- Create a new todoGET /api/todos/{todo_id}
- Get a specific todoPUT /api/todos/{todo_id}
- Update a todoDELETE /api/todos/{todo_id}
- Delete a todo
Example Payloads
Create Todo
{
"title": "Buy groceries",
"description": "Milk, bread, eggs",
"completed": false
}
Update Todo
{
"title": "Buy groceries",
"description": "Milk, bread, eggs, cheese",
"completed": true
}
Database
The application uses SQLite as its database, which is stored at /app/storage/db/db.sqlite
. Migrations are managed with Alembic.
Description
Languages
Python
94.6%
Mako
5.4%