79 lines
2.0 KiB
Markdown

# 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:
```bash
git clone <repository-url>
cd <repository-name>
```
2. Install dependencies:
```bash
pip install -r requirements.txt
```
3. Run the application:
```bash
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:
```json
{"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 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