102 lines
2.4 KiB
Markdown
102 lines
2.4 KiB
Markdown
# Simple Todo API
|
|
|
|
A deadass simple Todo API built with FastAPI and SQLite. This project provides a RESTful API for managing todo items with the basic CRUD operations.
|
|
|
|
## Features
|
|
|
|
- RESTful API endpoints for Todo resource (Create, Read, Update, Delete)
|
|
- SQLite database with SQLAlchemy ORM
|
|
- Database migrations with Alembic
|
|
- Health check endpoint
|
|
- Interactive API documentation (Swagger & ReDoc)
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
simpletodoapi/
|
|
├── alembic.ini
|
|
├── app/
|
|
│ ├── api/
|
|
│ │ ├── endpoints/
|
|
│ │ │ ├── health.py
|
|
│ │ │ └── todo.py
|
|
│ │ └── __init__.py
|
|
│ ├── core/
|
|
│ │ └── __init__.py
|
|
│ ├── db/
|
|
│ │ ├── database.py
|
|
│ │ └── __init__.py
|
|
│ ├── models/
|
|
│ │ ├── todo.py
|
|
│ │ └── __init__.py
|
|
│ ├── schemas/
|
|
│ │ ├── todo.py
|
|
│ │ └── __init__.py
|
|
│ └── __init__.py
|
|
├── migrations/
|
|
│ ├── env.py
|
|
│ ├── script.py.mako
|
|
│ ├── versions/
|
|
│ │ ├── 20231111_initial_migration.py
|
|
│ │ └── __init__.py
|
|
│ └── __init__.py
|
|
├── main.py
|
|
└── requirements.txt
|
|
```
|
|
|
|
## Installation
|
|
|
|
1. Clone the repository
|
|
|
|
2. Install dependencies:
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
3. Run the application:
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
The API will be available at http://localhost:8000
|
|
|
|
## API Endpoints
|
|
|
|
### Health Check
|
|
- `GET /health` - Check API and database health
|
|
|
|
### Todo Management
|
|
- `GET /api/v1/todos` - Get all todos (with optional pagination and filtering)
|
|
- `GET /api/v1/todos/{todo_id}` - Get a specific todo by ID
|
|
- `POST /api/v1/todos` - Create a new todo
|
|
- `PUT /api/v1/todos/{todo_id}` - Update an existing todo
|
|
- `DELETE /api/v1/todos/{todo_id}` - Delete a todo
|
|
|
|
## API Documentation
|
|
|
|
Interactive API documentation is available at:
|
|
- Swagger UI: http://localhost:8000/docs
|
|
- ReDoc: http://localhost:8000/redoc
|
|
|
|
## Database
|
|
|
|
The application uses SQLite as the database. The database file is stored at `/app/storage/db/db.sqlite`.
|
|
|
|
Database migrations are managed with Alembic. The initial migration is already included to set up the todos table.
|
|
|
|
## Development
|
|
|
|
To run the development server with hot-reload:
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
To lint the codebase:
|
|
```bash
|
|
ruff check .
|
|
```
|
|
|
|
To auto-fix linting issues:
|
|
```bash
|
|
ruff check --fix .
|
|
``` |