
- Setup project structure and dependencies - Create Todo model and SQLAlchemy database connection - Set up Alembic for database migrations - Implement CRUD operations and API endpoints - Add health check endpoint - Update README with project documentation generated with BackendIM... (backend.im)
1.4 KiB
1.4 KiB
Todo API
A simple Todo API built with FastAPI and SQLite.
Features
- Create, read, update, and delete todos
- Health check endpoint
- SQLite database with SQLAlchemy ORM
- Database migrations with Alembic
Project Structure
todoapi/
├── alembic/ # Database migrations
│ └── versions/ # Migration versions
├── app/ # Application code
│ ├── crud/ # Database CRUD operations
│ ├── models/ # SQLAlchemy models
│ ├── routes/ # API routes
│ └── schemas/ # Pydantic schemas
├── main.py # FastAPI application entry point
├── requirements.txt # Python dependencies
└── alembic.ini # Alembic configuration
API Endpoints
Todos
GET /api/todos
: Get all todosPOST /api/todos
: Create a new todoGET /api/todos/{todo_id}
: Get a specific todoPUT /api/todos/{todo_id}
: Update a todoDELETE /api/todos/{todo_id}
: Delete a todo
Health Check
GET /health
: Check API health
Setup and Installation
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
- Run the application:
uvicorn main:app --reload
Documentation
API documentation is available at:
- Swagger UI:
/docs
- ReDoc:
/redoc