# 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 1. Clone the repository: ``` git clone cd small-business-inventory-management-system ``` 2. Install dependencies: ``` pip install -r requirements.txt ``` 3. Run database migrations: ``` alembic upgrade head ``` 4. 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 token - `POST /api/v1/auth/register` - Register new user - `GET /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 item - `GET /api/v1/items/{item_id}` - Get item details - `PUT /api/v1/items/{item_id}` - Update item - `DELETE /api/v1/items/{item_id}` - Delete item - `GET /api/v1/items/search` - Search items by name, SKU, or barcode ### Categories - `GET /api/v1/categories` - List all categories - `POST /api/v1/categories` - Create new category - `GET /api/v1/categories/{category_id}` - Get category details - `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 details - `PUT /api/v1/suppliers/{supplier_id}` - Update supplier - `DELETE /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 details - `PUT /api/v1/transactions/{transaction_id}` - Update transaction metadata - `GET /api/v1/transactions/by-item/{item_id}` - Get item transactions - `GET /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 ```