
- Set up project structure with FastAPI, SQLAlchemy, and Alembic - Create Todo model and database operations - Implement CRUD API endpoints for Todo items - Configure database migrations - Add comprehensive documentation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
FastAPI Todo Backend Service
This is a simple Todo API backend service built with FastAPI, SQLAlchemy, and SQLite.
Features
- CRUD operations for Todo items
- API documentation with Swagger UI and ReDoc
- Database migrations with Alembic
- SQLite database
Project Structure
.
├── alembic/ # Database migrations
├── app/
│ ├── api/ # API endpoints
│ │ └── v1/ # API version 1
│ ├── core/ # Core application configurations
│ ├── db/ # Database connection and CRUD operations
│ ├── models/ # SQLAlchemy models
│ └── schemas/ # Pydantic schemas for request/response
├── main.py # Application entry point
├── requirements.txt # Python dependencies
└── alembic.ini # Alembic configuration
Getting Started
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
- Run database migrations:
alembic upgrade head
- Start the application:
uvicorn main:app --reload
API Documentation
Once the application is running, you can access:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
- GET
/api/v1/todos/
: List all todo items - POST
/api/v1/todos/
: Create a new todo item - GET
/api/v1/todos/{todo_id}
: Get a specific todo item - PUT
/api/v1/todos/{todo_id}
: Update a todo item - DELETE
/api/v1/todos/{todo_id}
: Delete a todo item
Example
Create a new todo
curl -X 'POST' \
'http://localhost:8000/api/v1/todos/' \
-H 'Content-Type: application/json' \
-d '{
"title": "Buy groceries",
"description": "Milk, bread, eggs",
"completed": false
}'
List all todos
curl -X 'GET' \
'http://localhost:8000/api/v1/todos/' \
-H 'accept: application/json'
Description
Languages
Python
94.9%
Mako
5.1%