
- Updated app/db/base.py to properly export Base class - Fixed error when running Alembic migrations due to missing Base import - Added proper imports for models
Todo API
A simple Todo application API built with FastAPI and SQLite.
Features
- RESTful API using FastAPI
- SQLite database with SQLAlchemy ORM
- Database migrations using Alembic
- CRUD operations for Todo items
- Health check endpoint
- OpenAPI documentation
Project Structure
/
├── app/
│ ├── api/
│ │ ├── v1/
│ │ │ ├── health.py
│ │ │ └── todos.py
│ │ ├── deps.py
│ │ └── routers.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/
│ │ └── 01_initial_todo_table.py
│ ├── env.py
│ └── script.py.mako
├── alembic.ini
├── main.py
└── requirements.txt
Installation
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
Database Setup
The application uses SQLite as its database. The database will be created at /app/storage/db/db.sqlite
when the application starts.
To run the migrations:
alembic upgrade head
Running the Application
To run the application locally:
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
Health Check
GET /api/v1/health
- Check API health
Todo Endpoints
GET /api/v1/todos
- List all todosPOST /api/v1/todos
- Create a new todoGET /api/v1/todos/{id}
- Get a specific todoPUT /api/v1/todos/{id}
- Update a todoDELETE /api/v1/todos/{id}
- Delete a todo
Query Parameters
List todos
skip
- Number of records to skip (default: 0)limit
- Maximum number of records to return (default: 100)completed
- Filter by completion status (optional, boolean)
Description
Languages
Python
96.3%
Mako
3.7%