
This commit includes: - Basic project structure with FastAPI - SQLite database integration using SQLAlchemy - CRUD API for items - Alembic migrations setup - Health check endpoint - Proper error handling - Updated README with setup instructions
QuickSimpleAPI
A quick and simple FastAPI application with SQLite database. This project provides a simple CRUD API for managing items.
Features
- FastAPI framework with automatic API documentation
- SQLite database integration
- SQLAlchemy ORM
- Alembic migrations
- CORS support
Requirements
- Python 3.8+
- FastAPI
- SQLAlchemy
- Alembic
- Uvicorn
- Pydantic
Getting Started
Installation
- Clone the repository:
git clone https://github.com/yourusername/quicksimpleapi.git
cd quicksimpleapi
- Install dependencies:
pip install -r requirements.txt
- Run database migrations:
alembic upgrade head
- Start the application:
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
Root Endpoint
GET /
: Returns basic information about the API.
Health Check
GET /health
: Returns the health status of the API.
Items API
GET /api/v1/items
: Retrieve a list of items.POST /api/v1/items
: Create a new item.GET /api/v1/items/{item_id}
: Retrieve an item by ID.PUT /api/v1/items/{item_id}
: Update an item.DELETE /api/v1/items/{item_id}
: Delete an item.
Environment Variables
The following environment variables can be set:
SECRET_KEY
: Secret key for security. Default is "development_secret_key".
Project Structure
quicksimpleapi/
├── app/
│ ├── api/
│ │ └── v1/
│ │ ├── __init__.py
│ │ └── items.py
│ ├── core/
│ │ ├── __init__.py
│ │ └── config.py
│ ├── db/
│ │ ├── __init__.py
│ │ ├── base.py
│ │ └── session.py
│ ├── models/
│ │ ├── __init__.py
│ │ └── item.py
│ └── schemas/
│ ├── __init__.py
│ └── item.py
├── migrations/
│ ├── versions/
│ │ └── 001_create_items_table.py
│ ├── env.py
│ └── script.py.mako
├── main.py
├── alembic.ini
└── requirements.txt
Description
Languages
Python
95.1%
Mako
4.9%