Automated Action 512d53de73 Create simple Todo application with FastAPI and SQLite
- Created CRUD operations for todos
- Added database models and SQLAlchemy integration
- Set up Alembic for database migrations
- Added health endpoint
- Updated README with installation and usage instructions

generated with BackendIM... (backend.im)
2025-05-12 10:34:56 +00:00

112 lines
2.0 KiB
Markdown

# Simple Todo Application
A simple Todo API built with FastAPI and SQLAlchemy using SQLite as the database.
## Features
- Todo CRUD operations (Create, Read, Update, Delete)
- Health endpoint to check application status
- Database migrations with Alembic
- SQLite database storage
## Requirements
- Python 3.8+
- FastAPI
- SQLAlchemy
- Alembic
- Uvicorn
## Installation
1. Clone the repository
```bash
git clone https://github.com/yourusername/simpletodoapplication.git
cd simpletodoapplication
```
2. Install dependencies
```bash
pip install -r requirements.txt
```
3. Run migrations
```bash
alembic upgrade head
```
## Running the Application
1. Start the FastAPI server
```bash
uvicorn main:app --reload
```
2. The API will be available at http://localhost:8000
## API Documentation
Once the server is running, you can access the interactive API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
## API Endpoints
### Health Check
- `GET /health` - Check application and database health
### Todo Operations
- `GET /api/todos` - Get all todos
- `GET /api/todos/{id}` - Get a specific todo by ID
- `POST /api/todos` - Create a new todo
- `PUT /api/todos/{id}` - Update an existing todo
- `DELETE /api/todos/{id}` - Delete a todo
## Data Model
### Todo
- `id`: integer (primary key)
- `title`: string (required)
- `description`: string (optional)
- `completed`: boolean (default: false)
- `created_at`: datetime
- `updated_at`: datetime
## Example Usage
### Create a Todo
```bash
curl -X 'POST' \
'http://localhost:8000/api/todos/' \
-H 'Content-Type: application/json' \
-d '{
"title": "Buy groceries",
"description": "Milk, eggs, bread",
"completed": false
}'
```
### Get All Todos
```bash
curl -X 'GET' 'http://localhost:8000/api/todos/'
```
### Update a Todo
```bash
curl -X 'PUT' \
'http://localhost:8000/api/todos/1' \
-H 'Content-Type: application/json' \
-d '{
"completed": true
}'
```
### Delete a Todo
```bash
curl -X 'DELETE' 'http://localhost:8000/api/todos/1'
```