
- Added improved Python path handling in env.py - Added fallback import method for app.models - Ensured database URL consistency generated with BackendIM... (backend.im)
Generic REST API Service
A RESTful API service built with FastAPI and SQLite, providing standard CRUD operations with a clean architecture.
Features
- FastAPI framework for high performance
- SQLite database with SQLAlchemy ORM
- Alembic for database migrations
- RESTful API endpoints
- Input validation with Pydantic
- Error handling
- Health check endpoint
- Interactive API documentation with Swagger
Project Structure
├── alembic/ # Database migrations
│ └── versions/ # Migration scripts
├── app/ # Application code
│ ├── api/ # API endpoints
│ │ ├── endpoints/ # Individual API route handlers
│ │ └── routes.py # API router setup
│ ├── database.py # Database connection setup
│ ├── errors.py # Error handling
│ ├── models.py # SQLAlchemy models
│ └── schemas.py # Pydantic schemas
├── main.py # Application entry point
├── alembic.ini # Alembic configuration
└── requirements.txt # Project dependencies
Installation
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
Usage
Run the application:
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
Health Check
GET /health
- Check API health status
Items
GET /items
- List all items (with optional filtering)POST /items
- Create a new itemGET /items/{item_id}
- Get a specific itemPUT /items/{item_id}
- Update an itemDELETE /items/{item_id}
- Delete an item
Database Management
This project uses Alembic for database migrations:
# Apply migrations
alembic upgrade head
# Create a new migration
alembic revision -m "description"
The SQLite database is stored at /app/storage/db/db.sqlite
.
Description
Languages
Python
96%
Mako
4%