Automated Action 3acdc84e45 Implement ToDo application with FastAPI and SQLite
- Create project structure and configuration files
- Set up database models and schemas for ToDo items
- Implement CRUD operations for ToDo management
- Create API endpoints for ToDo operations
- Add health check endpoint
- Set up Alembic for database migrations
- Add comprehensive README documentation
2025-05-18 16:45:51 +00:00

128 lines
2.4 KiB
Markdown

# ToDo Application API
A simple ToDo Application API built with FastAPI and SQLite.
## Features
- Create, read, update, and delete ToDo items
- Filter ToDo items by completion status
- Pagination support
- Health check endpoint
- SQLite database for data persistence
- Alembic for database migrations
## Project Structure
```
.
├── alembic.ini
├── app
│ ├── api
│ │ ├── routes
│ │ │ ├── health.py
│ │ │ └── todo.py
│ ├── core
│ ├── crud
│ │ └── todo.py
│ ├── db
│ │ ├── base.py
│ │ └── session.py
│ ├── models
│ │ └── todo.py
│ └── schemas
│ └── todo.py
├── main.py
├── migrations
│ ├── env.py
│ ├── script.py.mako
│ └── versions
│ └── 001_create_todos_table.py
└── requirements.txt
```
## Installation
1. Clone the repository
2. Install dependencies:
```bash
pip install -r requirements.txt
```
3. Run database migrations:
```bash
alembic upgrade head
```
## Running the application
Start the application:
```bash
uvicorn main:app --reload
```
The API will be available at http://localhost:8000. You can access the API documentation at http://localhost:8000/docs.
## API Endpoints
### ToDo Operations
- `GET /api/todos`: List all todos
- Query Parameters:
- `skip`: Number of items to skip (default: 0)
- `limit`: Maximum number of items to return (default: 100)
- `completed`: Filter by completion status (Boolean, optional)
- `POST /api/todos`: Create a new todo
- Request Body:
```json
{
"title": "string",
"description": "string",
"completed": false
}
```
- `GET /api/todos/{todo_id}`: Get a specific todo
- `PUT /api/todos/{todo_id}`: Update a todo
- Request Body:
```json
{
"title": "string",
"description": "string",
"completed": true
}
```
- `DELETE /api/todos/{todo_id}`: Delete a todo
### Health Check
- `GET /health`: Check application health
- Response:
```json
{
"status": "OK",
"database_connected": true
}
```
## Development
### Database Migrations
Create a new migration:
```bash
alembic revision -m "description"
```
Apply migrations:
```bash
alembic upgrade head
```
Rollback migration:
```bash
alembic downgrade -1
```