Automated Action e8172f2bc2 Implement complete FastAPI inventory management system
- Set up project structure with FastAPI and SQLite
- Created database models for users, categories, suppliers, items, and stock transactions
- Implemented Alembic for database migrations with proper absolute paths
- Built comprehensive CRUD operations for all entities
- Added JWT-based authentication and authorization system
- Created RESTful API endpoints for all inventory operations
- Implemented search, filtering, and low stock alerts
- Added health check endpoint and base URL response
- Configured CORS for all origins
- Set up Ruff for code linting and formatting
- Updated README with comprehensive documentation and usage examples

The system provides complete inventory management functionality for small businesses
including product tracking, supplier management, stock transactions, and reporting.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-18 10:55:22 +00:00
2025-06-18 10:45:49 +00:00

Small Business Inventory Management System

A comprehensive FastAPI-based inventory management system designed for small businesses to track products, manage suppliers, monitor stock levels, and handle inventory transactions.

Features

  • Product Management: Add, update, and track inventory items with detailed information
  • Category Management: Organize products into categories for better organization
  • Supplier Management: Maintain supplier information and relationships
  • Stock Tracking: Real-time stock level monitoring with low stock alerts
  • Transaction History: Complete audit trail of all stock movements
  • Authentication: Secure JWT-based authentication system
  • Search & Filtering: Powerful search capabilities across inventory items
  • RESTful API: Clean, well-documented API endpoints

Technology Stack

  • Framework: FastAPI
  • Database: SQLite with SQLAlchemy ORM
  • Authentication: JWT tokens with PassLib for password hashing
  • Migration: Alembic for database migrations
  • Validation: Pydantic for data validation
  • Documentation: Auto-generated OpenAPI/Swagger documentation

Installation

  1. Install dependencies:
pip install -r requirements.txt
  1. Run database migrations:
alembic upgrade head
  1. Start the application:
uvicorn main:app --host 0.0.0.0 --port 8000 --reload

Environment Variables

The following environment variables can be set to configure the application:

  • SECRET_KEY: JWT secret key (default: "your-secret-key-change-this-in-production")
  • FIRST_SUPERUSER_EMAIL: Admin user email (default: "admin@inventory.com")
  • FIRST_SUPERUSER_PASSWORD: Admin user password (default: "admin123")

Important: Change the default SECRET_KEY and admin credentials in production!

API Documentation

Once the application is running, you can access:

API Endpoints

Authentication

  • POST /auth/login - User login

Categories

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

Suppliers

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

Items

  • GET /items/ - List all items
  • POST /items/ - Create new item
  • GET /items/{id} - Get item by ID
  • PUT /items/{id} - Update item
  • DELETE /items/{id} - Delete item
  • GET /items/search?query={query} - Search items
  • GET /items/low-stock - Get items with low stock
  • GET /items/active - Get active items only

Stock Transactions

  • GET /stock-transactions/ - List all transactions
  • POST /stock-transactions/ - Create new transaction (updates stock automatically)
  • GET /stock-transactions/{id} - Get transaction by ID
  • GET /stock-transactions/item/{item_id} - Get transactions for specific item
  • GET /stock-transactions/type/{type} - Get transactions by type (in/out/adjustment)

System

  • GET / - API information and links
  • GET /health - Health check endpoint

Database Schema

The system uses the following main entities:

  • Users: System users with authentication
  • Categories: Product categories for organization
  • Suppliers: Supplier information and contacts
  • Items: Inventory items with pricing and stock information
  • StockTransactions: Record of all stock movements

Usage Examples

1. Login

curl -X POST "http://localhost:8000/auth/login" \
  -H "Content-Type: application/json" \
  -d '{"email": "admin@inventory.com", "password": "admin123"}'

2. Create a Category

curl -X POST "http://localhost:8000/categories/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "Electronics", "description": "Electronic devices and components"}'

3. Add an Item

curl -X POST "http://localhost:8000/items/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Laptop Computer",
    "description": "High-performance laptop",
    "sku": "LAP001",
    "unit_price": 999.99,
    "cost_price": 750.00,
    "quantity_in_stock": 10,
    "minimum_stock_level": 2,
    "reorder_point": 5,
    "category_id": 1
  }'

4. Record Stock Transaction

curl -X POST "http://localhost:8000/stock-transactions/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "item_id": 1,
    "transaction_type": "out",
    "quantity": 2,
    "reference_number": "SALE001",
    "notes": "Sale to customer"
  }'

Development

Running with Auto-reload

uvicorn main:app --reload

Code Formatting

The project uses Ruff for linting and formatting:

ruff check .
ruff format .

Database Migrations

Create a new migration:

alembic revision --autogenerate -m "Description of changes"

Apply migrations:

alembic upgrade head

Production Deployment

  1. Set secure environment variables
  2. Use a production WSGI server like Gunicorn
  3. Configure proper SSL/TLS certificates
  4. Set up database backups
  5. Configure logging and monitoring

License

This project is open source and available under the MIT License.

Description
Project: Small Business Inventory Management System
Readme 50 KiB
Languages
Python 98.8%
Mako 1.2%