
- Set up project structure and dependencies - Implement Todo model with SQLAlchemy - Configure SQLite database connection - Create Alembic migration scripts - Implement RESTful API endpoints for CRUD operations - Add health check endpoint - Update README with documentation generated with BackendIM... (backend.im)
Simple Todo Application
A simple Todo application API built with FastAPI and SQLite.
Features
- Create, read, update, and delete todo items
- SQLite database with SQLAlchemy ORM
- Alembic migrations
- Health check endpoint
Project Structure
├── alembic/ # Database migrations
├── app/ # Application package
│ ├── api/ # API endpoints
│ ├── core/ # Core configuration
│ ├── crud/ # CRUD operations
│ ├── db/ # Database setup
│ ├── models/ # SQLAlchemy models
│ └── schemas/ # Pydantic schemas
├── alembic.ini # Alembic configuration
├── main.py # FastAPI application
└── requirements.txt # Python dependencies
Installation
- Clone the repository:
git clone https://github.com/yourusername/simpletodoapplication.git
cd simpletodoapplication
- Install dependencies:
pip install -r requirements.txt
- Run database migrations:
alembic upgrade head
Usage
Start the application:
uvicorn main:app --reload
The application will be available at http://localhost:8000.
API documentation is available at:
- http://localhost:8000/docs (Swagger UI)
- http://localhost:8000/redoc (ReDoc)
API Endpoints
Todo Endpoints
GET /todos
- List all todosPOST /todos
- Create a new todoGET /todos/{todo_id}
- Get a specific todoPUT /todos/{todo_id}
- Update a todoDELETE /todos/{todo_id}
- Delete a todo
Health Check
GET /health
- Check API health
Example Requests
Create a Todo
curl -X 'POST' \
'http://localhost:8000/todos/' \
-H 'Content-Type: application/json' \
-d '{
"title": "Buy groceries",
"description": "Milk, eggs, bread",
"completed": false
}'
List All Todos
curl -X 'GET' 'http://localhost:8000/todos/'
Update a Todo
curl -X 'PUT' \
'http://localhost:8000/todos/1' \
-H 'Content-Type: application/json' \
-d '{
"title": "Buy groceries",
"description": "Milk, eggs, bread, cheese",
"completed": true
}'
Description
Languages
Python
95.4%
Mako
4.6%