
- Set up project structure with FastAPI and SQLite - Implement Todo model, schemas, and CRUD operations - Set up Alembic for database migrations - Add health endpoint for application monitoring - Update README with project information generated with BackendIM... (backend.im)
1.7 KiB
1.7 KiB
Basic Todo Application
A simple RESTful API for managing todo items, built with FastAPI and SQLite.
Features
- Create, read, update, and delete todo items
- SQLite database for data persistence
- Alembic migrations for database versioning
- Health check endpoint
Tech Stack
- FastAPI: Modern, fast web framework for building APIs
- SQLAlchemy: SQL toolkit and ORM
- Pydantic: Data validation and settings management
- SQLite: Lightweight, file-based database
- Alembic: Database migration tool
- Uvicorn: ASGI server
Project Structure
├── alembic/ # Database migration scripts
├── app/
│ ├── database/ # Database configuration
│ ├── models/ # SQLAlchemy models
│ ├── routes/ # API endpoints
│ └── schemas/ # Pydantic schemas
├── alembic.ini # Alembic configuration
├── main.py # Application entry point
└── requirements.txt # Project dependencies
API Endpoints
- GET /api/v1/todos: Get all todo items
- GET /api/v1/todos/{id}: Get a specific todo item
- POST /api/v1/todos: Create a new todo item
- PUT /api/v1/todos/{id}: Update a todo item
- DELETE /api/v1/todos/{id}: Delete a todo item
- GET /health: Health check endpoint
Installation and Setup
- Clone the repository
- Install the requirements:
pip install -r requirements.txt
- Run the application:
uvicorn main:app --reload
- Access the API documentation at http://localhost:8000/docs
Database Migrations
Run migrations:
alembic upgrade head
Create a new migration:
alembic revision -m "description"