Todo App API
This is a simple Todo application backend built with FastAPI and SQLite.
Features
- Create, read, update, and delete Todo items
- Filter Todos by completion status
- RESTful API with proper status codes
- SQLite database with SQLAlchemy ORM
- Database migrations with Alembic
- Input validation with Pydantic
- CORS support
- Health check endpoint
Requirements
- Python 3.8+
- FastAPI
- SQLAlchemy
- Alembic
- Uvicorn
- Pydantic
- Ruff (for linting)
Installation
- Clone the repository:
git clone <repository-url>
cd todoappbackend-uspc3m
- Install dependencies:
pip install -r requirements.txt
Configuration
The application uses environment variables for configuration. You can create a .env
file in the root directory with the following settings:
PROJECT_NAME=Todo App API
Database Setup
The application uses SQLite by default. The database file will be created at /app/storage/db/db.sqlite
.
To initialize the database:
# Run the database migrations
alembic upgrade head
Running the Application
# Development server
uvicorn main:app --reload
# Production server
uvicorn main:app --host 0.0.0.0 --port 8000
API Documentation
Once the application is running, you can access the API documentation at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
GET /api/v1/todos
: Get all todos (with optional filtering)POST /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 todoGET /health
: Health check endpoint
Development
Linting
ruff check .
Fix linting issues
ruff check --fix .
Description
Languages
Python
95.2%
Mako
4.8%