Automated Action 5da770418f Fix email validation dependency issue
- Add email-validator to requirements.txt
- Add fallback email validation for user and supplier schemas
- Implement graceful handling when email-validator is not installed
2025-06-17 19:05:26 +00:00
2025-06-17 19:05:26 +00:00
2025-06-17 18:51:11 +00:00

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

  1. Clone the repository:
git clone <repository-url>
cd small-business-inventory-management-system
  1. Create a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Set up environment variables:
# For development
export SECRET_KEY="your-super-secret-key-here"  # On Windows: set SECRET_KEY=your-super-secret-key-here
  1. Run database migrations:
alembic upgrade head
  1. 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:

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 user
  • PUT /api/v1/users/me - Update current user
  • GET /api/v1/users/{user_id} - Get user by ID
  • PUT /api/v1/users/{user_id} - Update user by ID (admin only)

Categories

  • GET /api/v1/categories/ - List categories
  • POST /api/v1/categories/ - Create category
  • GET /api/v1/categories/{id} - Get category by ID
  • PUT /api/v1/categories/{id} - Update category
  • DELETE /api/v1/categories/{id} - Delete category

Suppliers

  • GET /api/v1/suppliers/ - List suppliers
  • POST /api/v1/suppliers/ - Create supplier
  • GET /api/v1/suppliers/{id} - Get supplier by ID
  • PUT /api/v1/suppliers/{id} - Update supplier
  • DELETE /api/v1/suppliers/{id} - Delete supplier

Products

  • GET /api/v1/products/ - List products (with optional filtering)
  • POST /api/v1/products/ - Create product
  • GET /api/v1/products/{id} - Get product by ID
  • GET /api/v1/products/sku/{sku} - Get product by SKU
  • GET /api/v1/products/barcode/{barcode} - Get product by barcode
  • PUT /api/v1/products/{id} - Update product
  • DELETE /api/v1/products/{id} - Delete product

Inventory

  • GET /api/v1/inventory/ - List inventory items
  • GET /api/v1/inventory/product/{product_id} - Get inventory by product ID
  • GET /api/v1/inventory/low-stock - Get products with low stock
  • GET /api/v1/inventory/summary - Get inventory summary
  • PUT /api/v1/inventory/adjust/{product_id} - Adjust inventory for a product

Inventory Transactions

  • POST /api/v1/inventory/transactions/ - Create inventory transaction
  • GET /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

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin feature-name
  5. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Description
Project: Small Business Inventory Management System
Readme 61 KiB
Languages
Python 99.1%
Mako 0.9%