# Small Business Inventory Management System A RESTful API for small business inventory management built with FastAPI and SQLite. ## Features - **User Authentication**: Secure login and role-based access control - **Product Management**: Add, update, and remove products with detailed information - **Category and Supplier Management**: Organize products by categories and suppliers - **Inventory Tracking**: Monitor stock levels and receive alerts for low stock - **Stock Movement Tracking**: Record purchases, sales, returns, and inventory adjustments - **Search Functionality**: Search for products, categories, and suppliers ## Technical Stack - **Backend**: FastAPI (Python) - **Database**: SQLite - **ORM**: SQLAlchemy - **Migrations**: Alembic - **Authentication**: JWT (JSON Web Tokens) ## API Endpoints ### Authentication - `POST /api/v1/login/access-token` - Get access token - `POST /api/v1/login/test-token` - Test token validity ### Users - `GET /api/v1/users/` - List all users (admin only) - `POST /api/v1/users/` - Create a new user (admin only) - `GET /api/v1/users/me` - Get current user information - `PUT /api/v1/users/me` - Update current user information - `GET /api/v1/users/{user_id}` - Get specific user information - `PUT /api/v1/users/{user_id}` - Update specific user (admin only) ### Products - `GET /api/v1/products/` - List all products - `POST /api/v1/products/` - Create a new product - `GET /api/v1/products/{product_id}` - Get specific product - `PUT /api/v1/products/{product_id}` - Update specific product - `DELETE /api/v1/products/{product_id}` - Delete specific product (admin only) - `GET /api/v1/products/by-category/{category_id}` - Get products by category - `GET /api/v1/products/by-supplier/{supplier_id}` - Get products by supplier - `GET /api/v1/products/search/` - Search products - `GET /api/v1/products/low-stock/` - Get products with low stock ### Categories - `GET /api/v1/categories/` - List all categories - `POST /api/v1/categories/` - Create a new category - `GET /api/v1/categories/{category_id}` - Get specific category - `PUT /api/v1/categories/{category_id}` - Update specific category - `DELETE /api/v1/categories/{category_id}` - Delete specific category (admin only) - `GET /api/v1/categories/search/` - Search categories ### Suppliers - `GET /api/v1/suppliers/` - List all suppliers - `POST /api/v1/suppliers/` - Create a new supplier - `GET /api/v1/suppliers/{supplier_id}` - Get specific supplier - `PUT /api/v1/suppliers/{supplier_id}` - Update specific supplier - `DELETE /api/v1/suppliers/{supplier_id}` - Delete specific supplier (admin only) - `GET /api/v1/suppliers/search/` - Search suppliers ### Stock Movements - `GET /api/v1/stock-movements/` - List all stock movements - `POST /api/v1/stock-movements/` - Create a new stock movement - `GET /api/v1/stock-movements/{stock_movement_id}` - Get specific stock movement - `GET /api/v1/stock-movements/by-product/{product_id}` - Get stock movements by product - `GET /api/v1/stock-movements/by-type/{movement_type}` - Get stock movements by type ### Health Check - `GET /health` - Check API health status ## Installation and Setup 1. Clone the repository: ```bash git clone cd smallbusinessinventorymanagementsystem ``` 2. Install dependencies: ```bash pip install -r requirements.txt ``` 3. Run the application: ```bash uvicorn main:app --reload ``` 4. Access the API documentation: - Swagger UI: http://localhost:8000/docs - ReDoc: http://localhost:8000/redoc ## Database Migrations Initialize and apply database migrations: ```bash alembic upgrade head ``` ## Creating a Superuser To create an admin user, use the following API endpoint: ``` POST /api/v1/users/ ``` With the payload: ```json { "email": "admin@example.com", "username": "admin", "password": "your-secure-password", "is_superuser": true } ``` ## License This project is licensed under the MIT License - see the LICENSE file for details.