# Small Business Inventory Management System A comprehensive inventory management system for small businesses built with FastAPI and SQLite. ## Features - **Product Management**: Create, update, delete, and search products with SKU, barcode support - **Inventory Tracking**: Track inventory levels across multiple locations - **Purchase Order Management**: Create purchase orders and receive inventory - **Sales Tracking**: Record sales and automatically update inventory - **User Authentication**: Secure API with JWT authentication - **Role-Based Access Control**: Admin and regular user roles - **Reporting**: Several reports including inventory value, low stock, sales summary, and purchase summary ## Technologies - **Backend**: FastAPI (Python 3.9+) - **Database**: SQLite with SQLAlchemy ORM - **Authentication**: JWT tokens with OAuth2 - **Migration**: Alembic for database migrations - **Validation**: Pydantic for data validation - **Linting**: Ruff for code quality ## Setup and Installation 1. Clone the repository 2. Install dependencies: ``` pip install -r requirements.txt ``` 3. Run the database migrations: ``` alembic upgrade head ``` 4. Start the application: ``` python run.py ``` The API will be available at http://localhost:8000 ## API Documentation Once the application is running, you can access: - Interactive API documentation: http://localhost:8000/docs - Alternative API documentation: http://localhost:8000/redoc ## Default Admin User The system comes with a default admin user: - Email: admin@example.com - Password: admin123 **Important**: Change the default password after first login! ## Directory Structure ``` ├── app # Application source code │ ├── api # API endpoints │ ├── core # Core functionality │ ├── crud # CRUD operations │ ├── db # Database setup │ ├── models # SQLAlchemy models │ └── schemas # Pydantic schemas ├── migrations # Alembic migrations ├── alembic.ini # Alembic configuration ├── main.py # Application entry point ├── pyproject.toml # Project configuration ├── README.md # Project documentation ├── requirements.txt # Dependencies └── run.py # Script to run the application ``` ## API Endpoints The API provides the following main endpoints: ### Authentication - `POST /api/v1/login/access-token` - Login and get access token - `POST /api/v1/login/test-token` - Test access token validity ### Users - `GET /api/v1/users/` - List users (admin only) - `POST /api/v1/users/` - Create user (admin only) - `GET /api/v1/users/me` - Get current user - `PUT /api/v1/users/me` - Update current user ### Products - `GET /api/v1/products/` - List products - `POST /api/v1/products/` - Create product - `GET /api/v1/products/{id}` - Get product - `PUT /api/v1/products/{id}` - Update product - `DELETE /api/v1/products/{id}` - Delete product ### Inventory - `GET /api/v1/inventory/` - List inventory - `POST /api/v1/inventory/` - Create inventory - `POST /api/v1/inventory/adjust` - Adjust inventory ### Purchase Orders - `GET /api/v1/purchase-orders/` - List purchase orders - `POST /api/v1/purchase-orders/` - Create purchase order - `POST /api/v1/purchase-orders/{id}/receive` - Receive purchase order ### Sales - `GET /api/v1/sales/` - List sales - `POST /api/v1/sales/` - Create sale - `POST /api/v1/sales/{id}/cancel` - Cancel sale ### Reports - `GET /api/v1/reports/inventory-value` - Inventory value report - `GET /api/v1/reports/low-stock` - Low stock report - `GET /api/v1/reports/sales-summary` - Sales summary report - `GET /api/v1/reports/purchases-summary` - Purchases summary report - `GET /api/v1/reports/inventory-movements` - Inventory movements report