
- Set up project structure with FastAPI app - Create SQLite database models with SQLAlchemy - Set up Alembic migrations - Implement CRUD endpoints for todo items - Add health check endpoint - Update README with setup instructions generated with BackendIM... (backend.im)
79 lines
1.5 KiB
Markdown
79 lines
1.5 KiB
Markdown
# Simple Todo App with FastAPI and SQLite
|
|
|
|
A minimalist Todo API application built with FastAPI and SQLite for managing todo items.
|
|
|
|
## Features
|
|
|
|
- Create, read, update, and delete todo items
|
|
- SQLite database with SQLAlchemy ORM
|
|
- Alembic migrations for database versioning
|
|
- Health check endpoint for monitoring
|
|
- OpenAPI documentation
|
|
|
|
## Prerequisites
|
|
|
|
- Python 3.8+
|
|
- pip (Python package installer)
|
|
|
|
## Installation
|
|
|
|
1. Clone the repository:
|
|
|
|
```bash
|
|
git clone https://github.com/yourusername/simpletodoapp.git
|
|
cd simpletodoapp
|
|
```
|
|
|
|
2. Install dependencies:
|
|
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
3. Prepare the database directory:
|
|
|
|
```bash
|
|
mkdir -p /app/storage/db
|
|
```
|
|
|
|
4. Run database migrations:
|
|
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
## Running the Application
|
|
|
|
Start the application with Uvicorn:
|
|
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
The API will be available at http://localhost:8000
|
|
|
|
## API Documentation
|
|
|
|
Once the application is running, you can access:
|
|
|
|
- Interactive API documentation: http://localhost:8000/docs
|
|
- Alternative API documentation: http://localhost:8000/redoc
|
|
|
|
## API Endpoints
|
|
|
|
- `GET /todos` - Get all todos
|
|
- `POST /todos` - Create a new todo
|
|
- `GET /todos/{todo_id}` - Get a specific todo
|
|
- `PATCH /todos/{todo_id}` - Update a todo
|
|
- `DELETE /todos/{todo_id}` - Delete a todo
|
|
- `GET /health` - Check application health
|
|
|
|
## Example Todo JSON
|
|
|
|
```json
|
|
{
|
|
"title": "Buy groceries",
|
|
"description": "Milk, eggs, bread, and cheese",
|
|
"completed": false
|
|
}
|
|
``` |