# FastAPI REST API This is a FastAPI-based REST API application that provides CRUD operations for managing items. ## Features - FastAPI framework for high-performance API development - SQLAlchemy ORM with SQLite database - Alembic for database migrations - Pydantic for data validation - CRUD operations for items - Health check endpoint - Interactive API documentation ## Project Structure ``` ├── app/ # Application package │ ├── api/ # API endpoints │ │ ├── endpoints/ # API route handlers │ │ │ └── items.py # Items API endpoints │ ├── core/ # Core application modules │ │ ├── app.py # FastAPI application factory │ │ └── config.py # Application configuration │ ├── db/ # Database related modules │ │ ├── base.py # Import all models for Alembic │ │ ├── base_class.py # Base class for SQLAlchemy models │ │ └── session.py # Database session setup │ ├── models/ # SQLAlchemy models │ │ └── item.py # Item model │ └── schemas/ # Pydantic schemas │ └── item.py # Item schemas ├── migrations/ # Alembic migrations │ ├── versions/ # Migration scripts │ ├── env.py # Alembic environment configuration │ └── script.py.mako # Alembic script template ├── alembic.ini # Alembic configuration ├── main.py # Application entry point └── requirements.txt # Project dependencies ``` ## Setup and Installation 1. Clone the repository: ```bash git clone cd genericrestapi-3gclpr ``` 2. Install dependencies: ```bash pip install -r requirements.txt ``` 3. Run the application: ```bash uvicorn main:app --host 0.0.0.0 --port 8000 --reload ``` 4. Access the API documentation: - 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 the health status of the API ### Items API - `POST /api/v1/items`: Create a new item - `GET /api/v1/items`: List all items (with pagination) - `GET /api/v1/items/{item_id}`: Get a specific item by ID - `PUT /api/v1/items/{item_id}`: Update an item - `DELETE /api/v1/items/{item_id}`: Delete an item ## Database Migrations Create a new migration: ```bash alembic revision --autogenerate -m "description" ``` Apply migrations: ```bash alembic upgrade head ``` Revert migrations: ```bash alembic downgrade -1 ```