106 lines
1.9 KiB
Markdown
106 lines
1.9 KiB
Markdown
# Simple Todo Application
|
|
|
|
A simple todo application API built with FastAPI and SQLite.
|
|
|
|
## Features
|
|
|
|
- Create, read, update, and delete todo items
|
|
- Built with FastAPI for high performance
|
|
- SQLite database with SQLAlchemy ORM
|
|
- Alembic for database migrations
|
|
- Health check endpoint
|
|
|
|
## Requirements
|
|
|
|
- Python 3.8+
|
|
- FastAPI
|
|
- SQLAlchemy
|
|
- Uvicorn
|
|
- Alembic
|
|
- Ruff
|
|
|
|
## Installation
|
|
|
|
1. Clone the repository:
|
|
|
|
```bash
|
|
git clone <repository-url>
|
|
cd simpletodoapplication-ti5xsx
|
|
```
|
|
|
|
2. Install dependencies:
|
|
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
## Usage
|
|
|
|
1. Run the API server:
|
|
|
|
```bash
|
|
python main.py
|
|
```
|
|
|
|
Or with uvicorn directly:
|
|
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
2. Access the API documentation:
|
|
|
|
- Swagger UI: http://localhost:8000/docs
|
|
- ReDoc: http://localhost:8000/redoc
|
|
|
|
## API Endpoints
|
|
|
|
### Health Check
|
|
|
|
- `GET /health` - Check if the API is running
|
|
|
|
### Todo Endpoints
|
|
|
|
- `GET /api/v1/todos/` - Get 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
|
|
|
|
## Database Migrations
|
|
|
|
This project uses Alembic for database migrations:
|
|
|
|
```bash
|
|
# Apply migrations
|
|
alembic upgrade head
|
|
|
|
# Create a new migration after model changes
|
|
alembic revision --autogenerate -m "Description of changes"
|
|
```
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
simpletodoapplication-ti5xsx/
|
|
├── alembic.ini
|
|
├── app/
|
|
│ ├── __init__.py
|
|
│ ├── api/
|
|
│ │ ├── __init__.py
|
|
│ │ └── routes.py
|
|
│ ├── db/
|
|
│ │ ├── __init__.py
|
|
│ │ ├── database.py
|
|
│ │ └── models.py
|
|
│ └── schemas/
|
|
│ ├── __init__.py
|
|
│ └── todo.py
|
|
├── main.py
|
|
├── migrations/
|
|
│ ├── env.py
|
|
│ ├── script.py.mako
|
|
│ └── versions/
|
|
│ └── 47fb0c1c35a0_initial_migration.py
|
|
└── requirements.txt
|
|
``` |