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

  1. Clone the repository:
git clone <repository-url>
cd <repository-name>
  1. Install dependencies:
pip install -r requirements.txt
  1. 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

API Endpoints

  • GET /health: Health check endpoint
  • GET /api/v1/items: List all items
  • POST /api/v1/items: Create a new item
  • GET /api/v1/items/{id}: Get an item by ID
  • PUT /api/v1/items/{id}: Update an item
  • DELETE /api/v1/items/{id}: Delete an item
Description
Project: Generic REST API Service
Readme 51 KiB
Languages
Python 94.1%
Mako 3.6%
Shell 2.3%