1.9 KiB
1.9 KiB
FastAPI REST API Service
A REST API service built with FastAPI and SQLite for managing items.
Features
- RESTful API with CRUD operations for items
- SQLite database with SQLAlchemy ORM
- Alembic for database migrations
- Pydantic for data validation
- API documentation with Swagger UI and ReDoc
- Health check endpoint
- CORS middleware
Project Structure
├── app
│ ├── api
│ │ ├── api.py
│ │ ├── deps.py
│ │ └── endpoints
│ │ ├── items.py
│ ├── core
│ ├── crud
│ │ ├── base.py
│ │ └── crud_item.py
│ ├── db
│ │ └── database.py
│ ├── models
│ │ ├── base.py
│ │ └── item.py
│ └── schemas
│ └── item.py
├── migrations
│ └── versions
│ └── 7e4c6a11c9d7_create_items_table.py
├── alembic.ini
├── main.py
└── requirements.txt
Setup and Installation
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
- Run the application:
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
API Endpoints
Health Check
GET /health
Returns the health status of the API.
Items API
GET /api/v1/items
POST /api/v1/items
GET /api/v1/items/{id}
PUT /api/v1/items/{id}
DELETE /api/v1/items/{id}
API Documentation
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Database
The application uses SQLite as the database. The database file is stored at /app/storage/db/db.sqlite
.
Database Migrations
Migrations are managed with Alembic. The initial migration for creating the items table is already included.
License
This project is licensed under the MIT License.