# Small Business Inventory System A comprehensive FastAPI-based inventory management system designed for small businesses to track products, manage stock levels, and generate reports. ## Features - **Product Management**: Create, update, delete, and view products with detailed information - **Category Management**: Organize products into categories - **Supplier Management**: Track supplier information and relationships - **Stock Management**: Add/remove stock with automatic movement tracking - **Inventory Reports**: Get insights into stock levels, low stock alerts, and movement summaries - **Health Monitoring**: Built-in health check endpoints - **API Documentation**: Auto-generated OpenAPI/Swagger documentation ## Tech Stack - **Backend**: FastAPI (Python) - **Database**: SQLite with SQLAlchemy ORM - **Migrations**: Alembic - **Code Quality**: Ruff (linting and formatting) - **Server**: Uvicorn ## Installation 1. Install dependencies: ```bash pip install -r requirements.txt ``` 2. Run database migrations: ```bash alembic upgrade head ``` 3. Start the server: ```bash uvicorn main:app --host 0.0.0.0 --port 8000 ``` ## API Endpoints ### Root & Health - `GET /` - API information and links - `GET /health` - Health check endpoint ### Products - `GET /api/v1/products/` - List all products (with filtering) - `GET /api/v1/products/{id}` - Get product by ID - `POST /api/v1/products/` - Create new product - `PUT /api/v1/products/{id}` - Update product - `DELETE /api/v1/products/{id}` - Delete product - `POST /api/v1/products/{id}/stock/add` - Add stock - `POST /api/v1/products/{id}/stock/remove` - Remove stock ### Categories - `GET /api/v1/categories/` - List all categories - `GET /api/v1/categories/{id}` - Get category by ID - `POST /api/v1/categories/` - Create new category - `PUT /api/v1/categories/{id}` - Update category - `DELETE /api/v1/categories/{id}` - Delete category ### Suppliers - `GET /api/v1/suppliers/` - List all suppliers - `GET /api/v1/suppliers/{id}` - Get supplier by ID - `POST /api/v1/suppliers/` - Create new supplier - `PUT /api/v1/suppliers/{id}` - Update supplier - `DELETE /api/v1/suppliers/{id}` - Delete supplier ### Stock Movements - `GET /api/v1/stock-movements/` - List stock movements - `GET /api/v1/stock-movements/{id}` - Get movement by ID - `POST /api/v1/stock-movements/` - Create stock movement ### Reports - `GET /api/v1/reports/inventory-summary` - Overall inventory statistics - `GET /api/v1/reports/low-stock` - Products with low stock levels - `GET /api/v1/reports/stock-movements-summary` - Stock movement statistics ## Documentation - **API Documentation**: `/docs` (Swagger UI) - **Alternative Docs**: `/redoc` (ReDoc) - **OpenAPI JSON**: `/openapi.json` ## Database The application uses SQLite database located at `/app/storage/db/db.sqlite`. The database schema includes: - **Categories**: Product categories - **Suppliers**: Supplier information - **Products**: Product details with category and supplier relationships - **Stock Movements**: Track all stock changes (IN/OUT/ADJUSTMENT) ## Environment Configuration The application is configured to work with the following directory structure: - Database: `/app/storage/db/` - Storage: `/app/storage/` (for any file storage needs) ## Development ### Code Quality ```bash # Lint and fix code ruff check . --fix # Format code ruff format . ``` ### Database Migrations ```bash # Create new migration alembic revision --autogenerate -m "migration message" # Apply migrations alembic upgrade head ``` ## CORS Configuration The API is configured with CORS to allow all origins (`*`) for development purposes. Adjust this in production as needed. ## Health Check The `/health` endpoint provides information about: - Application status - Database connectivity - Storage directory status