
- Set up project structure with FastAPI - Create Todo database model and schema - Implement database connection with SQLAlchemy - Set up Alembic migrations - Implement CRUD API endpoints for Todo items - Add health check endpoint - Update documentation in README.md generated with BackendIM... (backend.im)
83 lines
2.0 KiB
Markdown
83 lines
2.0 KiB
Markdown
# Todo Application API
|
|
|
|
This is a Todo Application API built with FastAPI and SQLite database. It provides CRUD operations for managing todo items.
|
|
|
|
## Features
|
|
|
|
- Create, read, update, and delete todo items
|
|
- Filter todos by completion status
|
|
- Health check endpoint
|
|
- SQLite database with SQLAlchemy ORM
|
|
- Alembic migrations
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
/
|
|
├── app/
|
|
│ ├── api/
|
|
│ │ ├── health.py # Health check endpoint
|
|
│ │ └── todos.py # Todo CRUD endpoints
|
|
│ ├── db/
|
|
│ │ └── database.py # Database connection
|
|
│ ├── models/
|
|
│ │ └── todo.py # SQLAlchemy models
|
|
│ ├── schemas/
|
|
│ │ └── todo.py # Pydantic schemas
|
|
│ └── utils/
|
|
├── migrations/ # Alembic migrations
|
|
│ ├── versions/
|
|
│ │ └── 001_create_todos_table.py
|
|
│ ├── env.py
|
|
│ └── script.py.mako
|
|
├── storage/ # SQLite database location
|
|
│ └── db/
|
|
├── alembic.ini # Alembic configuration
|
|
├── main.py # Application entry point
|
|
├── requirements.txt # Project dependencies
|
|
└── README.md
|
|
```
|
|
|
|
## Getting Started
|
|
|
|
### Prerequisites
|
|
|
|
- Python 3.7+
|
|
- pip
|
|
|
|
### Installation
|
|
|
|
1. Clone the repository
|
|
2. Install dependencies:
|
|
```
|
|
pip install -r requirements.txt
|
|
```
|
|
3. Run database migrations:
|
|
```
|
|
alembic upgrade head
|
|
```
|
|
4. Start the server:
|
|
```
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
## API Documentation
|
|
|
|
Once the server is running, you can access the API documentation at:
|
|
|
|
- Swagger UI: http://localhost:8000/docs
|
|
- ReDoc: http://localhost:8000/redoc
|
|
|
|
## API Endpoints
|
|
|
|
### Todo Endpoints
|
|
|
|
- `GET /todos`: Get all todo items (with optional filtering)
|
|
- `POST /todos`: Create a new todo item
|
|
- `GET /todos/{todo_id}`: Get a specific todo item
|
|
- `PUT /todos/{todo_id}`: Update a todo item
|
|
- `DELETE /todos/{todo_id}`: Delete a todo item
|
|
|
|
### Health Endpoint
|
|
|
|
- `GET /health`: Health check endpoint |