
- Created complete RESTful API for inventory management - Set up database models for items, categories, suppliers, and transactions - Implemented user authentication with JWT tokens - Added transaction tracking for inventory movements - Created comprehensive API endpoints for all CRUD operations - Set up Alembic for database migrations - Added input validation and error handling - Created detailed documentation in README
135 lines
4.0 KiB
Markdown
135 lines
4.0 KiB
Markdown
# Small Business Inventory Management System
|
|
|
|
A RESTful API built with FastAPI and SQLite to help small businesses manage their inventory, track stock levels, and handle inventory transactions.
|
|
|
|
## Features
|
|
|
|
- User authentication with JWT tokens
|
|
- Inventory items management with categories and suppliers
|
|
- Stock level monitoring and low-stock alerts
|
|
- Transaction tracking (purchases, sales, adjustments, returns)
|
|
- Comprehensive reporting endpoints
|
|
- Role-based access control
|
|
|
|
## Technology Stack
|
|
|
|
- **Framework**: FastAPI
|
|
- **Database**: SQLite with SQLAlchemy ORM
|
|
- **Migrations**: Alembic
|
|
- **Authentication**: JWT tokens with password hashing
|
|
- **Validation**: Pydantic
|
|
- **Code Quality**: Ruff
|
|
|
|
## Getting Started
|
|
|
|
### Prerequisites
|
|
|
|
- Python 3.8+
|
|
- Virtual environment (recommended)
|
|
|
|
### Installation
|
|
|
|
1. Clone the repository:
|
|
```bash
|
|
git clone <repository-url>
|
|
cd smallbusinessinventorymanagementsystem
|
|
```
|
|
|
|
2. Create and activate a virtual environment:
|
|
```bash
|
|
python -m venv venv
|
|
source venv/bin/activate # On Windows, use: venv\Scripts\activate
|
|
```
|
|
|
|
3. Install dependencies:
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
4. Set up environment variables:
|
|
```bash
|
|
export SECRET_KEY="your-secret-key-here" # For production, use a strong random key
|
|
```
|
|
|
|
5. Run database migrations:
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
6. Start the application:
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
The API will be available at http://localhost:8000. The interactive API documentation is available at http://localhost:8000/docs.
|
|
|
|
## API Endpoints
|
|
|
|
### Authentication
|
|
- `POST /api/v1/login/access-token` - Get an access token
|
|
- `POST /api/v1/login/test-token` - Test an access token
|
|
|
|
### Users
|
|
- `GET /api/v1/users/` - Get all users (admin only)
|
|
- `POST /api/v1/users/` - Create a new 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 a specific user
|
|
- `PUT /api/v1/users/{user_id}` - Update a specific user (admin only)
|
|
|
|
### Items
|
|
- `GET /api/v1/items/` - Get all items
|
|
- `POST /api/v1/items/` - Create a new item
|
|
- `GET /api/v1/items/{id}` - Get an item by ID
|
|
- `PUT /api/v1/items/{id}` - Update an item
|
|
- `DELETE /api/v1/items/{id}` - Delete an item
|
|
- `GET /api/v1/items/by-category/{category_id}` - Get items by category
|
|
- `GET /api/v1/items/by-supplier/{supplier_id}` - Get items by supplier
|
|
- `GET /api/v1/items/low-stock/` - Get items with low stock
|
|
|
|
### Categories
|
|
- `GET /api/v1/categories/` - Get all categories
|
|
- `POST /api/v1/categories/` - Create a new category
|
|
- `GET /api/v1/categories/{id}` - Get a category by ID
|
|
- `PUT /api/v1/categories/{id}` - Update a category
|
|
- `DELETE /api/v1/categories/{id}` - Delete a category
|
|
|
|
### Suppliers
|
|
- `GET /api/v1/suppliers/` - Get all suppliers
|
|
- `POST /api/v1/suppliers/` - Create a new supplier
|
|
- `GET /api/v1/suppliers/{id}` - Get a supplier by ID
|
|
- `PUT /api/v1/suppliers/{id}` - Update a supplier
|
|
- `DELETE /api/v1/suppliers/{id}` - Delete a supplier
|
|
|
|
### Transactions
|
|
- `GET /api/v1/transactions/` - Get all transactions
|
|
- `POST /api/v1/transactions/` - Create a new transaction
|
|
- `GET /api/v1/transactions/{id}` - Get a transaction by ID
|
|
- `GET /api/v1/transactions/by-item/{item_id}` - Get transactions by item
|
|
- `GET /api/v1/transactions/by-user/{user_id}` - Get transactions by user (admin only)
|
|
- `GET /api/v1/transactions/by-type/{transaction_type}` - Get transactions by type
|
|
- `GET /api/v1/transactions/by-date-range/` - Get transactions by date range
|
|
|
|
## Environment Variables
|
|
|
|
| Variable | Description | Default Value |
|
|
|----------|-------------|---------------|
|
|
| SECRET_KEY | Key used for JWT token generation | "your-secret-key-here-make-sure-to-change-in-production" |
|
|
| ACCESS_TOKEN_EXPIRE_MINUTES | Token expiration time in minutes | 11520 (8 days) |
|
|
|
|
## Development
|
|
|
|
### Running Tests
|
|
```bash
|
|
pytest
|
|
```
|
|
|
|
### Linting with Ruff
|
|
```bash
|
|
ruff check .
|
|
ruff format .
|
|
```
|
|
|
|
## License
|
|
|
|
This project is licensed under the MIT License - see the LICENSE file for details. |