
- Set up project structure with FastAPI app - Implement items CRUD API endpoints - Configure SQLite database with SQLAlchemy - Set up Alembic migrations - Add health check endpoint - Enable CORS middleware - Create README with documentation
Quick API Service
A simple FastAPI application that provides a quick working API with basic CRUD operations.
Features
- RESTful API with FastAPI
- SQLite database with SQLAlchemy ORM
- Alembic migrations for database versioning
- CORS middleware enabled
- Health check endpoint
- Swagger documentation at
/docs
- ReDoc documentation at
/redoc
Project Structure
.
├── app
│ ├── api
│ │ └── v1
│ │ ├── api.py
│ │ └── endpoints
│ │ └── items.py
│ ├── core
│ │ └── config.py
│ ├── crud
│ │ └── item.py
│ ├── db
│ │ ├── base.py
│ │ └── session.py
│ ├── models
│ │ └── item.py
│ ├── schemas
│ │ └── item.py
│ └── storage
│ └── db
├── migrations
│ ├── env.py
│ ├── README
│ ├── script.py.mako
│ └── versions
│ └── 53b8c3f67ecb_create_items_table.py
├── alembic.ini
├── main.py
├── README.md
└── requirements.txt
Installation
- Clone the repository:
git clone <repository-url>
cd quickapiservice
- Install dependencies:
pip install -r requirements.txt
- Run the migrations:
alembic upgrade head
- Start the application:
uvicorn main:app --reload
The API will be available at http://localhost:8000
API Endpoints
GET /
: Root endpoint with basic informationGET /health
: Health check endpointGET /docs
: Swagger documentationGET /redoc
: ReDoc documentation
Items API
GET /api/v1/items
: Get all itemsPOST /api/v1/items
: Create a new itemGET /api/v1/items/{item_id}
: Get an item by IDPUT /api/v1/items/{item_id}
: Update an itemDELETE /api/v1/items/{item_id}
: Delete an item
Example API Usage
Create an Item
curl -X 'POST' \
'http://localhost:8000/api/v1/items/' \
-H 'Content-Type: application/json' \
-d '{
"title": "Example Item",
"description": "This is an example item"
}'
Get All Items
curl -X 'GET' 'http://localhost:8000/api/v1/items/'
Development
The application uses SQLite for the database, which is stored at /app/storage/db/db.sqlite
.
To apply new migrations:
alembic revision --autogenerate -m "description"
alembic upgrade head
License
This project is licensed under the MIT License.
Description
Languages
Python
95.1%
Mako
4.9%