This is a RESTful API for managing products in an e-commerce platform. It supports retrieving all products, filtering by category, retrieving a product by ID, and creating new products with validation.
- Backend Framework: FastAPI (Python 3.11)
- ORM: SQLAlchemy
- Database: PostgreSQL (via Docker)
- Migrations: Yoyo
- Testing: Pytest, TestClient
- Containerization: Docker, Docker Compose
- CI/CD: GitHub Actions
git clone https://github.com/malikmati90/ecommerce-product-api.git
cd ecommerce-product-apidocker compose up --buildThis will:
- Start the FastAPI app on port
8000 - Start PostgreSQL container
- Run migrations (including mock data)
Once running, visit:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
docker exec -it ecommerce_api pytestThis will run all unit tests inside the container.
curl http://localhost:8000/productscurl "http://localhost:8000/products?category=Apparel"curl http://localhost:8000/products/1curl -X POST http://localhost:8000/products/ \
-H "Content-Type: application/json" \
-d '{"name": "Test Product", "category": "Home", "price": 19.99}'- All API responses are validated using Pydantic
- Category field supports predefined values (dropdown in Swagger)
- Docker handles all dependencies and services for local development