
- Setup project structure - Create database models for todos - Configure SQLite database connection - Add Alembic migration scripts - Implement CRUD API endpoints for todos - Add health check endpoint - Update README with documentation generated with BackendIM... (backend.im)
120 lines
2.1 KiB
Markdown
120 lines
2.1 KiB
Markdown
# Simple Todo App
|
|
|
|
A simple REST API for managing todos built with FastAPI and SQLite.
|
|
|
|
## Features
|
|
|
|
- Create, read, update, and delete todos
|
|
- SQLite database with SQLAlchemy ORM
|
|
- Database migrations with Alembic
|
|
- Health check endpoint
|
|
- API documentation (Swagger UI and ReDoc)
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
simpletodoapp/
|
|
├── alembic/ # Database migration scripts
|
|
│ ├── versions/ # Migration version files
|
|
│ ├── env.py # Alembic environment configuration
|
|
│ └── script.py.mako # Migration script template
|
|
├── app/ # Application package
|
|
│ ├── __init__.py # Package initializer
|
|
│ ├── database.py # Database session and engine setup
|
|
│ ├── models.py # SQLAlchemy ORM models
|
|
│ └── schemas.py # Pydantic schemas for request/response validation
|
|
├── alembic.ini # Alembic configuration file
|
|
├── main.py # Application entry point
|
|
├── README.md # Project documentation
|
|
└── requirements.txt # Project dependencies
|
|
```
|
|
|
|
## Installation
|
|
|
|
1. Clone the repository:
|
|
|
|
```bash
|
|
git clone <repository-url>
|
|
cd simpletodoapp
|
|
```
|
|
|
|
2. Install dependencies:
|
|
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
3. Run the application:
|
|
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
The application will be available at http://localhost:8000.
|
|
|
|
## API Documentation
|
|
|
|
- Swagger UI: http://localhost:8000/docs
|
|
- ReDoc: http://localhost:8000/redoc
|
|
|
|
## API Endpoints
|
|
|
|
### Health Check
|
|
|
|
```
|
|
GET /health
|
|
```
|
|
|
|
Returns the health status of the application.
|
|
|
|
### Todos
|
|
|
|
```
|
|
GET /todos
|
|
```
|
|
|
|
Returns a list of all todos.
|
|
|
|
```
|
|
GET /todos/{todo_id}
|
|
```
|
|
|
|
Returns a specific todo by ID.
|
|
|
|
```
|
|
POST /todos
|
|
```
|
|
|
|
Creates a new todo.
|
|
|
|
Request Body:
|
|
|
|
```json
|
|
{
|
|
"title": "Buy groceries",
|
|
"description": "Milk, eggs, bread",
|
|
"completed": false
|
|
}
|
|
```
|
|
|
|
```
|
|
PUT /todos/{todo_id}
|
|
```
|
|
|
|
Updates an existing todo.
|
|
|
|
Request Body:
|
|
|
|
```json
|
|
{
|
|
"title": "Buy groceries",
|
|
"description": "Milk, eggs, bread, cheese",
|
|
"completed": true
|
|
}
|
|
```
|
|
|
|
```
|
|
DELETE /todos/{todo_id}
|
|
```
|
|
|
|
Deletes a todo by ID. |