Simple Todo App
A simple REST API for managing todo items, built with FastAPI and SQLite.
Features
- Create, read, update, and delete todo items
- SQLite database with SQLAlchemy ORM
- Alembic for database migrations
- Health check endpoint
- API documentation
Requirements
- Python 3.8+
- FastAPI
- SQLAlchemy
- Alembic
- Uvicorn
- SQLite
Setup
- Clone the repository:
git clone https://github.com/yourusername/simpletodoapp.git
cd simpletodoapp
- Install dependencies:
pip install -r requirements.txt
- Run database migrations:
alembic upgrade head
- Start the server:
uvicorn main:app --reload
The API will be available at http://localhost:8000
API Documentation
API documentation is available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
Root
GET /
- Returns basic app information
Health Check
GET /health
- Returns the health status of the API
Todo Operations
GET /api/v1/todos
- Get all todosPOST /api/v1/todos
- Create a new todoGET /api/v1/todos/{todo_id}
- Get a specific todoPUT /api/v1/todos/{todo_id}
- Update a todoDELETE /api/v1/todos/{todo_id}
- Delete a todo
Example Usage
Create a Todo
curl -X 'POST' \
'http://localhost:8000/api/v1/todos/' \
-H 'accept: application/json' \
-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/v1/todos/' \
-H 'accept: application/json'
Mark Todo as Completed
curl -X 'PUT' \
'http://localhost:8000/api/v1/todos/1' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"completed": true
}'
Project Structure
simpletodoapp/
├── app/
│ ├── api/
│ │ └── api_v1/
│ │ ├── endpoints/
│ │ │ └── todos.py
│ │ └── api.py
│ ├── core/
│ │ └── config.py
│ ├── crud/
│ │ ├── base.py
│ │ └── todo.py
│ ├── db/
│ │ ├── base.py
│ │ ├── base_class.py
│ │ └── session.py
│ ├── models/
│ │ └── todo.py
│ └── schemas/
│ └── todo.py
├── migrations/
│ └── versions/
│ └── 001_create_todos_table.py
├── storage/
│ └── db/
│ └── db.sqlite
├── alembic.ini
├── main.py
└── requirements.txt
Description
Languages
Python
96.4%
Mako
3.6%