2.8 KiB
2.8 KiB
Simple Todo App
A simple Todo API built with FastAPI and SQLite.
Features
- Create, read, update and delete Todo items
- Filter todos by completion status
- Health check endpoint to verify API and database status
- API documentation with Swagger UI and ReDoc
Requirements
- Python 3.8+
- FastAPI
- SQLAlchemy
- Alembic (for database migrations)
- Uvicorn (ASGI server)
- SQLite
Project Structure
.
├── alembic.ini # Alembic configuration file
├── app/ # Application package
│ ├── api/ # API endpoints
│ │ ├── deps.py # API dependencies
│ │ ├── health.py # Health check endpoint
│ │ └── v1/ # API version 1
│ │ ├── api.py # API router
│ │ └── endpoints/ # API endpoints by resource
│ │ └── todos.py # Todo CRUD operations
│ ├── core/ # Core modules
│ │ └── config.py # Application configuration
│ ├── db/ # Database related code
│ │ └── session.py # Database session
│ ├── models/ # SQLAlchemy models
│ │ └── todo.py # Todo model
│ ├── schemas/ # Pydantic schemas
│ │ └── todo.py # Todo schemas
│ └── storage/ # Storage directory
│ └── db/ # Database files
├── main.py # Application entry point
├── migrations/ # Alembic migrations
│ ├── env.py # Migration environment
│ ├── script.py.mako # Migration script template
│ └── versions/ # Migration versions
│ └── initial_migration.py # Initial migration
├── pyproject.toml # Project configuration for tools
└── requirements.txt # Python dependencies
Quick Start
- Clone the repository
- Create a virtual environment:
python -m venv venv
- Activate the virtual environment:
source venv/bin/activate
(Linux/Mac) orvenv\Scripts\activate
(Windows) - Install dependencies:
pip install -r requirements.txt
- Run the application:
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: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
- GET /api/v1/todos: List all todos
- POST /api/v1/todos: Create a new todo
- GET /api/v1/todos/{todo_id}: Get a specific todo
- PATCH /api/v1/todos/{todo_id}: Update a todo
- DELETE /api/v1/todos/{todo_id}: Delete a todo
- GET /health: Health check endpoint
- GET /: Root endpoint with welcome message