
- Set up project structure and FastAPI application - Create database models with SQLAlchemy - Set up Alembic for database migrations - Create API endpoints for todo CRUD operations - Add health check endpoint - Add unit tests for API endpoints - Configure Ruff for linting and formatting
92 lines
2.8 KiB
Markdown
92 lines
2.8 KiB
Markdown
# Simple Todo App
|
|
|
|
This is a FastAPI-based Todo application with SQLite as the database backend. The application provides a REST API for managing todo items.
|
|
|
|
## Features
|
|
|
|
- Create, read, update, and delete todo items
|
|
- SQLite database for data persistence
|
|
- Alembic for database migrations
|
|
- Health check endpoint
|
|
- API documentation with Swagger UI and ReDoc
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
├── alembic.ini # Alembic configuration
|
|
├── app # Application package
|
|
│ ├── api # API routes
|
|
│ │ ├── api.py # Main API router
|
|
│ │ └── endpoints # API endpoints
|
|
│ │ └── todos.py # Todo endpoints
|
|
│ ├── core # Core functionality
|
|
│ │ └── config.py # Application configuration
|
|
│ ├── db # Database related modules
|
|
│ │ └── session.py # Database session management
|
|
│ ├── models # SQLAlchemy models
|
|
│ │ └── todo.py # Todo model
|
|
│ └── schemas # Pydantic schemas
|
|
│ └── todo.py # Todo schemas
|
|
├── main.py # Application entry point
|
|
├── migrations # Alembic migrations
|
|
│ ├── env.py # Alembic environment
|
|
│ ├── README # Migrations README
|
|
│ ├── script.py.mako # Script template
|
|
│ └── versions # Migration versions
|
|
│ └── 001_create_todos_table.py # Initial migration
|
|
├── requirements.txt # Project dependencies
|
|
└── tests # Tests
|
|
└── test_api.py # API tests
|
|
```
|
|
|
|
## Getting Started
|
|
|
|
### Prerequisites
|
|
|
|
- Python 3.8 or higher
|
|
|
|
### Installation
|
|
|
|
1. Clone the repository
|
|
|
|
2. Install dependencies:
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
3. Run database migrations:
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
4. Start the application:
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
5. Access the API documentation:
|
|
- Swagger UI: http://localhost:8000/docs
|
|
- ReDoc: http://localhost:8000/redoc
|
|
|
|
## API Endpoints
|
|
|
|
| Method | Endpoint | Description |
|
|
|--------|--------------|--------------------------------------|
|
|
| GET | /health | Health check endpoint |
|
|
| GET | /todos | Get all todo items |
|
|
| GET | /todos/{id} | Get a specific todo item |
|
|
| POST | /todos | Create a new todo item |
|
|
| PUT | /todos/{id} | Update an existing todo item |
|
|
| DELETE | /todos/{id} | Delete a todo item |
|
|
|
|
## Testing
|
|
|
|
Run tests with pytest:
|
|
|
|
```bash
|
|
pytest
|
|
```
|
|
|
|
## License
|
|
|
|
This project is licensed under the MIT License. |