A FastAPI-based API for managing shops, products, inventory, and product variants. This API provides a complete solution for e-commerce applications with geographic features.
- Shop Management: CRUD operations for shops with location data
- Product Management: CRUD operations for products with categorization
- Inventory Management: Track product variants with color and size options
- Category System: Organize products with categories
- Spatial Queries: Find shops within a radius of a point (yet to be done)
- Type-Safe Development: Using SQLAlchemy 2.0 with type annotations
- FastAPI: Modern, fast web framework for building APIs
- SQLAlchemy 2.0: SQL toolkit and ORM with enhanced type safety
- PostgreSQL: Database with JSONB and UUID support
- Pydantic: Data validation and settings management
- Asyncio: Asynchronous I/O for high performance
- Docker: Containerization for easy deployment
- Python 3.13+
- PostgreSQL (test database in container)
- Docker and Docker Compose (optional, for containerized setup)
- Clone the repository
- Set up a virtual environment and install dependencies:
poetry install --no-root
- Activate environment
poetry shell
- Copy
.env.exampleto.envand fill in your configuration values
The API will be available at http://localhost:8000
Interactive API docs are automatically generated using FastAPI:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
GET /api/shops/- List all shopsPOST /api/shops/- Create a new shopGET /api/shops/{shop_id}- Get shop detailsPUT /api/shops/{shop_id}- Update a shopDELETE /api/shops/{shop_id}- Delete a shop
GET /api/products/- List all productsPOST /api/products/- Create a new productGET /api/products/{product_id}- Get product detailsPUT /api/products/{product_id}- Update a productDELETE /api/products/{product_id}- Delete a product
GET /api/inventory/- List all inventory itemsPOST /api/inventory/- Create a new inventory itemGET /api/inventory/{inventory_id}- Get inventory detailsPUT /api/inventory/{inventory_id}- Update an inventory itemDELETE /api/inventory/{inventory_id}- Delete an inventory item
GET /api/categories/- List all categoriesPOST /api/categories/- Create a new categoryGET /api/categories/{category_id}- Get category detailsPUT /api/categories/{category_id}- Update a categoryDELETE /api/categories/{category_id}- Delete a category
GET /api/colors/- List all colorsPOST /api/colors/- Create a new colorGET /api/colors/{color_id}- Get color detailsPUT /api/colors/{color_id}- Update a colorDELETE /api/colors/{color_id}- Delete a color
GET /api/sizes/- List all sizesPOST /api/sizes/- Create a new sizeGET /api/sizes/{size_id}- Get size detailsPUT /api/sizes/{size_id}- Update a sizeDELETE /api/sizes/{size_id}- Delete a size
The API uses SQLAlchemy 2.0 with the following models:
- Shop: Stores shop information including location data
- Product: Stores product information linked to shops
- Category: Provides categorization for products
- Inventory: Manages product variants with different colors and sizes
- Color: Contains color options for product variants
- Size: Contains size options for product variants
To extend the API:
- Define new models in the models directory
- Create corresponding schemas
- Implement CRUD operations
- Create API routes
The application automatically creates database tables on startup