todoapi-0h1oi4/README.md
Automated Action 7fa5fb0213 Setup complete Todo API with FastAPI and SQLite
- Create Todo model and schemas
- Set up API endpoints for CRUD operations
- Configure SQLAlchemy for database access
- Set up Alembic for database migrations
- Add Ruff for code linting
- Update README with project documentation
2025-05-27 06:32:35 +00:00

119 lines
3.0 KiB
Markdown

# Todo API
This is a FastAPI application for managing todo items.
## Features
- RESTful API for todo management
- CRUD operations for todo items
- SQLite database with SQLAlchemy ORM
- Alembic for database migrations
- Automatic API documentation with Swagger UI
## Project Structure
```
todoapi/
├── alembic.ini # Alembic configuration
├── app/ # Application package
│ ├── api/ # API routes
│ │ └── v1/ # API version 1
│ │ ├── api.py # Main API router
│ │ └── endpoints/ # API endpoints
│ │ └── todos.py # Todo endpoints
│ ├── core/ # Core modules
│ │ └── config.py # Application configuration
│ ├── crud/ # CRUD operations
│ │ └── todo.py # Todo CRUD operations
│ ├── db/ # Database modules
│ │ ├── base.py # Base models module
│ │ ├── base_class.py # Base model class
│ │ └── session.py # Database session
│ ├── models/ # SQLAlchemy models
│ │ └── todo.py # Todo model
│ └── schemas/ # Pydantic schemas
│ └── todo.py # Todo schemas
├── main.py # Main application entry point
├── migrations/ # Alembic migrations
│ ├── env.py # Migrations environment
│ ├── README # Migrations README
│ ├── script.py.mako # Migrations script template
│ └── versions/ # Migration versions
│ └── initial_migration.py # Initial migration
├── pyproject.toml # Project configuration
├── README.md # This file
└── requirements.txt # Project dependencies
```
## Installation
1. Clone the repository:
```bash
git clone <repository-url>
cd todoapi
```
2. Install dependencies:
```bash
pip install -r requirements.txt
```
3. Run the application:
```bash
uvicorn main:app --reload
```
The API will be available at http://localhost:8000.
## API Documentation
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- OpenAPI JSON: http://localhost:8000/openapi.json
## API Endpoints
### Todo 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
- `PUT /api/v1/todos/{todo_id}` - Update a todo
- `DELETE /api/v1/todos/{todo_id}` - Delete a todo
## Health Check
- `GET /health` - Check if the API is running
## Database Migrations
Apply migrations:
```bash
alembic upgrade head
```
Create a new migration:
```bash
alembic revision --autogenerate -m "description"
```
## Development
### Linting
This project uses Ruff for linting:
```bash
ruff check .
```
To automatically fix issues:
```bash
ruff check --fix .
```