106 lines
2.6 KiB
Markdown
106 lines
2.6 KiB
Markdown
# Simple Todo App
|
|
|
|
This is a simple Todo application API built with FastAPI and SQLite. It allows you to create, read, update, and delete todo items through a RESTful API.
|
|
|
|
## Features
|
|
|
|
- RESTful API for Todo items
|
|
- SQLite database for persistence
|
|
- Alembic migrations for database versioning
|
|
- Data validation with Pydantic
|
|
- Health check endpoint
|
|
- API documentation with Swagger UI
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
.
|
|
├── app/ # Application package
|
|
│ ├── api/ # API endpoints
|
|
│ │ ├── health.py # Health check endpoint
|
|
│ │ └── todos.py # Todo CRUD endpoints
|
|
│ ├── database/ # Database configuration
|
|
│ │ └── database.py # SQLAlchemy setup
|
|
│ ├── models/ # SQLAlchemy models
|
|
│ │ └── todo.py # Todo model
|
|
│ └── schemas/ # Pydantic schemas
|
|
│ └── todo.py # Todo schemas for validation
|
|
├── migrations/ # Alembic migrations
|
|
│ └── versions/ # Migration scripts
|
|
│ └── 001_create_todos_table.py # Initial migration
|
|
├── alembic.ini # Alembic configuration
|
|
├── main.py # FastAPI application entry point
|
|
└── requirements.txt # Project dependencies
|
|
```
|
|
|
|
## Requirements
|
|
|
|
- Python 3.8 or higher
|
|
|
|
## Installation
|
|
|
|
1. Clone the repository:
|
|
|
|
```bash
|
|
git clone <repository-url>
|
|
cd <repository-directory>
|
|
```
|
|
|
|
2. Install dependencies:
|
|
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
## Running the Application
|
|
|
|
To run the application in development mode:
|
|
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
The application will be available at http://localhost:8000.
|
|
|
|
## API Documentation
|
|
|
|
- Swagger UI documentation: http://localhost:8000/docs
|
|
- ReDoc documentation: http://localhost:8000/redoc
|
|
|
|
## API Endpoints
|
|
|
|
### Health Check
|
|
|
|
- `GET /health` - Check if the application is running properly
|
|
|
|
### Todo Items
|
|
|
|
- `GET /api/v1/todos` - List all todo items
|
|
- `POST /api/v1/todos` - Create a new todo item
|
|
- `GET /api/v1/todos/{todo_id}` - Get a specific todo item
|
|
- `PUT /api/v1/todos/{todo_id}` - Update a todo item
|
|
- `DELETE /api/v1/todos/{todo_id}` - Delete a todo item
|
|
|
|
## Database Migrations
|
|
|
|
The application uses Alembic for database migrations. The initial migration to create the todos table is already included.
|
|
|
|
To apply migrations:
|
|
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
## Development
|
|
|
|
This project uses Ruff for linting. To run the linter:
|
|
|
|
```bash
|
|
ruff check .
|
|
```
|
|
|
|
To automatically fix issues:
|
|
|
|
```bash
|
|
ruff check --fix .
|
|
``` |