
- Set up project structure with FastAPI and SQLite - Created Todo model with SQLAlchemy ORM - Added CRUD operations for todos - Implemented API endpoints for Todo operations - Added health check endpoint - Added Alembic for database migrations - Updated README with documentation generated with BackendIM... (backend.im)
95 lines
2.4 KiB
Markdown
95 lines
2.4 KiB
Markdown
# Simple Todo Application
|
|
|
|
A simple RESTful Todo application API built with FastAPI and SQLite.
|
|
|
|
## Features
|
|
|
|
- Create, read, update, and delete todo items
|
|
- SQLite database with SQLAlchemy ORM
|
|
- Alembic for database migrations
|
|
- Health check endpoint
|
|
- API documentation with Swagger UI
|
|
|
|
## Installation
|
|
|
|
1. Clone the repository:
|
|
|
|
```bash
|
|
git clone [repository-url]
|
|
cd simpletodoapplication
|
|
```
|
|
|
|
2. Install dependencies:
|
|
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
3. Apply 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 is available at:
|
|
- Swagger UI: `http://localhost:8000/docs`
|
|
- ReDoc: `http://localhost:8000/redoc`
|
|
|
|
## API Endpoints
|
|
|
|
### Todos
|
|
|
|
- `GET /api/todos/` - List all todos
|
|
- `POST /api/todos/` - Create a new todo
|
|
- `GET /api/todos/{todo_id}` - Get a specific todo
|
|
- `PUT /api/todos/{todo_id}` - Update a todo
|
|
- `DELETE /api/todos/{todo_id}` - Delete a todo
|
|
|
|
### Health Check
|
|
|
|
- `GET /health` - Health check endpoint
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
.
|
|
├── alembic/ # Database migration scripts
|
|
├── app/
|
|
│ ├── api/ # API routes
|
|
│ │ ├── health.py # Health check endpoint
|
|
│ │ └── todos.py # Todo API endpoints
|
|
│ ├── database/ # Database related code
|
|
│ │ ├── base.py # Database connection setup
|
|
│ │ └── crud.py # CRUD operations
|
|
│ ├── models/ # Data models
|
|
│ │ ├── schemas.py # Pydantic schemas
|
|
│ │ └── todo.py # SQLAlchemy Todo model
|
|
│ └── storage/
|
|
│ └── db/ # SQLite database files
|
|
├── main.py # FastAPI application entry point
|
|
├── requirements.txt # Project dependencies
|
|
└── README.md # Project documentation
|
|
```
|
|
|
|
## Database Schema
|
|
|
|
### Todo
|
|
|
|
| Column | Type | Description |
|
|
|-------------|-----------|-------------------------------|
|
|
| id | Integer | Primary key |
|
|
| title | String | Todo title |
|
|
| description | String | Todo description (optional) |
|
|
| completed | Boolean | Todo completion status |
|
|
| created_at | DateTime | Creation timestamp |
|
|
| updated_at | DateTime | Last update timestamp | |