
Features implemented: - Product management with CRUD operations - Category and supplier management - Stock movement tracking with automatic updates - Inventory reports and analytics - SQLite database with Alembic migrations - Health monitoring endpoints - CORS configuration for API access - Comprehensive API documentation - Code quality with Ruff linting and formatting The system provides a complete backend solution for small business inventory management with proper database relationships, stock tracking, and reporting capabilities.
3.7 KiB
3.7 KiB
Small Business Inventory System
A comprehensive FastAPI-based inventory management system designed for small businesses to track products, manage stock levels, and generate reports.
Features
- Product Management: Create, update, delete, and view products with detailed information
- Category Management: Organize products into categories
- Supplier Management: Track supplier information and relationships
- Stock Management: Add/remove stock with automatic movement tracking
- Inventory Reports: Get insights into stock levels, low stock alerts, and movement summaries
- Health Monitoring: Built-in health check endpoints
- API Documentation: Auto-generated OpenAPI/Swagger documentation
Tech Stack
- Backend: FastAPI (Python)
- Database: SQLite with SQLAlchemy ORM
- Migrations: Alembic
- Code Quality: Ruff (linting and formatting)
- Server: Uvicorn
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
API Endpoints
Root & Health
GET /
- API information and linksGET /health
- Health check endpoint
Products
GET /api/v1/products/
- List all products (with filtering)GET /api/v1/products/{id}
- Get product by IDPOST /api/v1/products/
- Create new productPUT /api/v1/products/{id}
- Update productDELETE /api/v1/products/{id}
- Delete productPOST /api/v1/products/{id}/stock/add
- Add stockPOST /api/v1/products/{id}/stock/remove
- Remove stock
Categories
GET /api/v1/categories/
- List all categoriesGET /api/v1/categories/{id}
- Get category by IDPOST /api/v1/categories/
- Create new categoryPUT /api/v1/categories/{id}
- Update categoryDELETE /api/v1/categories/{id}
- Delete category
Suppliers
GET /api/v1/suppliers/
- List all suppliersGET /api/v1/suppliers/{id}
- Get supplier by IDPOST /api/v1/suppliers/
- Create new supplierPUT /api/v1/suppliers/{id}
- Update supplierDELETE /api/v1/suppliers/{id}
- Delete supplier
Stock Movements
GET /api/v1/stock-movements/
- List stock movementsGET /api/v1/stock-movements/{id}
- Get movement by IDPOST /api/v1/stock-movements/
- Create stock movement
Reports
GET /api/v1/reports/inventory-summary
- Overall inventory statisticsGET /api/v1/reports/low-stock
- Products with low stock levelsGET /api/v1/reports/stock-movements-summary
- Stock movement statistics
Documentation
- API Documentation:
/docs
(Swagger UI) - Alternative Docs:
/redoc
(ReDoc) - OpenAPI JSON:
/openapi.json
Database
The application uses SQLite database located at /app/storage/db/db.sqlite
. The database schema includes:
- Categories: Product categories
- Suppliers: Supplier information
- Products: Product details with category and supplier relationships
- Stock Movements: Track all stock changes (IN/OUT/ADJUSTMENT)
Environment Configuration
The application is configured to work with the following directory structure:
- Database:
/app/storage/db/
- Storage:
/app/storage/
(for any file storage needs)
Development
Code Quality
# Lint and fix code
ruff check . --fix
# Format code
ruff format .
Database Migrations
# Create new migration
alembic revision --autogenerate -m "migration message"
# Apply migrations
alembic upgrade head
CORS Configuration
The API is configured with CORS to allow all origins (*
) for development purposes. Adjust this in production as needed.
Health Check
The /health
endpoint provides information about:
- Application status
- Database connectivity
- Storage directory status