
generated with BackendIM... (backend.im)
Product Catalog API
A simple product catalog API with CRUD operations built with FastAPI and SQLite.
Features
- Product management with CRUD operations
- Product filtering by category
- Health check endpoint
- Database migrations using Alembic
- SQLite database for data storage
Project Structure
.
├── app
│ ├── api
│ │ ├── api.py # API router configuration
│ │ ├── health.py # Health check endpoint
│ │ └── products.py # Product endpoints
│ ├── crud
│ │ └── product.py # CRUD operations for products
│ ├── db
│ │ └── database.py # Database configuration and session
│ ├── models
│ │ └── product.py # SQLAlchemy models
│ └── schemas
│ ├── health.py # Pydantic schemas for health check
│ └── product.py # Pydantic schemas for products
├── migrations # Alembic migration files
│ ├── env.py
│ ├── script.py.mako
│ └── versions
│ └── initial_products_table.py
├── alembic.ini # Alembic configuration
├── main.py # Application entry point
└── requirements.txt # Project dependencies
Installation
-
Clone the repository
-
Install dependencies:
pip install -r requirements.txt
Running the Application
uvicorn main:app --reload
The API will be available at http://localhost:8000.
API documentation is available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
Health Check
GET /health
- Get API health status
Products
GET /products
- Get all products (with optional category filter)POST /products
- Create a new productGET /products/{product_id}
- Get a specific productPUT /products/{product_id}
- Update a productDELETE /products/{product_id}
- Delete a product
Database
The application uses SQLite as database, stored at /app/storage/db/db.sqlite
.
Database Migrations
Migrations are managed with Alembic.
# Apply migrations
alembic upgrade head
Description
Languages
Python
96.2%
Mako
3.8%