Automated Action a17fe518a9 Implement Small Business Inventory Management System
This commit includes:
- Project structure setup with FastAPI and SQLite
- Database models and schemas for inventory management
- CRUD operations for all entities
- API endpoints for product, category, supplier, and inventory management
- User authentication with JWT tokens
- Initial database migration
- Comprehensive README with setup instructions
2025-06-17 19:02:35 +00:00

161 lines
4.7 KiB
Markdown

# Small Business Inventory Management System
A comprehensive inventory management system designed for small businesses built with FastAPI and SQLite.
## Features
- **Product Management**: Create, update, and track products with SKU, barcode, price, cost, and more
- **Category Organization**: Organize products into categories for easier management
- **Supplier Management**: Track product suppliers with contact information
- **Inventory Tracking**: Monitor stock levels across your business
- **Transaction History**: Keep a complete history of inventory movements (purchases, sales, returns, etc.)
- **Low Stock Alerts**: Easily identify products that need to be reordered
- **User Authentication**: Secure API with JWT-based authentication and role-based permissions
## Installation
### Prerequisites
- Python 3.8 or higher
- pip (Python package manager)
### Setup
1. Clone the repository:
```bash
git clone <repository-url>
cd small-business-inventory-management-system
```
2. Create a virtual environment:
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
3. Install dependencies:
```bash
pip install -r requirements.txt
```
4. Set up environment variables:
```bash
# For development
export SECRET_KEY="your-super-secret-key-here" # On Windows: set SECRET_KEY=your-super-secret-key-here
```
5. Run database migrations:
```bash
alembic upgrade head
```
6. Create a superuser:
```bash
python -m app.initial_data # Script not included in this version, create manually via API
```
## Running the Application
Start the server with:
```bash
uvicorn main:app --reload --host 0.0.0.0 --port 8000
```
The API will be available at http://localhost:8000/
API documentation is available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
## API Endpoints
### Authentication
- `POST /api/v1/login/access-token` - Get access token (login)
- `POST /api/v1/login/test-token` - Test 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
- `GET /api/v1/users/{user_id}` - Get user by ID
- `PUT /api/v1/users/{user_id}` - Update user by ID (admin only)
### Categories
- `GET /api/v1/categories/` - List categories
- `POST /api/v1/categories/` - Create category
- `GET /api/v1/categories/{id}` - Get category by ID
- `PUT /api/v1/categories/{id}` - Update category
- `DELETE /api/v1/categories/{id}` - Delete category
### Suppliers
- `GET /api/v1/suppliers/` - List suppliers
- `POST /api/v1/suppliers/` - Create supplier
- `GET /api/v1/suppliers/{id}` - Get supplier by ID
- `PUT /api/v1/suppliers/{id}` - Update supplier
- `DELETE /api/v1/suppliers/{id}` - Delete supplier
### Products
- `GET /api/v1/products/` - List products (with optional filtering)
- `POST /api/v1/products/` - Create product
- `GET /api/v1/products/{id}` - Get product by ID
- `GET /api/v1/products/sku/{sku}` - Get product by SKU
- `GET /api/v1/products/barcode/{barcode}` - Get product by barcode
- `PUT /api/v1/products/{id}` - Update product
- `DELETE /api/v1/products/{id}` - Delete product
### Inventory
- `GET /api/v1/inventory/` - List inventory items
- `GET /api/v1/inventory/product/{product_id}` - Get inventory by product ID
- `GET /api/v1/inventory/low-stock` - Get products with low stock
- `GET /api/v1/inventory/summary` - Get inventory summary
- `PUT /api/v1/inventory/adjust/{product_id}` - Adjust inventory for a product
### Inventory Transactions
- `POST /api/v1/inventory/transactions/` - Create inventory transaction
- `GET /api/v1/inventory/transactions/` - List transactions (with optional filtering)
- `GET /api/v1/inventory/transactions/{transaction_id}` - Get transaction by ID
## Environment Variables
The application uses the following environment variables:
- `SECRET_KEY` - Secret key for JWT token generation and validation (default: "your-secret-key-here-replace-in-production")
- `ACCESS_TOKEN_EXPIRE_MINUTES` - JWT token expiration time in minutes (default: 30)
## Database Structure
The application uses SQLite as the database, stored in `/app/storage/db/db.sqlite`. The database schema includes:
- **User**: Authentication and system users
- **Category**: Product categories
- **Supplier**: Product suppliers
- **Product**: Product information
- **Inventory**: Current stock levels
- **InventoryTransaction**: History of inventory movements
## Contributing
1. Fork the repository
2. Create a feature branch: `git checkout -b feature-name`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin feature-name`
5. Submit a pull request
## License
This project is licensed under the MIT License - see the LICENSE file for details.