
- Created FastAPI application with SQLite database - Implemented models for inventory items, categories, suppliers, and transactions - Added authentication system with JWT tokens - Implemented CRUD operations for all models - Set up Alembic for database migrations - Added comprehensive API documentation - Configured Ruff for code linting
Small Business Inventory Management System
A robust API-based inventory management system built for small businesses using FastAPI and SQLite. This system helps businesses track inventory items, manage suppliers, categorize products, and record stock movements.
Features
- Item Management: Create, update, delete, and search inventory items
- Category Management: Organize items by categories
- Supplier Management: Track suppliers for inventory items
- Stock Transactions: Record stock-in and stock-out transactions
- User Authentication: Secure API access with JWT authentication
- Low Stock Alerts: Identify items with stock levels below reorder points
- Reporting: Generate transaction reports for specific time periods
Technology Stack
- Backend: Python 3.8+ with FastAPI
- Database: SQLite with SQLAlchemy ORM
- Authentication: JWT tokens with OAuth2
- API Documentation: Swagger UI and ReDoc via OpenAPI
- Migrations: Alembic for database schema versioning
API Documentation
API documentation is available at:
- Swagger UI:
/docs
- ReDoc:
/redoc
Environment Variables
The application uses the following environment variables:
Variable | Description | Default |
---|---|---|
SECRET_KEY | JWT secret key | super-secret-key-for-development-only |
ACCESS_TOKEN_EXPIRE_MINUTES | JWT token expiration time in minutes | 60 |
Installation and Setup
Prerequisites
- Python 3.8 or higher
- pip (Python package manager)
Installation Steps
-
Clone the repository:
git clone <repository-url> cd small-business-inventory-management-system
-
Install dependencies:
pip install -r requirements.txt
-
Run database migrations:
alembic upgrade head
-
Start the application:
uvicorn main:app --reload
The API will be available at http://localhost:8000
API Endpoints
Authentication
POST /api/v1/auth/login
- Obtain JWT tokenPOST /api/v1/auth/register
- Register new userGET /api/v1/auth/me
- Get current user info
Items
GET /api/v1/items
- List all items (with optional filtering)POST /api/v1/items
- Create new itemGET /api/v1/items/{item_id}
- Get item detailsPUT /api/v1/items/{item_id}
- Update itemDELETE /api/v1/items/{item_id}
- Delete itemGET /api/v1/items/search
- Search items by name, SKU, or barcode
Categories
GET /api/v1/categories
- List all categoriesPOST /api/v1/categories
- Create new categoryGET /api/v1/categories/{category_id}
- Get category detailsPUT /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 detailsPUT /api/v1/suppliers/{supplier_id}
- Update supplierDELETE /api/v1/suppliers/{supplier_id}
- Delete supplier
Transactions
GET /api/v1/transactions
- List all transactions (with optional filtering)POST /api/v1/transactions
- Create new transaction (stock in/out)GET /api/v1/transactions/{transaction_id}
- Get transaction detailsPUT /api/v1/transactions/{transaction_id}
- Update transaction metadataGET /api/v1/transactions/by-item/{item_id}
- Get item transactionsGET /api/v1/transactions/report/daily
- Get daily transaction report
Data Models
User
- Username, email, password, full name
- Active status and superuser privileges
Item
- Name, description, SKU, barcode
- Quantity, unit price, reorder level
- Associated category and supplier
Category
- Name and description
Supplier
- Name, contact info (name, email, phone, address)
Transaction
- Associated item and user
- Quantity, unit price, total price
- Transaction type (stock in/out)
- Reference, notes, timestamp
Development
Adding Database Migrations
When you make changes to the database models, generate new migrations with:
alembic revision --autogenerate -m "Description of changes"
Then apply the migrations:
alembic upgrade head
Description
Languages
Python
99.2%
Mako
0.8%