
- Update models/__init__.py to properly export model classes - Fix the AttributeError when referencing models.User in app/api/deps.py - Ensure proper re-exports to satisfy linting requirements
Small Business Inventory Management System
A comprehensive inventory management system designed for small businesses built with FastAPI and SQLite.
Features
- Product Management: Create, update, and track products with SKU, barcode, price, cost, and more
- Category Organization: Organize products into categories for easier management
- Supplier Management: Track product suppliers with contact information
- Inventory Tracking: Monitor stock levels across your business
- Transaction History: Keep a complete history of inventory movements (purchases, sales, returns, etc.)
- Low Stock Alerts: Easily identify products that need to be reordered
- User Authentication: Secure API with JWT-based authentication and role-based permissions
Installation
Prerequisites
- Python 3.8 or higher
- pip (Python package manager)
Setup
- Clone the repository:
git clone <repository-url>
cd small-business-inventory-management-system
- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Set up environment variables:
# For development
export SECRET_KEY="your-super-secret-key-here" # On Windows: set SECRET_KEY=your-super-secret-key-here
- Run database migrations:
alembic upgrade head
- Create a superuser:
python -m app.initial_data # Script not included in this version, create manually via API
Running the Application
Start the server with:
uvicorn main:app --reload --host 0.0.0.0 --port 8000
The API will be available at http://localhost:8000/
API documentation is available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
Authentication
POST /api/v1/login/access-token
- Get access token (login)POST /api/v1/login/test-token
- Test token validity
Users
GET /api/v1/users/
- List users (admin only)POST /api/v1/users/
- Create user (admin only)GET /api/v1/users/me
- Get current userPUT /api/v1/users/me
- Update current userGET /api/v1/users/{user_id}
- Get user by IDPUT /api/v1/users/{user_id}
- Update user by ID (admin only)
Categories
GET /api/v1/categories/
- List categoriesPOST /api/v1/categories/
- Create categoryGET /api/v1/categories/{id}
- Get category by IDPUT /api/v1/categories/{id}
- Update categoryDELETE /api/v1/categories/{id}
- Delete category
Suppliers
GET /api/v1/suppliers/
- List suppliersPOST /api/v1/suppliers/
- Create supplierGET /api/v1/suppliers/{id}
- Get supplier by IDPUT /api/v1/suppliers/{id}
- Update supplierDELETE /api/v1/suppliers/{id}
- Delete supplier
Products
GET /api/v1/products/
- List products (with optional filtering)POST /api/v1/products/
- Create productGET /api/v1/products/{id}
- Get product by IDGET /api/v1/products/sku/{sku}
- Get product by SKUGET /api/v1/products/barcode/{barcode}
- Get product by barcodePUT /api/v1/products/{id}
- Update productDELETE /api/v1/products/{id}
- Delete product
Inventory
GET /api/v1/inventory/
- List inventory itemsGET /api/v1/inventory/product/{product_id}
- Get inventory by product IDGET /api/v1/inventory/low-stock
- Get products with low stockGET /api/v1/inventory/summary
- Get inventory summaryPUT /api/v1/inventory/adjust/{product_id}
- Adjust inventory for a product
Inventory Transactions
POST /api/v1/inventory/transactions/
- Create inventory transactionGET /api/v1/inventory/transactions/
- List transactions (with optional filtering)GET /api/v1/inventory/transactions/{transaction_id}
- Get transaction by ID
Environment Variables
The application uses the following environment variables:
SECRET_KEY
- Secret key for JWT token generation and validation (default: "your-secret-key-here-replace-in-production")ACCESS_TOKEN_EXPIRE_MINUTES
- JWT token expiration time in minutes (default: 30)
Database Structure
The application uses SQLite as the database, stored in /app/storage/db/db.sqlite
. The database schema includes:
- User: Authentication and system users
- Category: Product categories
- Supplier: Product suppliers
- Product: Product information
- Inventory: Current stock levels
- InventoryTransaction: History of inventory movements
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature-name
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin feature-name
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Description
Languages
Python
99.1%
Mako
0.9%