
Generic REST API Service
A FastAPI-based REST API service with SQLite database integration.
Features
- RESTful API with FastAPI
- SQLAlchemy ORM integration with SQLite
- Database migrations with Alembic
- Health check endpoint
- Items CRUD operations
- OpenAPI documentation (Swagger and ReDoc)
Project Structure
├── app/
│ ├── api/ # API endpoints
│ ├── core/ # Core functionality, configuration
│ ├── crud/ # CRUD operations
│ ├── db/ # Database setup
│ ├── models/ # SQLAlchemy models
│ └── schemas/ # Pydantic schemas
├── migrations/ # Alembic migrations
│ └── versions/ # Migration versions
├── alembic.ini # Alembic configuration
├── main.py # Application entry point
└── requirements.txt # Dependencies
Getting Started
Prerequisites
- Python 3.8+
- pip
Installation
- Clone the repository:
git clone <repository-url>
cd <repository-name>
- Install dependencies:
pip install -r requirements.txt
- Run the application:
uvicorn main:app --host 0.0.0.0 --port 8001 --reload
The API will be available at http://localhost:8001.
Health Check
The application has a dedicated health check endpoint at /health
that returns a simple JSON response:
{"status": "ok"}
This endpoint can be used by load balancers, container orchestrators, or monitoring tools to verify that the application is running correctly.
API Documentation
- Swagger UI: http://localhost:8001/docs
- ReDoc: http://localhost:8001/redoc
API Endpoints
GET /health
: Health check endpointGET /api/v1/items
: List all itemsPOST /api/v1/items
: Create a new itemGET /api/v1/items/{id}
: Get an item by IDPUT /api/v1/items/{id}
: Update an itemDELETE /api/v1/items/{id}
: Delete an item
Description
Languages
Python
94.1%
Mako
3.6%
Shell
2.3%