70 lines
1.7 KiB
Markdown
70 lines
1.7 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 --reload
|
|
```
|
|
|
|
The API will be available at http://localhost:8000.
|
|
|
|
## API Documentation
|
|
|
|
- Swagger UI: http://localhost:8000/docs
|
|
- ReDoc: http://localhost:8000/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 |