
- Create project structure and configuration files - Set up database models and schemas for ToDo items - Implement CRUD operations for ToDo management - Create API endpoints for ToDo operations - Add health check endpoint - Set up Alembic for database migrations - Add comprehensive README documentation
ToDo Application API
A simple ToDo Application API built with FastAPI and SQLite.
Features
- Create, read, update, and delete ToDo items
- Filter ToDo items by completion status
- Pagination support
- Health check endpoint
- SQLite database for data persistence
- Alembic for database migrations
Project Structure
.
├── alembic.ini
├── app
│ ├── api
│ │ ├── routes
│ │ │ ├── health.py
│ │ │ └── todo.py
│ ├── core
│ ├── crud
│ │ └── todo.py
│ ├── db
│ │ ├── base.py
│ │ └── session.py
│ ├── models
│ │ └── todo.py
│ └── schemas
│ └── todo.py
├── main.py
├── migrations
│ ├── env.py
│ ├── script.py.mako
│ └── versions
│ └── 001_create_todos_table.py
└── requirements.txt
Installation
-
Clone the repository
-
Install dependencies:
pip install -r requirements.txt
- Run database migrations:
alembic upgrade head
Running the application
Start the application:
uvicorn main:app --reload
The API will be available at http://localhost:8000. You can access the API documentation at http://localhost:8000/docs.
API Endpoints
ToDo Operations
-
GET /api/todos
: List all todos- Query Parameters:
skip
: Number of items to skip (default: 0)limit
: Maximum number of items to return (default: 100)completed
: Filter by completion status (Boolean, optional)
- Query Parameters:
-
POST /api/todos
: Create a new todo- Request Body:
{ "title": "string", "description": "string", "completed": false }
- Request Body:
-
GET /api/todos/{todo_id}
: Get a specific todo -
PUT /api/todos/{todo_id}
: Update a todo- Request Body:
{ "title": "string", "description": "string", "completed": true }
- Request Body:
-
DELETE /api/todos/{todo_id}
: Delete a todo
Health Check
GET /health
: Check application health- Response:
{ "status": "OK", "database_connected": true }
- Response:
Development
Database Migrations
Create a new migration:
alembic revision -m "description"
Apply migrations:
alembic upgrade head
Rollback migration:
alembic downgrade -1
Description
Languages
Python
95.6%
Mako
4.4%