
- Created project structure with FastAPI setup - Added SQLite database connection with SQLAlchemy ORM - Implemented Todo model and schemas - Added CRUD operations for Todo items - Created API endpoints for Todo management - Added health check endpoint - Configured Alembic for database migrations - Updated project documentation in README.md
103 lines
2.2 KiB
Markdown
103 lines
2.2 KiB
Markdown
# Todo API
|
|
|
|
A simple Todo application API built with FastAPI and SQLite.
|
|
|
|
## Features
|
|
|
|
- RESTful API using FastAPI
|
|
- SQLite database with SQLAlchemy ORM
|
|
- Database migrations using Alembic
|
|
- CRUD operations for Todo items
|
|
- Health check endpoint
|
|
- OpenAPI documentation
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
/
|
|
├── app/
|
|
│ ├── api/
|
|
│ │ ├── v1/
|
|
│ │ │ ├── health.py
|
|
│ │ │ └── todos.py
|
|
│ │ ├── deps.py
|
|
│ │ └── routers.py
|
|
│ ├── core/
|
|
│ │ └── config.py
|
|
│ ├── crud/
|
|
│ │ ├── base.py
|
|
│ │ └── todo.py
|
|
│ ├── db/
|
|
│ │ ├── base.py
|
|
│ │ ├── base_class.py
|
|
│ │ └── session.py
|
|
│ ├── models/
|
|
│ │ └── todo.py
|
|
│ └── schemas/
|
|
│ └── todo.py
|
|
├── migrations/
|
|
│ ├── versions/
|
|
│ │ └── 01_initial_todo_table.py
|
|
│ ├── env.py
|
|
│ └── script.py.mako
|
|
├── alembic.ini
|
|
├── main.py
|
|
└── requirements.txt
|
|
```
|
|
|
|
## Installation
|
|
|
|
1. Clone the repository
|
|
2. Install dependencies:
|
|
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
## Database Setup
|
|
|
|
The application uses SQLite as its database. The database will be created at `/app/storage/db/db.sqlite` when the application starts.
|
|
|
|
To run the migrations:
|
|
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
## Running the Application
|
|
|
|
To run the application locally:
|
|
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
The API will be available at http://localhost:8000
|
|
|
|
## API Documentation
|
|
|
|
API documentation is available at:
|
|
- Swagger UI: http://localhost:8000/docs
|
|
- ReDoc: http://localhost:8000/redoc
|
|
|
|
## API Endpoints
|
|
|
|
### Health Check
|
|
|
|
- `GET /api/v1/health` - Check API health
|
|
|
|
### Todo Endpoints
|
|
|
|
- `GET /api/v1/todos` - List all todos
|
|
- `POST /api/v1/todos` - Create a new todo
|
|
- `GET /api/v1/todos/{id}` - Get a specific todo
|
|
- `PUT /api/v1/todos/{id}` - Update a todo
|
|
- `DELETE /api/v1/todos/{id}` - Delete a todo
|
|
|
|
## Query Parameters
|
|
|
|
### List todos
|
|
|
|
- `skip` - Number of records to skip (default: 0)
|
|
- `limit` - Maximum number of records to return (default: 100)
|
|
- `completed` - Filter by completion status (optional, boolean) |