2.4 KiB
2.4 KiB
Todo Application with FastAPI
This is a simple Todo Application backend built with FastAPI and SQLite.
Features
- RESTful API for managing todo items
- CRUD operations for todos
- SQLite database with SQLAlchemy ORM
- Database migrations with Alembic
- OpenAPI documentation
Getting Started
Prerequisites
- Python 3.8+
Installation
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
- Run database migrations:
alembic upgrade head
- Start the application:
uvicorn main:app --reload
The application will be available at http://localhost:8000.
API Documentation
After starting the server, you can access the interactive API documentation at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
- GET /api/v1/todos: List all todos (can filter by completion status)
- POST /api/v1/todos: Create a new todo
- GET /api/v1/todos/{todo_id}: Get a specific todo
- PUT /api/v1/todos/{todo_id}: Update a todo
- DELETE /api/v1/todos/{todo_id}: Delete a todo
- GET /api/v1/health: Health check endpoint
Project Structure
.
├── alembic.ini # Alembic configuration
├── app # Application package
│ ├── api # API endpoints
│ │ ├── api.py # API router
│ │ └── endpoints # API endpoint modules
│ │ ├── health.py # Health check endpoint
│ │ └── todos.py # Todo endpoints
│ ├── core # Core modules
│ │ └── config.py # Application configuration
│ ├── crud # CRUD operations
│ │ └── crud_todo.py # CRUD for todos
│ ├── db # Database modules
│ │ └── session.py # Database session
│ ├── models # SQLAlchemy models
│ │ └── todo.py # Todo model
│ └── schemas # Pydantic schemas
│ └── todo.py # Todo schemas
├── main.py # Application entry point
├── migrations # Alembic migrations
└── requirements.txt # Project dependencies