
- Implement Todo CRUD API endpoints - Set up SQLite database with SQLAlchemy - Create Todo model and schemas - Configure Alembic migrations - Add comprehensive documentation 🤖 Generated with and Co-Authored by [BackendIM](https://backend.im)
87 lines
2.0 KiB
Markdown
87 lines
2.0 KiB
Markdown
# Todo Backend Service API
|
|
|
|
This is a RESTful API for a Todo application built with FastAPI and SQLite. The API allows users to create, read, update, and delete todo items.
|
|
|
|
## Features
|
|
|
|
- CRUD operations for todo items
|
|
- Filtering todos by completion status
|
|
- SQLite database with SQLAlchemy ORM
|
|
- Alembic migrations
|
|
- API documentation with Swagger UI and ReDoc
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
todobackendservice/
|
|
├── alembic/ # Database migrations
|
|
├── app/ # Application package
|
|
│ ├── api/ # API endpoints
|
|
│ ├── core/ # Core functionality, configs
|
|
│ ├── db/ # Database session, dependencies
|
|
│ ├── models/ # SQLAlchemy models
|
|
│ ├── schemas/ # Pydantic schemas
|
|
│ └── storage/ # Storage directory for SQLite
|
|
├── main.py # Application entry point
|
|
├── alembic.ini # Alembic configuration
|
|
└── requirements.txt # Project dependencies
|
|
```
|
|
|
|
## Getting Started
|
|
|
|
### Prerequisites
|
|
|
|
- Python 3.8 or higher
|
|
- pip (Python package installer)
|
|
|
|
### Installation
|
|
|
|
1. Clone the repository:
|
|
|
|
```bash
|
|
git clone <repository-url>
|
|
cd todobackendservice
|
|
```
|
|
|
|
2. Install the dependencies:
|
|
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
3. Run the database migrations:
|
|
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
4. Start the application:
|
|
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
The API will be available at `http://localhost:8000`.
|
|
|
|
## API Documentation
|
|
|
|
The API documentation is available at:
|
|
|
|
- Swagger UI: `http://localhost:8000/docs`
|
|
- ReDoc: `http://localhost:8000/redoc`
|
|
|
|
## API Endpoints
|
|
|
|
### Todos
|
|
|
|
- `GET /api/v1/todos` - List all todos
|
|
- `POST /api/v1/todos` - Create a new todo
|
|
- `GET /api/v1/todos/{todo_id}` - Get a specific todo
|
|
- `PUT /api/v1/todos/{todo_id}` - Update a todo
|
|
- `DELETE /api/v1/todos/{todo_id}` - Delete a todo
|
|
|
|
### Query Parameters
|
|
|
|
- `skip` - Number of records to skip (default: 0)
|
|
- `limit` - Maximum number of records to return (default: 100)
|
|
- `completed` - Filter by completion status (optional) |