
- Updated alembic.ini to use the async SQLite driver\n- Updated alembic env.py to support async operations\n- Created storage directory for database files\n- Added .gitignore to exclude temporary files and databases\n\ngenerated with BackendIM... (backend.im)
Generic REST API Service
A RESTful API service built with FastAPI and SQLite for database storage.
Features
- RESTful API endpoints for CRUD operations on items
- Async SQLAlchemy with SQLite database
- Database migrations with Alembic
- Health check endpoint
- Pydantic schemas for validation
- Comprehensive API documentation
Project Structure
├── alembic/ # Database migration files
├── app/ # Application package
│ ├── api/ # API endpoints and routes
│ ├── db/ # Database connection and utilities
│ ├── models/ # SQLAlchemy ORM models
│ └── schemas/ # Pydantic schemas for validation and serialization
├── main.py # Application entry point
├── requirements.txt # Project dependencies
└── README.md # This file
API Endpoints
GET /health
: Check API health statusGET /api/items
: List all itemsGET /api/items/{item_id}
: Get a specific itemPOST /api/items
: Create a new itemPUT /api/items/{item_id}
: Update an existing itemDELETE /api/items/{item_id}
: Delete an item
Getting Started
-
Install dependencies:
pip install -r requirements.txt
-
Run the application:
uvicorn main:app --reload
-
Access the API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Database Migrations
Database migrations are managed with Alembic:
# Apply migrations
alembic upgrade head
# Create a new migration
alembic revision --autogenerate -m "description"
Description
Languages
Python
95.5%
Mako
4.5%