Simple Todo Application
A simple Todo API built with FastAPI and SQLite.
Features
- Create, read, update, and delete todo items
- Filter todos by completion status
- Database migrations using Alembic
- Health check endpoint
- API documentation
Requirements
- Python 3.8+
- FastAPI
- SQLAlchemy
- Alembic
- Uvicorn
- SQLite
Installation
-
Clone this repository:
git clone https://github.com/yourusername/simpletodoapplication.git cd simpletodoapplication
-
Install the dependencies:
pip install -r requirements.txt
-
Run the database migrations:
alembic upgrade head
Running the Application
Start the server with:
uvicorn main:app --reload
The API will be available at http://localhost:8000.
API Documentation
Once the application is running, you can access:
- Swagger UI documentation: http://localhost:8000/docs
- ReDoc documentation: http://localhost:8000/redoc
API Endpoints
Health Check
GET /health
- Check the health of the API
Todo Operations
GET /api/v1/todos
- List all todos (optional query parameters: skip, limit, completed)POST /api/v1/todos
- Create a new todoGET /api/v1/todos/{todo_id}
- Get a specific todoPATCH /api/v1/todos/{todo_id}
- Update a todoDELETE /api/v1/todos/{todo_id}
- Delete a todo
Project Structure
simpletodoapplication/
├── alembic.ini
├── app/
│ ├── api/
│ │ ├── endpoints/
│ │ │ ├── health.py
│ │ │ └── todos.py
│ │ └── routers.py
│ ├── core/
│ │ └── config.py
│ ├── db/
│ │ └── session.py
│ ├── models/
│ │ └── todo.py
│ └── schemas/
│ └── todo.py
├── main.py
├── migrations/
│ ├── env.py
│ ├── script.py.mako
│ └── versions/
│ └── 01_initial_migration.py
└── requirements.txt
Data Models
Todo
id
: Integer (Primary Key)title
: String (Required)description
: String (Optional)completed
: Boolean (Default: False)created_at
: DateTimeupdated_at
: DateTime
Description
Languages
Python
95.2%
Mako
4.8%