
- Setup project structure - Create database models for todos - Configure SQLite database connection - Add Alembic migration scripts - Implement CRUD API endpoints for todos - Add health check endpoint - Update README with documentation generated with BackendIM... (backend.im)
Simple Todo App
A simple REST API for managing todos built with FastAPI and SQLite.
Features
- Create, read, update, and delete todos
- SQLite database with SQLAlchemy ORM
- Database migrations with Alembic
- Health check endpoint
- API documentation (Swagger UI and ReDoc)
Project Structure
simpletodoapp/
├── alembic/ # Database migration scripts
│ ├── versions/ # Migration version files
│ ├── env.py # Alembic environment configuration
│ └── script.py.mako # Migration script template
├── app/ # Application package
│ ├── __init__.py # Package initializer
│ ├── database.py # Database session and engine setup
│ ├── models.py # SQLAlchemy ORM models
│ └── schemas.py # Pydantic schemas for request/response validation
├── alembic.ini # Alembic configuration file
├── main.py # Application entry point
├── README.md # Project documentation
└── requirements.txt # Project dependencies
Installation
- Clone the repository:
git clone <repository-url>
cd simpletodoapp
- Install dependencies:
pip install -r requirements.txt
- Run the application:
uvicorn main:app --reload
The application will be available at http://localhost:8000.
API Documentation
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
Health Check
GET /health
Returns the health status of the application.
Todos
GET /todos
Returns a list of all todos.
GET /todos/{todo_id}
Returns a specific todo by ID.
POST /todos
Creates a new todo.
Request Body:
{
"title": "Buy groceries",
"description": "Milk, eggs, bread",
"completed": false
}
PUT /todos/{todo_id}
Updates an existing todo.
Request Body:
{
"title": "Buy groceries",
"description": "Milk, eggs, bread, cheese",
"completed": true
}
DELETE /todos/{todo_id}
Deletes a todo by ID.
Description
Languages
Python
94.3%
Mako
5.7%