93 lines
2.4 KiB
Markdown
93 lines
2.4 KiB
Markdown
# Barebones Todo API
|
|
|
|
A simple, lightweight RESTful API for managing todo items built with FastAPI and SQLite.
|
|
|
|
## Features
|
|
|
|
- Create, read, update, and delete todo items
|
|
- Filter todos by completion status
|
|
- SQLite database for data persistence
|
|
- FastAPI for high performance and automatic API documentation
|
|
- Alembic for database migrations
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
├── app/
|
|
│ ├── api/ # API routes
|
|
│ │ └── v1/ # API version 1
|
|
│ │ └── endpoints/
|
|
│ │ └── todos.py
|
|
│ ├── core/ # Core application code
|
|
│ │ └── config.py # Configuration settings
|
|
│ ├── db/ # Database setup
|
|
│ │ ├── base.py
|
|
│ │ ├── base_class.py
|
|
│ │ └── session.py
|
|
│ ├── models/ # SQLAlchemy models
|
|
│ │ └── todo.py
|
|
│ └── schemas/ # Pydantic schemas
|
|
│ └── todo.py
|
|
├── migrations/ # Alembic migrations
|
|
├── storage/ # Storage directory
|
|
│ └── db/ # Database storage
|
|
├── alembic.ini # Alembic configuration
|
|
├── main.py # Application entry point
|
|
└── requirements.txt # Project dependencies
|
|
```
|
|
|
|
## Installation
|
|
|
|
1. Clone the repository
|
|
|
|
2. Install dependencies
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
3. Apply database migrations
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
## Running the API
|
|
|
|
Start the API server with:
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
The API will be available at http://localhost:8000
|
|
|
|
## API Documentation
|
|
|
|
- Swagger UI: http://localhost:8000/docs
|
|
- ReDoc: http://localhost:8000/redoc
|
|
- OpenAPI JSON: http://localhost:8000/openapi.json
|
|
|
|
## API Endpoints
|
|
|
|
### Base URL
|
|
- `GET /` - Returns basic API information
|
|
- `GET /health` - Health check endpoint
|
|
|
|
### Todo Endpoints
|
|
- `GET /api/v1/todos` - List all todos (with optional filters)
|
|
- `POST /api/v1/todos` - Create a new todo
|
|
- `GET /api/v1/todos/{todo_id}` - Retrieve 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. To create a new migration after model changes:
|
|
|
|
```bash
|
|
alembic revision --autogenerate -m "Description of changes"
|
|
```
|
|
|
|
To apply migrations:
|
|
|
|
```bash
|
|
alembic upgrade head
|
|
``` |