
- Add CRUD operations for todos (create, read, update, delete) - Implement SQLAlchemy models and schemas - Set up Alembic for database migrations - Add health endpoint and CORS configuration - Include comprehensive API documentation - Structure project with proper separation of concerns
1.7 KiB
1.7 KiB
Todo App API
A simple Todo application API built with FastAPI and SQLite.
Features
- CRUD operations for todos (Create, Read, Update, Delete)
- SQLite database with SQLAlchemy ORM
- Database migrations with Alembic
- CORS enabled for all origins
- Health check endpoint
- Interactive API documentation
Installation
- Install dependencies:
pip install -r requirements.txt
- Run database migrations:
alembic upgrade head
- Start the application:
uvicorn main:app --reload
The API will be available at http://localhost:8000
API Endpoints
Base
GET /
- API information and linksGET /health
- Health check
Todos
POST /todos/
- Create a new todoGET /todos/
- Get all todos (with pagination)GET /todos/{todo_id}
- Get a specific todoPUT /todos/{todo_id}
- Update a todoDELETE /todos/{todo_id}
- Delete a todo
Documentation
- Interactive API docs:
http://localhost:8000/docs
- ReDoc documentation:
http://localhost:8000/redoc
- OpenAPI JSON:
http://localhost:8000/openapi.json
Database
The application uses SQLite with the database file stored at /app/storage/db/db.sqlite
.
Project Structure
├── main.py # FastAPI application entry point
├── requirements.txt # Python dependencies
├── alembic.ini # Alembic configuration
├── alembic/ # Database migrations
├── app/
│ ├── db/ # Database configuration
│ ├── models/ # SQLAlchemy models
│ ├── schemas/ # Pydantic schemas
│ └── routes/ # API routes
└── storage/ # Application storage directory