
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
- Clone the repository:
git clone <repository-url>
cd genericrestapiservice-p3bojs
- Install the dependencies:
pip install -r requirements.txt
- Run the database migrations:
alembic upgrade head
- Start the development server:
uvicorn main:app --reload
The API will be available at http://localhost:8000.
API Documentation
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
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 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
Health Check
GET /api/v1/health
- Check API health
License
This project is licensed under the MIT License.
Description
Languages
Python
97.3%
Mako
2.7%