Automated Action 0e00013b7f Implement product catalog API with CRUD operations
- Created FastAPI application with product catalog functionality
- Implemented CRUD operations for products
- Added SQLAlchemy models and Pydantic schemas
- Set up SQLite database with Alembic migrations
- Added health check endpoint
- Updated README with project documentation

generated with BackendIM... (backend.im)
2025-05-13 17:21:00 +00:00

2.2 KiB

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

  1. Clone the repository

  2. 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:

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 product
  • GET /products/{product_id} - Get a specific product
  • PUT /products/{product_id} - Update a product
  • DELETE /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