Small Business Inventory Management System
This is a FastAPI application for managing small business inventory, products, orders, and suppliers.
Features
- User authentication and authorization
- Product management
- Inventory tracking
- Order processing
- Supplier management
- Category organization
API Endpoints
/docs
- Swagger UI documentation/redoc
- ReDoc documentation/health
- Health check endpoint/api/v1/auth
- Authentication endpoints/api/v1/users
- User management/api/v1/products
- Product management/api/v1/inventory
- Inventory management/api/v1/orders
- Order processing/api/v1/suppliers
- Supplier management/api/v1/categories
- Category management
Running Locally
-
Install dependencies:
pip install -r requirements.txt
-
Start the server:
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
Environment Variables
The application uses the following environment variables:
SECRET_KEY
: Secret key for JWT token generationSERVER_NAME
: Server name (e.g., "Inventory Management System")SERVER_HOST
: Server host URL (e.g., "https://inventory.example.com")FIRST_SUPERUSER
: Email for the first superuserFIRST_SUPERUSER_PASSWORD
: Password for the first superuser
Kubernetes Deployment
The application can be deployed using Kubernetes with the provided configuration files in the kubernetes/
directory:
deployment.yaml
: Deployment configuration (using nameprod-pod
)service.yaml
: Service configuration (using nameprod-pod-service
)pvc.yaml
: Persistent Volume Claim for storagesecrets.yaml
: Secret configuration for environment variables
Deployment Configuration
The deployment has been optimized for maximum scheduling flexibility and minimal resource requirements:
-
Minimal Resource Requirements:
- Single replica (no high availability) to ensure easier scheduling
- Extremely low resource requests (10m CPU, 64Mi memory)
- No resource limits to allow for flexible resource usage
- Reduced PVC storage request (100Mi)
- Optional emptyDir volume configuration (commented out)
-
Maximum Scheduling Flexibility:
- Uses Recreate deployment strategy instead of RollingUpdate
- Tolerations for all taints using
operator: "Exists"
- No node selector or required affinity rules
- Default scheduler and DNS policy
-
Vault Integration (Commented Out):
- Added configuration templates for HashiCorp Vault integration
- Instructions for using Vault Agent Injector with the deployment
- Support for vault-agent and vault-agent-init sidecars
Troubleshooting "pod does not have a host assigned" Error
If you encounter this error, follow these steps:
-
Check Cluster Resources:
kubectl get nodes kubectl describe nodes
- Ensure nodes have available CPU, memory, and are in Ready state
-
Check PVC Status:
kubectl get pvc kubectl describe pvc inventory-api-pvc
- If the PVC is stuck in Pending state, check storage class availability:
kubectl get storageclass
- If no storage class is available, modify deployment.yaml to use emptyDir:
volumes: - name: storage-volume emptyDir: {} # persistentVolumeClaim: # claimName: inventory-api-pvc
- If the PVC is stuck in Pending state, check storage class availability:
-
Check Pod Status:
kubectl get pods kubectl describe pod <pod-name> kubectl get events --sort-by='.metadata.creationTimestamp'
- Look for scheduling errors or resource constraints
-
Verify Vault Configuration (if applicable):
- If your cluster uses HashiCorp Vault, uncomment the Vault configuration in deployment.yaml
- Check Vault service status:
kubectl get svc -n vault
-
Extreme Resource Reduction:
- If still having issues, you can uncomment and adjust these values in deployment.yaml:
resources: requests: cpu: "1m" # Absolute minimum memory: "32Mi" # Absolute minimum
- If still having issues, you can uncomment and adjust these values in deployment.yaml:
Deployment Commands
To deploy:
# Apply secret first
kubectl apply -f kubernetes/secrets.yaml
# Create PVC
kubectl apply -f kubernetes/pvc.yaml
# Apply deployment
kubectl apply -f kubernetes/deployment.yaml
# Apply service
kubectl apply -f kubernetes/service.yaml
To check status:
# Get pod status
kubectl get pods
# Describe pod for detailed information
kubectl describe pod <pod-name>
# Check recent events
kubectl get events --sort-by='.metadata.creationTimestamp'
# Get logs from container
kubectl logs <pod-name> -c app
To delete deployment:
kubectl delete -f kubernetes/deployment.yaml
kubectl delete -f kubernetes/service.yaml
kubectl delete -f kubernetes/pvc.yaml
kubectl delete -f kubernetes/secrets.yaml
Description
Languages
Python
100%