108 lines
2.2 KiB
Markdown
108 lines
2.2 KiB
Markdown
# Simple Todo Application
|
|
|
|
A simple Todo API built with FastAPI and SQLite.
|
|
|
|
## Features
|
|
|
|
- Create, read, update, and delete todo items
|
|
- Filter todos by completion status
|
|
- Database migrations using Alembic
|
|
- Health check endpoint
|
|
- API documentation
|
|
|
|
## Requirements
|
|
|
|
- Python 3.8+
|
|
- FastAPI
|
|
- SQLAlchemy
|
|
- Alembic
|
|
- Uvicorn
|
|
- SQLite
|
|
|
|
## Installation
|
|
|
|
1. Clone this repository:
|
|
```bash
|
|
git clone https://github.com/yourusername/simpletodoapplication.git
|
|
cd simpletodoapplication
|
|
```
|
|
|
|
2. Install the dependencies:
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
3. Run the database migrations:
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
## Running the Application
|
|
|
|
Start the server with:
|
|
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
The API will be available at http://localhost:8000.
|
|
|
|
## API Documentation
|
|
|
|
Once the application is running, you can access:
|
|
|
|
- Swagger UI documentation: http://localhost:8000/docs
|
|
- ReDoc documentation: http://localhost:8000/redoc
|
|
|
|
## API Endpoints
|
|
|
|
### Health Check
|
|
|
|
- `GET /health` - Check the health of the API
|
|
|
|
### Todo Operations
|
|
|
|
- `GET /api/v1/todos` - List all todos (optional query parameters: skip, limit, completed)
|
|
- `POST /api/v1/todos` - Create a new todo
|
|
- `GET /api/v1/todos/{todo_id}` - Get a specific todo
|
|
- `PATCH /api/v1/todos/{todo_id}` - Update a todo
|
|
- `DELETE /api/v1/todos/{todo_id}` - Delete a todo
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
simpletodoapplication/
|
|
├── alembic.ini
|
|
├── app/
|
|
│ ├── api/
|
|
│ │ ├── endpoints/
|
|
│ │ │ ├── health.py
|
|
│ │ │ └── todos.py
|
|
│ │ └── routers.py
|
|
│ ├── core/
|
|
│ │ └── config.py
|
|
│ ├── db/
|
|
│ │ └── session.py
|
|
│ ├── models/
|
|
│ │ └── todo.py
|
|
│ └── schemas/
|
|
│ └── todo.py
|
|
├── main.py
|
|
├── migrations/
|
|
│ ├── env.py
|
|
│ ├── script.py.mako
|
|
│ └── versions/
|
|
│ └── 01_initial_migration.py
|
|
└── requirements.txt
|
|
```
|
|
|
|
## Data Models
|
|
|
|
### Todo
|
|
|
|
- `id`: Integer (Primary Key)
|
|
- `title`: String (Required)
|
|
- `description`: String (Optional)
|
|
- `completed`: Boolean (Default: False)
|
|
- `created_at`: DateTime
|
|
- `updated_at`: DateTime |