Automated Action 252ce19872 Implement complete small business inventory management system
Features include:
- User management with JWT authentication and role-based access
- Inventory items with SKU/barcode tracking and stock management
- Categories and suppliers organization
- Inventory transactions with automatic stock updates
- Low stock alerts and advanced search/filtering
- RESTful API with comprehensive CRUD operations
- SQLite database with Alembic migrations
- Auto-generated API documentation

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-21 16:10:33 +00:00

4.2 KiB

Small Business Inventory System

A comprehensive inventory management system for small businesses built with Python and FastAPI.

Features

  • User Management: Secure authentication with JWT tokens and role-based access control
  • Inventory Management: Complete CRUD operations for inventory items with SKU and barcode support
  • Category Management: Organize inventory items by categories
  • Supplier Management: Track supplier information and relationships
  • Stock Tracking: Real-time stock levels with low stock alerts
  • Transaction History: Track all inventory movements (in/out/adjustments)
  • Search & Filter: Advanced search and filtering capabilities
  • RESTful API: Well-documented API endpoints with automatic OpenAPI documentation

Tech Stack

  • Framework: FastAPI
  • Database: SQLite with SQLAlchemy ORM
  • Authentication: JWT tokens with bcrypt password hashing
  • Migrations: Alembic for database schema management
  • Documentation: Automatic API documentation with Swagger UI

Installation & Setup

  1. Install dependencies:

    pip install -r requirements.txt
    
  2. Set up environment variables (optional):

    export SECRET_KEY="your-secret-key-here"
    export ADMIN_EMAIL="admin@yourcompany.com"
    export ADMIN_PASSWORD="secure-admin-password"
    
  3. Run the application:

    uvicorn main:app --host 0.0.0.0 --port 8000 --reload
    

Environment Variables

The following environment variables can be set:

  • SECRET_KEY: JWT secret key (defaults to development key - change in production!)
  • ADMIN_EMAIL: Initial admin user email (default: admin@example.com)
  • ADMIN_PASSWORD: Initial admin user password (default: admin123)

⚠️ Important: Change the SECRET_KEY, ADMIN_EMAIL, and ADMIN_PASSWORD environment variables in production!

API Documentation

Once the application is running, you can access:

API Endpoints

Authentication

  • POST /api/v1/auth/login - Login and get access token

Users

  • GET /api/v1/users/me - Get current user info
  • GET /api/v1/users/ - List all users (admin only)
  • POST /api/v1/users/ - Create new user (admin only)

Categories

  • GET /api/v1/categories/ - List all categories
  • POST /api/v1/categories/ - Create new category
  • PUT /api/v1/categories/{id} - Update category
  • DELETE /api/v1/categories/{id} - Delete category

Suppliers

  • GET /api/v1/suppliers/ - List all suppliers
  • POST /api/v1/suppliers/ - Create new supplier
  • PUT /api/v1/suppliers/{id} - Update supplier
  • DELETE /api/v1/suppliers/{id} - Delete supplier

Inventory

  • GET /api/v1/inventory/ - List inventory items (with search/filter options)
  • GET /api/v1/inventory/low-stock - Get low stock items
  • POST /api/v1/inventory/ - Create new inventory item
  • GET /api/v1/inventory/{id} - Get inventory item by ID
  • GET /api/v1/inventory/sku/{sku} - Get inventory item by SKU
  • PUT /api/v1/inventory/{id} - Update inventory item
  • DELETE /api/v1/inventory/{id} - Delete inventory item

Transactions

  • GET /api/v1/transactions/ - List inventory transactions
  • POST /api/v1/transactions/ - Create new transaction (updates stock levels)
  • GET /api/v1/transactions/{id} - Get transaction by ID

Database Schema

The system uses SQLite with the following main entities:

  • Users: System users with authentication
  • Categories: Item categories for organization
  • Suppliers: Supplier information and contacts
  • InventoryItems: Main inventory items with pricing and stock info
  • InventoryTransactions: Track all stock movements

Development

  • Linting: The project uses Ruff for code linting and formatting
  • Database: SQLite database stored in /app/storage/db/
  • Migrations: Use Alembic for database schema changes

Default Admin User

The system creates a default admin user on first run:

  • Email: admin@example.com (or value from ADMIN_EMAIL env var)
  • Password: admin123 (or value from ADMIN_PASSWORD env var)

⚠️ Security Note: Change the default admin credentials immediately in production!