
- Create project structure with FastAPI and SQLAlchemy - Implement database models for items, categories, suppliers, and stock movements - Add CRUD operations for all models - Configure Alembic for database migrations - Create RESTful API endpoints for inventory management - Add health endpoint for system monitoring - Update README with setup and usage instructions generated with BackendIM... (backend.im)
161 lines
3.4 KiB
Markdown
161 lines
3.4 KiB
Markdown
# Small Business Inventory Management System
|
|
|
|
A RESTful API for managing inventory for small businesses built with FastAPI and SQLite.
|
|
|
|
## Features
|
|
|
|
- Inventory item management (create, read, update, delete)
|
|
- Category management
|
|
- Supplier management
|
|
- Stock movement tracking (purchases, sales, returns, adjustments)
|
|
- Low stock alerts
|
|
- Detailed reporting capabilities
|
|
|
|
## Tech Stack
|
|
|
|
- Python 3.8+
|
|
- FastAPI
|
|
- SQLAlchemy ORM
|
|
- SQLite Database
|
|
- Alembic Migrations
|
|
- Pydantic Data Validation
|
|
|
|
## Setup Instructions
|
|
|
|
### Prerequisites
|
|
|
|
- Python 3.8 or higher
|
|
- pip (Python package manager)
|
|
|
|
### Installation
|
|
|
|
1. Clone the repository:
|
|
```bash
|
|
git clone https://github.com/yourusername/small-business-inventory.git
|
|
cd small-business-inventory
|
|
```
|
|
|
|
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 the database:
|
|
```bash
|
|
# Run the database migrations
|
|
alembic upgrade head
|
|
```
|
|
|
|
### Running the Application
|
|
|
|
1. Start the FastAPI server:
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
2. Access the API:
|
|
- API Documentation: http://localhost:8000/docs
|
|
- API Endpoints: http://localhost:8000/redoc
|
|
|
|
## API Endpoints
|
|
|
|
### Health Check
|
|
- `GET /health` - Check system health
|
|
|
|
### Categories
|
|
- `GET /categories` - List all categories
|
|
- `GET /categories/{category_id}` - Get a specific category
|
|
- `POST /categories` - Create a new category
|
|
- `PUT /categories/{category_id}` - Update a category
|
|
- `DELETE /categories/{category_id}` - Delete a category
|
|
|
|
### Suppliers
|
|
- `GET /suppliers` - List all suppliers
|
|
- `GET /suppliers/{supplier_id}` - Get a specific supplier
|
|
- `POST /suppliers` - Create a new supplier
|
|
- `PUT /suppliers/{supplier_id}` - Update a supplier
|
|
- `DELETE /suppliers/{supplier_id}` - Delete a supplier
|
|
|
|
### Inventory Items
|
|
- `GET /items` - List all inventory items (with filtering options)
|
|
- `GET /items/{item_id}` - Get a specific item
|
|
- `POST /items` - Create a new item
|
|
- `PUT /items/{item_id}` - Update an item
|
|
- `DELETE /items/{item_id}` - Delete an item
|
|
|
|
### Stock Management
|
|
- `GET /stock/movements` - List all stock movements
|
|
- `GET /stock/movements/{movement_id}` - Get a specific stock movement
|
|
- `POST /stock/movements` - Create a new stock movement
|
|
- `GET /stock/low-stock` - Get low stock items
|
|
|
|
## Data Models
|
|
|
|
### Category
|
|
```json
|
|
{
|
|
"id": 1,
|
|
"name": "Electronics",
|
|
"description": "Electronic components and devices",
|
|
"is_active": true,
|
|
"created_at": "2025-05-12T10:00:00",
|
|
"updated_at": "2025-05-12T10:00:00"
|
|
}
|
|
```
|
|
|
|
### Supplier
|
|
```json
|
|
{
|
|
"id": 1,
|
|
"name": "ABC Supplies",
|
|
"contact_name": "John Doe",
|
|
"email": "john@abcsupplies.com",
|
|
"phone": "555-1234",
|
|
"address": "123 Main St, Anytown",
|
|
"is_active": true,
|
|
"created_at": "2025-05-12T10:00:00",
|
|
"updated_at": "2025-05-12T10:00:00"
|
|
}
|
|
```
|
|
|
|
### Item
|
|
```json
|
|
{
|
|
"id": 1,
|
|
"name": "LED Monitor",
|
|
"sku": "MON-LED-24",
|
|
"description": "24-inch LED Monitor",
|
|
"unit_price": 199.99,
|
|
"quantity": 25,
|
|
"reorder_level": 5,
|
|
"category_id": 1,
|
|
"supplier_id": 1,
|
|
"is_active": true,
|
|
"created_at": "2025-05-12T10:00:00",
|
|
"updated_at": "2025-05-12T10:00:00"
|
|
}
|
|
```
|
|
|
|
### StockMovement
|
|
```json
|
|
{
|
|
"id": 1,
|
|
"item_id": 1,
|
|
"quantity": 10,
|
|
"movement_type": "purchase",
|
|
"reference": "PO12345",
|
|
"notes": "Initial stock order",
|
|
"unit_price": 180.00,
|
|
"created_at": "2025-05-12T10:00:00"
|
|
}
|
|
```
|
|
|
|
## License
|
|
|
|
MIT |