Generic REST API Service

A robust REST API service built with FastAPI and SQLite.

Features

  • RESTful API endpoints with FastAPI
  • SQLite database with SQLAlchemy ORM
  • Alembic for database migrations
  • CRUD operations for Item resources
  • Health check endpoint
  • Comprehensive API documentation with Swagger UI and ReDoc

Getting Started

Prerequisites

  • Python 3.8+
  • pip package manager

Installation

  1. Clone the repository:
git clone <repository-url>
cd genericrestapiservice-p3bojs
  1. Install the dependencies:
pip install -r requirements.txt
  1. Run the database migrations:
alembic upgrade head
  1. Start the development server:
uvicorn main:app --reload

The API will be available at http://localhost:8000.

API Documentation

Project Structure

.
├── app/
│   ├── api/               # API endpoints
│   │   ├── endpoints/     # Endpoint modules
│   │   └── api.py         # API router definitions
│   ├── core/              # Core application code
│   │   └── config.py      # Application configuration
│   ├── db/                # Database setup
│   │   ├── base.py        # Import models for Alembic
│   │   ├── base_class.py  # Base SQLAlchemy class
│   │   └── 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
│   └── script.py.mako     # Migration script template
├── alembic.ini            # Alembic configuration
├── main.py                # Main application entry point
├── requirements.txt       # Python dependencies
└── README.md              # Project documentation

API Endpoints

Items

  • GET /api/v1/items - List all items
  • POST /api/v1/items - Create a new item
  • GET /api/v1/items/{item_id} - Get an item by ID
  • PUT /api/v1/items/{item_id} - Update an item
  • DELETE /api/v1/items/{item_id} - Delete an item

Health Check

  • GET /api/v1/health - Check API health

License

This project is licensed under the MIT License.

Description
Project: Generic REST API Service
Readme 42 KiB
Languages
Python 97.3%
Mako 2.7%