
- Created CRUD operations for todos - Added database models and SQLAlchemy integration - Set up Alembic for database migrations - Added health endpoint - Updated README with installation and usage instructions generated with BackendIM... (backend.im)
Simple Todo Application
A simple Todo API built with FastAPI and SQLAlchemy using SQLite as the database.
Features
- Todo CRUD operations (Create, Read, Update, Delete)
- Health endpoint to check application status
- Database migrations with Alembic
- SQLite database storage
Requirements
- Python 3.8+
- FastAPI
- SQLAlchemy
- Alembic
- Uvicorn
Installation
- Clone the repository
git clone https://github.com/yourusername/simpletodoapplication.git
cd simpletodoapplication
- Install dependencies
pip install -r requirements.txt
- Run migrations
alembic upgrade head
Running the Application
- Start the FastAPI server
uvicorn main:app --reload
- The API will be available at http://localhost:8000
API Documentation
Once the server is running, you can access the interactive API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
Health Check
GET /health
- Check application and database health
Todo Operations
GET /api/todos
- Get all todosGET /api/todos/{id}
- Get a specific todo by IDPOST /api/todos
- Create a new todoPUT /api/todos/{id}
- Update an existing todoDELETE /api/todos/{id}
- Delete a todo
Data Model
Todo
id
: integer (primary key)title
: string (required)description
: string (optional)completed
: boolean (default: false)created_at
: datetimeupdated_at
: datetime
Example Usage
Create a Todo
curl -X 'POST' \
'http://localhost:8000/api/todos/' \
-H 'Content-Type: application/json' \
-d '{
"title": "Buy groceries",
"description": "Milk, eggs, bread",
"completed": false
}'
Get All Todos
curl -X 'GET' 'http://localhost:8000/api/todos/'
Update a Todo
curl -X 'PUT' \
'http://localhost:8000/api/todos/1' \
-H 'Content-Type: application/json' \
-d '{
"completed": true
}'
Delete a Todo
curl -X 'DELETE' 'http://localhost:8000/api/todos/1'
Description
Languages
Python
94.5%
Mako
5.5%