
- Set up FastAPI application with CORS and health check endpoint - Create SQLite database models for inventory items, categories, and suppliers - Implement complete CRUD API endpoints for all entities - Add low-stock monitoring functionality - Configure Alembic for database migrations - Set up Ruff for code linting and formatting - Include comprehensive API documentation and README
Small Business Inventory System
A comprehensive FastAPI-based inventory management system designed for small businesses.
Features
- Inventory Management: Full CRUD operations for inventory items
- Category Management: Organize products by categories
- Supplier Management: Track supplier information and relationships
- Stock Monitoring: Automated low-stock alerts
- RESTful API: Complete API with automatic documentation
- SQLite Database: Lightweight database with migration support
API Endpoints
Inventory Items
GET /api/v1/inventory/
- List all inventory itemsPOST /api/v1/inventory/
- Create new inventory itemGET /api/v1/inventory/{item_id}
- Get specific inventory itemPUT /api/v1/inventory/{item_id}
- Update inventory itemDELETE /api/v1/inventory/{item_id}
- Delete inventory itemGET /api/v1/inventory/low-stock/
- Get low stock items
Categories
GET /api/v1/categories/
- List all categoriesPOST /api/v1/categories/
- Create new categoryGET /api/v1/categories/{category_id}
- Get specific categoryPUT /api/v1/categories/{category_id}
- Update categoryDELETE /api/v1/categories/{category_id}
- Delete category
Suppliers
GET /api/v1/suppliers/
- List all suppliersPOST /api/v1/suppliers/
- Create new supplierGET /api/v1/suppliers/{supplier_id}
- Get specific supplierPUT /api/v1/suppliers/{supplier_id}
- Update supplierDELETE /api/v1/suppliers/{supplier_id}
- Delete supplier
System
GET /
- API information and documentation linksGET /health
- Health check endpointGET /docs
- Interactive API documentation (Swagger UI)GET /redoc
- Alternative API documentation
Installation
- Install dependencies:
pip install -r requirements.txt
- Run database migrations:
alembic upgrade head
- Start the server:
uvicorn main:app --host 0.0.0.0 --port 8000
Development
Linting
ruff check --fix .
Database Migrations
- Create new migration:
alembic revision --autogenerate -m "description"
- Apply migrations:
alembic upgrade head
- Rollback migration:
alembic downgrade -1
Database Schema
InventoryItem
id
: Primary keyname
: Product namesku
: Unique stock keeping unitdescription
: Product descriptionquantity
: Current stock quantityunit_price
: Price per unitminimum_stock
: Minimum stock level for alertscategory_id
: Foreign key to Categorysupplier_id
: Foreign key to Suppliercreated_at
: Creation timestampupdated_at
: Last update timestamp
Category
id
: Primary keyname
: Category name (unique)description
: Category descriptioncreated_at
: Creation timestamp
Supplier
id
: Primary keyname
: Supplier name (unique)contact_person
: Contact person nameemail
: Contact emailphone
: Contact phone numberaddress
: Supplier addresscreated_at
: Creation timestamp
Configuration
The application uses SQLite database stored at /app/storage/db/db.sqlite
.
API Documentation
Once the server is running, visit:
- http://localhost:8000/docs for Swagger UI documentation
- http://localhost:8000/redoc for ReDoc documentation
- http://localhost:8000/openapi.json for OpenAPI schema
Description
Languages
Python
97.1%
Mako
2.9%