# Simple FastAPI Application This is a simple FastAPI application with SQLite database integration, built to demonstrate best practices for API development with FastAPI. ## Features - RESTful API with FastAPI - SQLite database with SQLAlchemy ORM - Database migrations with Alembic - CRUD operations for items - Health check endpoint - OpenAPI documentation - Code linting with Ruff ## Project Structure ``` ├── app/ │ ├── api/ │ │ ├── endpoints/ │ │ │ ├── health.py │ │ │ └── items.py │ ├── core/ │ │ └── config.py │ ├── db/ │ │ └── session.py │ ├── models/ │ │ └── models.py │ ├── schemas/ │ │ └── item.py │ └── storage/ │ └── db/ ├── migrations/ │ ├── versions/ │ │ └── 47e3b63e1a20_create_items_table.py │ ├── env.py │ └── script.py.mako ├── alembic.ini ├── main.py ├── README.md └── requirements.txt ``` ## Installation 1. Clone the repository 2. Install dependencies: ```bash pip install -r requirements.txt ``` ## Running the Application Start the application with uvicorn: ```bash uvicorn main:app --host 0.0.0.0 --port 8000 --reload ``` ## API Documentation Once the application is running, you can access: - Swagger UI: [http://localhost:8000/docs](http://localhost:8000/docs) - ReDoc: [http://localhost:8000/redoc](http://localhost:8000/redoc) ## API Endpoints ### Health Check - `GET /health` - Check if the API and database are running ### Items - `GET /api/v1/items` - Get all items - `GET /api/v1/items/{item_id}` - Get an item by ID - `POST /api/v1/items` - Create a new item - `PATCH /api/v1/items/{item_id}` - Update an item - `DELETE /api/v1/items/{item_id}` - Delete an item ## Database Migrations Run migrations: ```bash alembic upgrade head ``` Create a new migration: ```bash alembic revision --autogenerate -m "description" ``` ## License MIT