
Features: - Project structure setup - Database configuration with SQLAlchemy - Item model and CRUD operations - API endpoints for items - Alembic migrations - Health check endpoint - Comprehensive documentation generated with BackendIM... (backend.im)
67 lines
1.6 KiB
Markdown
67 lines
1.6 KiB
Markdown
# Generic REST API Service
|
|
|
|
A modern REST API service built with FastAPI and SQLite, providing a clean architecture and RESTful endpoints.
|
|
|
|
## Features
|
|
|
|
- Fast and efficient API with FastAPI
|
|
- SQLite database with SQLAlchemy ORM
|
|
- Database migrations with Alembic
|
|
- Pydantic schemas for validation
|
|
- Health check endpoint
|
|
- Full CRUD operations for items
|
|
- OpenAPI documentation
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
.
|
|
├── app # Application package
|
|
│ ├── database.py # Database configuration
|
|
│ ├── models # SQLAlchemy models
|
|
│ ├── routes # API routes and endpoints
|
|
│ └── schemas # Pydantic schemas
|
|
├── migrations # Alembic migrations
|
|
├── alembic.ini # Alembic configuration
|
|
├── main.py # Application entry point
|
|
└── requirements.txt # Project dependencies
|
|
```
|
|
|
|
## API Endpoints
|
|
|
|
- `GET /health` - Health check endpoint
|
|
- `GET /api/v1/items` - List all items
|
|
- `GET /api/v1/items/{item_id}` - Get a specific item
|
|
- `POST /api/v1/items` - Create a new item
|
|
- `PUT /api/v1/items/{item_id}` - Update an item
|
|
- `DELETE /api/v1/items/{item_id}` - Delete an item
|
|
|
|
## API Documentation
|
|
|
|
Once the application is running, you can access the API documentation:
|
|
|
|
- Swagger UI - `/docs`
|
|
- ReDoc - `/redoc`
|
|
|
|
## Development
|
|
|
|
### Requirements
|
|
|
|
- Python 3.8+
|
|
- SQLite
|
|
|
|
### Setup
|
|
|
|
1. Install dependencies:
|
|
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
2. Run the application:
|
|
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
The API will be available at http://localhost:8000. |