{"id":26047789,"url":"https://github.com/harsh971/inventory-management-system","last_synced_at":"2026-04-08T16:01:40.698Z","repository":{"id":281151123,"uuid":"944339750","full_name":"Harsh971/inventory-management-system","owner":"Harsh971","description":"Inventory Management System: A Flask API with MySQL, containerized with Docker and deployed on Kubernetes for efficient product tracking and order management.","archived":false,"fork":false,"pushed_at":"2025-03-07T08:21:04.000Z","size":177,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-14T23:46:19.769Z","etag":null,"topics":["docker","docker-compose","flask","kubernetes","mysql","python"],"latest_commit_sha":null,"homepage":"https://harshthakkar.netlify.app/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Harsh971.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-07T07:14:02.000Z","updated_at":"2025-03-07T08:25:29.000Z","dependencies_parsed_at":"2025-03-07T09:36:46.925Z","dependency_job_id":null,"html_url":"https://github.com/Harsh971/inventory-management-system","commit_stats":null,"previous_names":["harsh971/inventory-management-system"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Harsh971/inventory-management-system","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Harsh971%2Finventory-management-system","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Harsh971%2Finventory-management-system/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Harsh971%2Finventory-management-system/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Harsh971%2Finventory-management-system/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Harsh971","download_url":"https://codeload.github.com/Harsh971/inventory-management-system/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Harsh971%2Finventory-management-system/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31562697,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","flask","kubernetes","mysql","python"],"created_at":"2025-03-07T23:13:56.420Z","updated_at":"2026-04-08T16:01:40.683Z","avatar_url":"https://github.com/Harsh971.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Inventory Management System\n\n\u003cimg scr=\"https://raw.githubusercontent.com/Harsh971/inventory-management-system/refs/heads/master/structure.gif\"\u003e\n\nThis project is an end-to-end inventory management system featuring:\n\n- A **Flask API** built with object-oriented design.\n- **MySQL** integration with a normalized schema.\n- Concurrency control for handling simultaneous orders.\n- **Containerization** using Docker and Docker Compose.\n- **Kubernetes orchestration** for scalable deployment.\n- (Optional) A basic UI that can be further enhanced.\n\n---\n\n## Table of Contents\n\n- [Project Overview](#project-overview)\n- [Features](#features)\n- [Prerequisites](#prerequisites)\n- [Local Development Setup](#local-development-setup)\n  - [1. Clone the Repository](#1-clone-the-repository)\n  - [2. Create and Activate a Virtual Environment](#2-create-and-activate-a-virtual-environment)\n  - [3. Install Python Dependencies](#3-install-python-dependencies)\n  - [4. Configure Environment Variables](#4-configure-environment-variables)\n  - [5. Create the MySQL Database and Tables](#5-create-the-mysql-database-and-tables)\n  - [6. Run the Flask Application Locally](#6-run-the-flask-application-locally)\n- [Containerization with Docker Compose](#containerization-with-docker-compose)\n  - [1. Build and Run Containers](#1-build-and-run-containers)\n  - [2. Verify Endpoints](#2-verify-endpoints)\n- [Kubernetes Deployment](#kubernetes-deployment)\n  - [1. Prerequisites for Kubernetes](#1-prerequisites-for-kubernetes)\n  - [2. Using Local Images in Kubernetes](#2-using-local-images-in-kubernetes)\n  - [3. Kubernetes YAML Files](#3-kubernetes-yaml-files)\n  - [4. Deploying to Kubernetes](#4-deploying-to-kubernetes)\n- [Future Enhancements](#future-enhancements)\n- [Troubleshooting](#troubleshooting)\n\n---\n\n## Project Overview\n\nThis project provides a fully containerized inventory management system with the following core components:\n\n- **API Endpoints:** For adding products, placing orders, and generating inventory reports.\n- **MySQL Database:** Stores product details, orders, and order items.\n- **Concurrency Management:** Uses thread locks to safely process simultaneous orders.\n- **Docker \u0026 Docker Compose:** Containerizes both the application and MySQL.\n- **Kubernetes Deployment:** YAML files are provided for deploying the system to a Kubernetes cluster.\n- **Optional UI:** Basic HTML templates can be enhanced for a complete web interface.\n\n---\n\n## Features\n\n- **Flask API:** RESTful endpoints built with Flask.\n- **MySQL Integration:** Well-designed schema for products, orders, and order items.\n- **Concurrency:** Ensures safe order processing.\n- **Dockerized:** Simple setup with Docker and Docker Compose.\n- **Kubernetes Ready:** YAML configurations for cloud or local Kubernetes clusters.\n- **Extensible UI:** (Optional) Starter templates using Flask's Jinja2.\n\n---\n\n## Project Architecture\n\n- [Click Here](https://raw.githubusercontent.com/Harsh971/inventory-management-system/refs/heads/master/structure.png)\n\n---\n\n## Prerequisites\n\n- **Operating System:** Linux, macOS, or Windows.\n- **Docker \u0026 Docker Compose:** Installed on your system.\n- **Kubernetes:** Docker Desktop's integrated Kubernetes or Minikube for local testing.\n- **Python 3.8+** and **MySQL** (for local development).\n\n---\n\n## Local Development Setup\n\n### 1. Clone the Repository\n\n```bash\ngit clone https://github.com/yourusername/inventory-management-system.git\ncd inventory-management-system\n```\n\n### 2. Create and Activate a Virtual Environment\n\n```bash\npython3 -m venv venv\nsource venv/bin/activate   # On Windows use: venv\\Scripts\\activate\n```\n\n### 3. Install Python Dependencies\n\n```bash\npip install -r requirements.txt\n```\n\n### 4. Configure Environment Variables\nCreate a file named ``.env`` in the project root with the following content (adjust values as needed):\n\n```bash\nDB_USER=inventory_user\nDB_PASSWORD=inventory_pass\nDB_HOST=127.0.0.1\nDB_NAME=inventory_db\nSECRET_KEY=your_secret_key\n```\n\n### 5. Create the MySQL Database and Tables\n\n- Option 1: Use your MySQL client and run the provided SQL schema (if available).\n- Option 2: Uncomment the `db.create_all()` lines in `app.py` temporarily and run the app once to create the tables automatically.\n\n### 6. Run the Flask Application Locally\n\n```bash\npython app.py\n```\nOpen your browser at `http://localhost:5000` to verify the server is running. Test endpoints (e.g., `/add_product`, `/report`) using curl, Postman, or a browser.\n\n\n## Containerization with Docker Compose\n\n### 1. Build and Run Containers\n\nMake sure you have a working `Dockerfile` and `docker-compose.yaml` in the project root. Then run:\n\n```bash\ndocker-compose up --build\n```\nThis command will:\n- Build the Docker image for the Flask app.\n- Start the MySQL container.\n- Start the Flask app container and link them on the same network.\n\n### 2. Verify Endpoints\n\n- Open `http://localhost:5000` in your browser.\n- Test the `/report` endpoint at `http://localhost:5000/report`.\n- Use curl/Postman to test API endpoints.\n\n\n## Kubernetes Deployment\n\n### 1. Prerequisites for Kubernetes\n- Docker Desktop with Kubernetes enabled or a local cluster like Minikube.\n- Ensure kubectl is installed and configured to interact with your cluster.\n\n### 2. Using Local Images in Kubernetes\nSince Docker Desktop's Kubernetes shares the same Docker daemon, you can use the locally built image directly:\n\n#### 1. Build the Image Locally:\n```bash\ndocker build -t inventory-app:latest .\n```\n\n#### 2. Reference the Local Image in Your YAML Files:\nIn your deployment YAML files, set the image to:\n```bash\nimage: inventory-app:latest\n```\n\n### 3. Kubernetes YAML Files\nMySQL Deployment \u0026 Service (`mysql-deployment.yaml`)\n```bash\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: mysql-deployment\nspec:\n  replicas: 1\n  selector:\n    matchLabels:\n      app: mysql\n  template:\n    metadata:\n      labels:\n        app: mysql\n    spec:\n      containers:\n      - name: mysql\n        image: mysql:5.7\n        env:\n          - name: MYSQL_ROOT_PASSWORD\n            value: \"rootpassword\"\n          - name: MYSQL_DATABASE\n            value: \"inventory_db\"\n          - name: MYSQL_USER\n            value: \"inventory_user\"\n          - name: MYSQL_PASSWORD\n            value: \"inventory_pass\"\n        ports:\n        - containerPort: 3306\n---\napiVersion: v1\nkind: Service\nmetadata:\n  name: mysql-service\nspec:\n  selector:\n    app: mysql\n  ports:\n    - port: 3306\n      targetPort: 3306\n  clusterIP: None\n```\n\nFlask App Deployment \u0026 Service (`inventory-app-deployment.yaml` \u0026 `inventory-app-service.yaml`)\n\n```bash\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: inventory-app-deployment\nspec:\n  replicas: 3\n  selector:\n    matchLabels:\n      app: inventory-app\n  template:\n    metadata:\n      labels:\n        app: inventory-app\n    spec:\n      containers:\n      - name: inventory-app\n        image: inventory-app:latest\n        env:\n          - name: DB_USER\n            value: \"inventory_user\"\n          - name: DB_PASSWORD\n            value: \"inventory_pass\"\n          - name: DB_HOST\n            value: \"mysql-service\"\n          - name: DB_NAME\n            value: \"inventory_db\"\n          - name: SECRET_KEY\n            value: \"your_secret_key\"\n        ports:\n          - containerPort: 5000\n---\napiVersion: v1\nkind: Service\nmetadata:\n  name: inventory-app-service\nspec:\n  selector:\n    app: inventory-app\n  ports:\n    - protocol: TCP\n      port: 80\n      targetPort: 5000\n  type: LoadBalancer\n```\n\n### 4. Deploying to Kubernetes\nApply the YAML files:\n```bash\nkubectl apply -f mysql-deployment.yaml\nkubectl apply -f inventory-app-deployment.yaml\nkubectl apply -f inventory-app-service.yaml\n```\n\nVerify your deployments:\n```bash\nkubectl get pods\nkubectl get svc\n```\n\nAccess your application:\n- For LoadBalancer, use the external IP once assigned.\n- Alternatively, run port forwarding:\n```bash\nkubectl port-forward svc/inventory-app-service 5000:80\n```\n\nThen visit `http://localhost:5000`.\n\n\n## Future Enhancements\n- User Interface: Develop a comprehensive front-end using frameworks like React or Vue.\n- Security: Implement authentication/authorization and manage secrets using Kubernetes Secrets.\n- Testing: Add unit, integration, and end-to-end tests.\n- Monitoring \u0026 Logging: Integrate tools like Prometheus, Grafana, and the ELK Stack.\n- CI/CD Pipeline: Automate builds and deployments using GitHub Actions, Jenkins, etc.\n\n## Troubleshooting\n- DNS Issues During Build:\nIf you encounter DNS resolution issues, try disabling BuildKit:\n```bash\nDOCKER_BUILDKIT=0 docker-compose up --build\n```\nOr update Docker daemon DNS settings in /etc/docker/daemon.json.\n\n- Database Connection Errors:\nEnsure environment variables are correctly set and that MySQL is running.\n\n- Kubernetes Deployment Problems:\nUse `kubectl logs \u003cpod-name\u003e` for debugging and verify service configurations.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharsh971%2Finventory-management-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharsh971%2Finventory-management-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharsh971%2Finventory-management-system/lists"}