Small Business Inventory Management System

A FastAPI-based inventory management system designed for small businesses. This API provides comprehensive inventory management capabilities including product management, inventory movement tracking, supplier and category organization, user authentication, and reporting.

Features

  • Product Management: Create, update, and delete products with details such as SKU, barcode, price, and stock levels
  • Category & Supplier Management: Organize products by categories and suppliers
  • Inventory Movement Tracking: Track all inventory changes (stock in, stock out, adjustments, returns)
  • User Authentication: Secure API access with JWT-based authentication
  • Reports: Generate inventory insights including low stock alerts, inventory valuation, and movement history
  • Health Monitoring: Monitor API and database health

Tech Stack

  • Framework: FastAPI
  • Database: SQLite with SQLAlchemy ORM
  • Migrations: Alembic
  • Authentication: JWT tokens with OAuth2
  • Validation: Pydantic models

Getting Started

Prerequisites

  • Python 3.8+
  • pip (Python package manager)

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/smallbusinessinventorymanagementsystem.git
    cd smallbusinessinventorymanagementsystem
    
  2. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. Install dependencies:

    pip install -r requirements.txt
    
  4. Initialize the database:

    alembic upgrade head
    
  5. Run the application:

    uvicorn main:app --reload
    

The API will be available at http://localhost:8000

Environment Variables

The application uses the following environment variables:

Variable Description Default
SECRET_KEY Secret key for JWT token generation Random generated key
ACCESS_TOKEN_EXPIRE_MINUTES JWT token expiration time in minutes 11520 (8 days)
DEBUG Enable debug mode False
ENVIRONMENT Environment name (development, production) development

API Documentation

Once the application is running, you can access the interactive API documentation at:

API Endpoints

The API is organized around the following resources:

Authentication

  • POST /api/v1/auth/login/access-token - Get access token
  • POST /api/v1/auth/login/test-token - Test access token

Users

  • GET /api/v1/users - List all users (admin only)
  • POST /api/v1/users - Create new 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 (admin only)
  • PUT /api/v1/users/{user_id} - Update user (admin only)

Products

  • GET /api/v1/products - List all products
  • POST /api/v1/products - Create new product
  • GET /api/v1/products/{product_id} - Get product by ID
  • PUT /api/v1/products/{product_id} - Update product
  • DELETE /api/v1/products/{product_id} - Delete product
  • PATCH /api/v1/products/{product_id}/stock - Update product stock

Categories

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

Suppliers

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

Inventory Movements

  • GET /api/v1/inventory/movements - List inventory movements
  • POST /api/v1/inventory/movements - Create inventory movement
  • GET /api/v1/inventory/movements/{movement_id} - Get movement by ID
  • DELETE /api/v1/inventory/movements/{movement_id} - Delete movement

Reports

  • GET /api/v1/reports/low-stock - Get low stock products
  • GET /api/v1/reports/inventory-value - Get inventory value
  • GET /api/v1/reports/movement-summary - Get movement summary

Health Check

  • GET /api/v1/health - Check API health

Default Admin User

On first run, the system creates a default admin user:

Important: Change the default admin password in production environments.

Development

Running Tests

# TODO: Add test commands

Code Formatting

The project uses Ruff for code formatting and linting:

ruff check .
ruff format .

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.3%
Mako 0.7%