Automated Action 5c826d8908 Fix Pydantic error in config.py
- Add ClassVar type annotation to DB_DIR to fix the Pydantic validation error
- Update Config to model_config for Pydantic v2 compatibility
- Ensure the Settings class properly handles the database directory path
2025-06-10 09:21:05 +00:00
2025-06-10 09:21:05 +00:00
2025-06-05 16:58:14 +00:00
2025-06-05 16:32:38 +00:00
2025-06-05 16:58:14 +00:00
2025-06-05 16:58:14 +00:00
2025-06-05 16:58:14 +00:00
2025-06-05 16:58:14 +00:00
2025-06-05 16:58:14 +00:00

Small Business Inventory Management System

Overview

This project is a comprehensive inventory management system designed for small businesses. It provides a robust REST API for managing products, categories, suppliers, and inventory transactions, along with analytics for business insights.

Features

  • User Authentication: Secure login and user management
  • Product Management: CRUD operations for products with SKU, pricing, and stock levels
  • Category Management: Organize products into categories
  • Supplier Management: Track and manage your suppliers
  • Inventory Transactions: Record purchases, sales, returns, and adjustments
  • Inventory Analytics: Get insights into your inventory performance
  • Stock Alerts: Identify low stock and out-of-stock products

Tech Stack

  • Framework: FastAPI
  • Database: SQLite
  • ORM: SQLAlchemy
  • Authentication: JWT (JSON Web Tokens)
  • Migrations: Alembic

API Endpoints

Authentication

  • POST /api/v1/auth/login - Login to get access token
  • POST /api/v1/auth/test-token - Verify access token

Users

  • GET /api/v1/users/ - List all users (admin only)
  • POST /api/v1/users/ - Create a new user (admin only)
  • GET /api/v1/users/me - Get current user info
  • PUT /api/v1/users/me - Update current user info
  • GET /api/v1/users/{user_id} - Get user by ID
  • PUT /api/v1/users/{user_id} - Update user (admin only)

Categories

  • GET /api/v1/categories/ - List all categories
  • POST /api/v1/categories/ - Create a new category
  • GET /api/v1/categories/{id} - Get category by ID
  • PUT /api/v1/categories/{id} - Update category
  • DELETE /api/v1/categories/{id} - Delete category (admin only)

Suppliers

  • GET /api/v1/suppliers/ - List all suppliers
  • POST /api/v1/suppliers/ - Create a new supplier
  • GET /api/v1/suppliers/{id} - Get supplier by ID
  • PUT /api/v1/suppliers/{id} - Update supplier
  • DELETE /api/v1/suppliers/{id} - Delete supplier (admin only)

Products

  • GET /api/v1/products/ - List all products
  • POST /api/v1/products/ - Create a new product
  • GET /api/v1/products/{id} - Get product by ID
  • PUT /api/v1/products/{id} - Update product
  • DELETE /api/v1/products/{id} - Delete product
  • GET /api/v1/products/by-category/{category_id} - Get products by category
  • GET /api/v1/products/by-supplier/{supplier_id} - Get products by supplier
  • GET /api/v1/products/low-stock - Get low stock products
  • GET /api/v1/products/out-of-stock - Get out of stock products

Inventory Transactions

  • POST /api/v1/inventory-transactions/ - Create a new transaction
  • GET /api/v1/inventory-transactions/ - List all transactions
  • GET /api/v1/inventory-transactions/{id} - Get transaction by ID
  • GET /api/v1/inventory-transactions/by-product/{product_id} - Get transactions by product
  • GET /api/v1/inventory-transactions/by-type/{transaction_type} - Get transactions by type

Analytics

  • GET /api/v1/analytics/inventory-summary - Get inventory summary
  • GET /api/v1/analytics/transaction-history - Get transaction history
  • GET /api/v1/analytics/product-performance - Get product performance
  • GET /api/v1/analytics/category-performance - Get category performance

Installation and Setup

Prerequisites

  • Python 3.8+
  • pip

Setting Up the Environment

  1. Clone the repository:

    git clone <repository-url>
    cd smallbusinessinventorymanagementsystem
    
  2. Install the required packages:

    pip install -r requirements.txt
    
  3. Create a .env file in the root directory (optional):

    SECRET_KEY=your_secret_key_here
    ACCESS_TOKEN_EXPIRE_MINUTES=43200  # 30 days
    

Database Setup

  1. The application uses SQLite by default, stored at /app/storage/db/db.sqlite.

  2. Run the database migrations:

    alembic upgrade head
    

Running the Application

  1. Start the FastAPI server:

    uvicorn main:app --reload
    
  2. Access the API documentation at:

Environment Variables

Variable Description Default
SECRET_KEY Secret key for JWT encoding "CHANGE_ME_IN_PRODUCTION"
ACCESS_TOKEN_EXPIRE_MINUTES Token expiration time in minutes 10080 (7 days)
SQLALCHEMY_DATABASE_URL Database connection URL "sqlite:///app/storage/db/db.sqlite"

Development

Creating a Superuser

To create a superuser account, you can use the API or add a user directly to the database with the is_superuser flag set to True.

Running Tests

pytest

License

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

Description
Project: Small Business Inventory Management System
Readme 60 KiB
Languages
Python 99.3%
Mako 0.7%