
- Set up project structure with FastAPI - Create SQLite database models with SQLAlchemy - Implement Alembic for migrations - Create API endpoints for todo operations - Add health check endpoint - Update README.md with comprehensive documentation generated with BackendIM... (backend.im)
87 lines
2.0 KiB
Markdown
87 lines
2.0 KiB
Markdown
# Simple Todo Application
|
|
|
|
A simple todo application built with FastAPI and SQLite.
|
|
|
|
## Features
|
|
|
|
- Create, read, update, and delete todo items
|
|
- SQLite database with SQLAlchemy ORM
|
|
- Alembic migrations
|
|
- FastAPI with automatic OpenAPI documentation
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
simpletodoapplication/
|
|
├── alembic/ # Database migrations
|
|
│ └── versions/ # Migration scripts
|
|
├── app/ # Application code
|
|
│ ├── api/ # API routes
|
|
│ ├── core/ # Core configuration
|
|
│ ├── db/ # Database setup
|
|
│ ├── models/ # SQLAlchemy models
|
|
│ └── schemas/ # Pydantic schemas
|
|
├── storage/ # Storage directory
|
|
│ └── db/ # Database files
|
|
├── alembic.ini # Alembic configuration
|
|
├── main.py # Application entry point
|
|
├── README.md # This file
|
|
└── requirements.txt # Project dependencies
|
|
```
|
|
|
|
## Installation
|
|
|
|
1. Clone the repository
|
|
2. Install dependencies:
|
|
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
## Running the Application
|
|
|
|
1. Run database migrations:
|
|
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
2. Start the application:
|
|
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
3. Open your browser and navigate to:
|
|
- API Documentation: http://localhost:8000/docs
|
|
- Redoc Documentation: http://localhost:8000/redoc
|
|
- Health Check: http://localhost:8000/health
|
|
|
|
## API Endpoints
|
|
|
|
- `GET /health`: Health check endpoint
|
|
- `POST /api/todos/`: Create a new todo
|
|
- `GET /api/todos/`: Get all todos
|
|
- `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
|
|
|
|
## Database Migrations
|
|
|
|
To create a new migration:
|
|
|
|
```bash
|
|
alembic revision -m "your migration message"
|
|
```
|
|
|
|
To upgrade to the latest migration:
|
|
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
To downgrade the last migration:
|
|
|
|
```bash
|
|
alembic downgrade -1
|
|
``` |