
- Set up project structure with FastAPI application - Create Todo model and related Pydantic schemas - Implement CRUD operations for Todo items - Add health endpoint for application monitoring - Configure database connection with SQLite - Create database migrations with Alembic - Update documentation with setup and usage instructions generated with BackendIM... (backend.im)
81 lines
2.1 KiB
Markdown
81 lines
2.1 KiB
Markdown
# Simple Todo Application
|
|
|
|
A simple todo application API built with FastAPI and SQLite.
|
|
|
|
## Features
|
|
|
|
- Create, read, update, and delete todo items
|
|
- Health check endpoint
|
|
- API documentation
|
|
- Database migrations with Alembic
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
/
|
|
├── alembic/ # Database migration scripts
|
|
├── app/ # Application code
|
|
│ ├── api/ # API endpoints
|
|
│ │ ├── endpoints/ # API endpoint implementations
|
|
│ │ │ ├── health.py # Health check endpoint
|
|
│ │ │ └── todos.py # Todo endpoints
|
|
│ │ └── routes.py # API router configuration
|
|
│ ├── core/ # Core application code
|
|
│ │ └── config.py # Application configuration
|
|
│ ├── db/ # Database configuration
|
|
│ │ └── database.py # Database connection setup
|
|
│ ├── models/ # SQLAlchemy models
|
|
│ │ └── todo.py # Todo model
|
|
│ └── schemas/ # Pydantic schemas
|
|
│ └── todo.py # Todo schemas
|
|
├── alembic.ini # Alembic configuration
|
|
├── main.py # Application entry point
|
|
└── requirements.txt # Project dependencies
|
|
```
|
|
|
|
## Getting Started
|
|
|
|
### Prerequisites
|
|
|
|
- Python 3.8 or higher
|
|
|
|
### Installation
|
|
|
|
1. Clone the repository
|
|
2. Install dependencies:
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
### Database Setup
|
|
|
|
1. Run database migrations:
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
### Running the Application
|
|
|
|
Start the application with:
|
|
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
The API will be available at `http://localhost:8000`.
|
|
|
|
## API Documentation
|
|
|
|
Once the application is running, you can access the API documentation at:
|
|
|
|
- Swagger UI: `http://localhost:8000/docs`
|
|
- ReDoc: `http://localhost:8000/redoc`
|
|
|
|
## API Endpoints
|
|
|
|
- `GET /api/v1/health` - Health check endpoint
|
|
- `GET /api/v1/todos` - List all todos
|
|
- `POST /api/v1/todos` - Create a new todo
|
|
- `GET /api/v1/todos/{todo_id}` - Get a specific todo
|
|
- `PUT /api/v1/todos/{todo_id}` - Update a todo
|
|
- `DELETE /api/v1/todos/{todo_id}` - Delete a todo |