
- Set up project structure with FastAPI and SQLite - Created Todo model and database schemas - Implemented CRUD operations for Todo items - Added Alembic for database migrations - Added health check endpoint - Used Ruff for code linting and formatting - Updated README with project documentation
98 lines
2.0 KiB
Markdown
98 lines
2.0 KiB
Markdown
# Simple Todo App
|
|
|
|
A simple Todo application API built with FastAPI and SQLite.
|
|
|
|
## Features
|
|
|
|
- Create, read, update, and delete Todo items
|
|
- Filter Todos by completion status
|
|
- Health check endpoint
|
|
- SQLite database with SQLAlchemy ORM
|
|
- Alembic for database migrations
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
simpletodoapp/
|
|
├── app/
|
|
│ ├── api/
|
|
│ │ ├── endpoints/
|
|
│ │ │ ├── health.py
|
|
│ │ │ └── todos.py
|
|
│ ├── core/
|
|
│ │ └── config.py
|
|
│ ├── db/
|
|
│ │ ├── crud.py
|
|
│ │ └── session.py
|
|
│ ├── models/
|
|
│ │ └── todo.py
|
|
│ └── schemas/
|
|
│ └── todo.py
|
|
├── migrations/
|
|
│ ├── versions/
|
|
│ │ └── e4fe0b756bcd_create_todos_table.py
|
|
│ ├── env.py
|
|
│ ├── README
|
|
│ └── script.py.mako
|
|
├── storage/
|
|
│ └── db/
|
|
├── alembic.ini
|
|
├── main.py
|
|
└── requirements.txt
|
|
```
|
|
|
|
## Installation
|
|
|
|
1. Clone the repository
|
|
2. Install dependencies:
|
|
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
## Running the Application
|
|
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
The API will be available at `http://localhost:8000`.
|
|
|
|
API Documentation will be available at:
|
|
- Swagger UI: `http://localhost:8000/docs`
|
|
- ReDoc: `http://localhost:8000/redoc`
|
|
|
|
## Database Migration
|
|
|
|
The application uses Alembic for database migrations.
|
|
|
|
To apply migrations:
|
|
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
## API Endpoints
|
|
|
|
### Health Check
|
|
- `GET /health` - Check the health of the application
|
|
|
|
### Todo Endpoints
|
|
- `GET /api/todos` - List all todos (with optional filtering)
|
|
- `POST /api/todos` - Create a new todo
|
|
- `GET /api/todos/{todo_id}` - Get a specific todo
|
|
- `PUT /api/todos/{todo_id}` - Update a todo
|
|
- `DELETE /api/todos/{todo_id}` - Delete a todo
|
|
|
|
## Example Todo Object
|
|
|
|
```json
|
|
{
|
|
"id": 1,
|
|
"title": "Buy groceries",
|
|
"description": "Milk, bread, eggs",
|
|
"completed": false,
|
|
"created_at": "2023-08-01T10:00:00",
|
|
"updated_at": "2023-08-01T10:00:00"
|
|
}
|
|
``` |