
- Implement Todo database model with SQLAlchemy - Set up Alembic for database migrations - Create CRUD operations for Todo items - Implement RESTful API endpoints - Add health check endpoint - Include comprehensive README with usage instructions
2.1 KiB
2.1 KiB
Simple Todo App
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 for database versioning
- API documentation with Swagger UI
- Health check endpoint
Requirements
- Python 3.7+
- FastAPI
- SQLAlchemy
- Alembic
- Uvicorn
- Ruff (for linting)
Installation
- Clone the repository:
git clone https://github.com/yourusername/simpletodoapp.git
cd simpletodoapp
- Install dependencies:
pip install -r requirements.txt
- Run migrations:
alembic upgrade head
Running the Application
Start the application with:
uvicorn main:app --reload
The API will be available at http://localhost:8000
API Documentation
Once the application is running, you can access the interactive API documentation at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
Todo Endpoints
GET /api/todos
- Get all todosPOST /api/todos
- Create a new todoGET /api/todos/{todo_id}
- Get a specific todoPATCH /api/todos/{todo_id}
- Update a todoDELETE /api/todos/{todo_id}
- Delete a todo
Health Check
GET /health
- Check API health status
Database
The application uses SQLite as the database with SQLAlchemy as the ORM. The database file is stored at /app/storage/db/db.sqlite
.
Development
Linting
ruff check .
ruff check --fix .
Running Tests
# No tests implemented yet
Project Structure
simpletodoapp/
├── app/
│ ├── crud/ # CRUD operations
│ ├── models/ # SQLAlchemy models
│ ├── routers/ # API endpoints
│ ├── schemas/ # Pydantic schemas
│ └── database.py # Database configuration
├── migrations/ # Alembic migrations
├── main.py # Application entry point
├── alembic.ini # Alembic configuration
├── requirements.txt # Dependencies
└── README.md # Project documentation