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
-
Clone the repository:
git clone https://github.com/yourusername/smallbusinessinventorymanagementsystem.git cd smallbusinessinventorymanagementsystem
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Initialize the database:
alembic upgrade head
-
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:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
The API is organized around the following resources:
Authentication
POST /api/v1/auth/login/access-token
- Get access tokenPOST /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 userPUT /api/v1/users/me
- Update current userGET /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 productsPOST /api/v1/products
- Create new productGET /api/v1/products/{product_id}
- Get product by IDPUT /api/v1/products/{product_id}
- Update productDELETE /api/v1/products/{product_id}
- Delete productPATCH /api/v1/products/{product_id}/stock
- Update product stock
Categories
GET /api/v1/categories
- List all categoriesPOST /api/v1/categories
- Create new categoryGET /api/v1/categories/{category_id}
- Get category by IDPUT /api/v1/categories/{category_id}
- Update categoryDELETE /api/v1/categories/{category_id}
- Delete category
Suppliers
GET /api/v1/suppliers
- List all suppliersPOST /api/v1/suppliers
- Create new supplierGET /api/v1/suppliers/{supplier_id}
- Get supplier by IDPUT /api/v1/suppliers/{supplier_id}
- Update supplierDELETE /api/v1/suppliers/{supplier_id}
- Delete supplier
Inventory Movements
GET /api/v1/inventory/movements
- List inventory movementsPOST /api/v1/inventory/movements
- Create inventory movementGET /api/v1/inventory/movements/{movement_id}
- Get movement by IDDELETE /api/v1/inventory/movements/{movement_id}
- Delete movement
Reports
GET /api/v1/reports/low-stock
- Get low stock productsGET /api/v1/reports/inventory-value
- Get inventory valueGET /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:
- Email: admin@example.com
- Password: admin
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.