
- Created FastAPI application with CRUD endpoints for todos - Set up SQLAlchemy with SQLite database - Created database models and Pydantic schemas - Added Alembic for database migrations - Added health check endpoint - Updated README with project information generated with BackendIM... (backend.im)
73 lines
1.8 KiB
Markdown
73 lines
1.8 KiB
Markdown
# Simple Todo App
|
|
|
|
This is a simple Todo API built with FastAPI and SQLite.
|
|
|
|
## Features
|
|
|
|
- Create, read, update, and delete todo items
|
|
- Health check endpoint
|
|
- SQLite database with SQLAlchemy ORM
|
|
- Alembic for database migrations
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
simpletodoapp/
|
|
│
|
|
├── alembic/ # Database migrations
|
|
│ ├── versions/ # Migration versions
|
|
│ ├── env.py # Alembic environment configuration
|
|
│ └── script.py.mako # Migration script template
|
|
│
|
|
├── app/ # Application package
|
|
│ ├── __init__.py
|
|
│ ├── crud.py # CRUD operations
|
|
│ ├── database.py # Database setup and connection
|
|
│ ├── models.py # SQLAlchemy models
|
|
│ └── schemas.py # Pydantic schemas for API
|
|
│
|
|
├── alembic.ini # Alembic configuration
|
|
├── main.py # FastAPI application and endpoints
|
|
└── requirements.txt # Python dependencies
|
|
```
|
|
|
|
## API Endpoints
|
|
|
|
- `GET /health` - Health check endpoint
|
|
- `GET /todos` - Get all todos
|
|
- `POST /todos` - Create a new todo
|
|
- `GET /todos/{todo_id}` - Get a specific todo
|
|
- `PUT /todos/{todo_id}` - Update a todo
|
|
- `DELETE /todos/{todo_id}` - Delete a todo
|
|
|
|
## Getting Started
|
|
|
|
1. Install dependencies:
|
|
```
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
2. Run database migrations:
|
|
```
|
|
alembic upgrade head
|
|
```
|
|
|
|
3. Start the application:
|
|
```
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
4. Access the API documentation at http://localhost:8000/docs
|
|
|
|
## Todo Item Schema
|
|
|
|
```json
|
|
{
|
|
"id": 1,
|
|
"title": "Task title",
|
|
"description": "Task description",
|
|
"completed": false,
|
|
"created_at": "2023-01-01T00:00:00",
|
|
"updated_at": "2023-01-01T00:00:00"
|
|
}
|
|
``` |