
- Set up FastAPI application with CORS and health check endpoint - Create SQLite database models for inventory items, categories, and suppliers - Implement complete CRUD API endpoints for all entities - Add low-stock monitoring functionality - Configure Alembic for database migrations - Set up Ruff for code linting and formatting - Include comprehensive API documentation and README
113 lines
3.2 KiB
Markdown
113 lines
3.2 KiB
Markdown
# Small Business Inventory System
|
|
|
|
A comprehensive FastAPI-based inventory management system designed for small businesses.
|
|
|
|
## Features
|
|
|
|
- **Inventory Management**: Full CRUD operations for inventory items
|
|
- **Category Management**: Organize products by categories
|
|
- **Supplier Management**: Track supplier information and relationships
|
|
- **Stock Monitoring**: Automated low-stock alerts
|
|
- **RESTful API**: Complete API with automatic documentation
|
|
- **SQLite Database**: Lightweight database with migration support
|
|
|
|
## API Endpoints
|
|
|
|
### Inventory Items
|
|
- `GET /api/v1/inventory/` - List all inventory items
|
|
- `POST /api/v1/inventory/` - Create new inventory item
|
|
- `GET /api/v1/inventory/{item_id}` - Get specific inventory item
|
|
- `PUT /api/v1/inventory/{item_id}` - Update inventory item
|
|
- `DELETE /api/v1/inventory/{item_id}` - Delete inventory item
|
|
- `GET /api/v1/inventory/low-stock/` - Get low stock items
|
|
|
|
### Categories
|
|
- `GET /api/v1/categories/` - List all categories
|
|
- `POST /api/v1/categories/` - Create new category
|
|
- `GET /api/v1/categories/{category_id}` - Get specific category
|
|
- `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 specific supplier
|
|
- `PUT /api/v1/suppliers/{supplier_id}` - Update supplier
|
|
- `DELETE /api/v1/suppliers/{supplier_id}` - Delete supplier
|
|
|
|
### System
|
|
- `GET /` - API information and documentation links
|
|
- `GET /health` - Health check endpoint
|
|
- `GET /docs` - Interactive API documentation (Swagger UI)
|
|
- `GET /redoc` - Alternative API documentation
|
|
|
|
## 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
|
|
```
|
|
|
|
## Development
|
|
|
|
### Linting
|
|
```bash
|
|
ruff check --fix .
|
|
```
|
|
|
|
### Database Migrations
|
|
- Create new migration: `alembic revision --autogenerate -m "description"`
|
|
- Apply migrations: `alembic upgrade head`
|
|
- Rollback migration: `alembic downgrade -1`
|
|
|
|
## Database Schema
|
|
|
|
### InventoryItem
|
|
- `id`: Primary key
|
|
- `name`: Product name
|
|
- `sku`: Unique stock keeping unit
|
|
- `description`: Product description
|
|
- `quantity`: Current stock quantity
|
|
- `unit_price`: Price per unit
|
|
- `minimum_stock`: Minimum stock level for alerts
|
|
- `category_id`: Foreign key to Category
|
|
- `supplier_id`: Foreign key to Supplier
|
|
- `created_at`: Creation timestamp
|
|
- `updated_at`: Last update timestamp
|
|
|
|
### Category
|
|
- `id`: Primary key
|
|
- `name`: Category name (unique)
|
|
- `description`: Category description
|
|
- `created_at`: Creation timestamp
|
|
|
|
### Supplier
|
|
- `id`: Primary key
|
|
- `name`: Supplier name (unique)
|
|
- `contact_person`: Contact person name
|
|
- `email`: Contact email
|
|
- `phone`: Contact phone number
|
|
- `address`: Supplier address
|
|
- `created_at`: Creation timestamp
|
|
|
|
## Configuration
|
|
|
|
The application uses SQLite database stored at `/app/storage/db/db.sqlite`.
|
|
|
|
## API Documentation
|
|
|
|
Once the server is running, visit:
|
|
- http://localhost:8000/docs for Swagger UI documentation
|
|
- http://localhost:8000/redoc for ReDoc documentation
|
|
- http://localhost:8000/openapi.json for OpenAPI schema
|