{"id":21871497,"url":"https://github.com/niv-devops/python-mongodb-kafka","last_synced_at":"2026-04-15T14:03:12.810Z","repository":{"id":261775539,"uuid":"880967908","full_name":"niv-devops/python-mongodb-kafka","owner":"niv-devops","description":"Flask Python online shopping project using Apache Kafka for communication, MongoDB for data storage, K8's cluster and Helm for deployment.","archived":false,"fork":false,"pushed_at":"2025-08-15T17:28:20.000Z","size":1129,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-29T04:43:22.906Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://niv-devops.github.io/python-mongodb-kafka/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/niv-devops.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-10-30T17:22:41.000Z","updated_at":"2025-08-15T17:28:24.000Z","dependencies_parsed_at":"2024-11-08T11:34:58.485Z","dependency_job_id":"7807fa16-add9-4cc7-9026-991fdb7bf560","html_url":"https://github.com/niv-devops/python-mongodb-kafka","commit_stats":null,"previous_names":["niv-devops/python-mongodb-kafka"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/niv-devops/python-mongodb-kafka","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niv-devops%2Fpython-mongodb-kafka","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niv-devops%2Fpython-mongodb-kafka/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niv-devops%2Fpython-mongodb-kafka/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niv-devops%2Fpython-mongodb-kafka/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/niv-devops","download_url":"https://codeload.github.com/niv-devops/python-mongodb-kafka/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niv-devops%2Fpython-mongodb-kafka/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31844329,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T13:28:40.153Z","status":"ssl_error","status_checked_at":"2026-04-15T13:28:29.396Z","response_time":63,"last_error":"SSL_read: 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":[],"created_at":"2024-11-28T06:14:24.692Z","updated_at":"2026-04-15T14:03:12.779Z","avatar_url":"https://github.com/niv-devops.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python - MongoDB project using Apache Kafka\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"./images/broncos-webapp.png\" alt=\"DevOps Exercises\" width=\"300\"\u003e\n\u003c/div\u003e\n\nA simple purchase service that allows users to buy items and check all purchased items. This project uses Python and Flask for the API and client servers, MongoDB for data storage, Kafka and Zookeeper for messaging, and Kubernetes for orchestration. The application is also deployed in a Kubernetes environment using Helm for easy management.\n\n## Table of Contents\n\n- [Features](#features)\n- [Technologies](#technologies)\n- [Getting Started](#getting-started)\n- [Deployment](#deployment)\n- [Usage](#usage)\n- [License](#license)\n\n## Features\n\n- Buy/Remove items and store purchase information in MongoDB.\n- Retrieve a list of all purchased items.\n- Asynchronous communication using Kafka.\n- Containerized deployment using Docker and Kubernetes.\n- Manage deployment using Helm Charts.\n\n## Technologies\n\n- **Programming Language**: Python\n- **Web Framework**: Flask\n- **Database**: MongoDB\n- **Messaging Queue**: Kafka\n- **Containerization**: Docker\n- **Orchestration**: Kubernetes\n- **Local Development**: Minikube\n- **Deployment**: Helm\n\n## Getting Started\n\n### Prerequisites\n\n- [Docker](https://www.docker.com/get-started)\n- [Minikube](https://minikube.sigs.k8s.io/docs/start/)\n- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)\n- [Helm](https://helm.sh/docs/intro/install/)\n\n### Setting Up the Environment\n\n1. **Clone the repository**:\n   ```bash\n   git clone https://github.com/niv-devops/python-mongodb-kafka.git\n   cd python-mongodb-kafka\n   ```\n\n2. **Start Minikube**:\n   ```bash\n   minikube start\n   eval $(minikube docker-env)\n   ```\n\n3. **Build Docker Images**:\n   ```bash\n   docker build -t kafka-python:latest .\n   docker tag kafka-python:latest devopsgoofy/kafka-python:latest\n   docker push devopsgoofy/kafka-python:latest\n   ```\n\n4. **Apply The Cluster**:\n   ```bash\n   # Create the Kubernetes namespace\n   kubectl create namespace python-mongodb\n   \n   # Apply manifest files\n   kubectl apply -f k8s-manifests/ --namespace=python-mongodb\n   kubectl get pods\n   \n   # Obtain IP Address for external access\n   minikube ip\n   ```\n\n5. **Setup MongoDB**:\n   ```bash\n   # Access the pod and create DB \u0026 Collections\n   kubectl exec -it -n python-mongodb \u003cmongodb-pod-name\u003e -- bash\n   mongosh\n   use shop;\n   db.createCollection(\"customers\");\n   db.createCollection(\"items\");\n\n   # Insert data into collections\n   db.items.insertMany([\n     { \"item\": \"Blue Jersey\", \"price\": 80, image: 'https://cdn.jerseyaz.com/wp-content/uploads/2024/04/gexdimzsguAdgmjugCAtmnrxgexdambqgaxdkmjrgaAdqmrwgCxtkmztgexdknjt-510x510.jpeg' },\n     { \"item\": \"Orange Jersey\", \"price\": 90, image: 'https://fanatics.frgimages.com/denver-broncos/youth-denver-broncos-peyton-manning-nike-orange-team-color-game-jersey_pi787000_altimages_ff_787747alt1_full.jpg?_hv=2\u0026w=900' },\n     { \"item\": \"White Jersey\", \"price\": 100, image: 'https://fanatics.frgimages.com/denver-broncos/youth-denver-broncos-peyton-manning-nike-white-game-jersey_pi787000_altimages_ff_787753alt1_full.jpg?_hv=2\u0026w=900' }\n   ]);\n\n   db.customers.insertMany([\n     { \"username\": \"admin\", \"password\": \"adminpass\", \"Blue Jersey\": 0, \"Orange Jersey\": 0, \"White Jersey\": 0 },\n     { \"username\": \"user\", \"password\": \"userpass\", \"Blue Jersey\": 0, \"Orange Jersey\": 0, \"White Jersey\": 0 }\n   ]);\n\n   # Verify Data and exit\n   show dbs\n   db.items.find()\n   db.customers.find()\n   exit\n   ```\n\n6. **Create Helm Chart**:\n   ```bash\n   helm create kafka-mongo-chart\n   helm dependency update\n   helm install kafka-mongo-chart . --namespace chart-python-mongodb --create-namespace\n   helm status kafka-mongo-chart --namespace chart-python-mongodb\n   ```\n\n7. **(Optional) For test environment on local machine**:\n   ```bash\n   # Create virtual environment\n   sudo apt install python3-venv\n   python3 -m venv .venv\n   source .venv/bin/activate\n\n   # Install requirments\n   pip install flask kafka-python pymongo\n\n   # Start the ZooKeeper server\n   bin/zookeeper-server-start.sh config/zookeeper.properties\n\n   # Start the Kafka server (On another terminal)\n   bin/kafka-server-start.sh config/server.properties\n   ```\n\n## Deployment\n\nThis project deploys the following services in the `python-mongodb` namespace:\n\n- **MongoDB**: Stores purchase data.\n- **Zookeeper**: Manages Kafka cluster.\n- **Kafka**: Handles messaging between services.\n- **API Server**: Provides endpoints for buying items and retrieving purchase history.\n- **Client Server**: User interface for interacting with the purchase service.\n\n1. **Deploy using Helm**:\n\n   Navigate to the main chart directory and install the application:\n\n   ```bash\n   helm install my-project ./ --namespace python-mongodb --create-namespace\n   ```\n\n2. **Verify the deployment**:\n\n   Check the status of the deployed services:\n\n   ```bash\n   helm status my-project --namespace python-mongodb\n   kubectl get pods -n python-mongodb\n   kubectl get svc -n python-mongodb\n   ```\n\n## Usage\n\n1. **Access the Client**:\n   After deploying, you can access the client at `http://\u003cminikube-ip\u003e:30002`. Use the following command to get the Minikube IP:\n   ```bash\n   minikube ip\n   ```\n\n2. **Login**:\n   Use the interface to into existing account or insert new data into the form, user will be created automatically.\n\n2. **Buy an Item**:\n   Use the interface to submit a buy request.\n\n3. **Get All Purchased Items**:\n   Click the `View Cart` button to retrieve and display all purchased items.\n\n4. **Remove An Item**:\n   Click the `Remove` button to remove item from the list, which will reset its quantity value to 0.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniv-devops%2Fpython-mongodb-kafka","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fniv-devops%2Fpython-mongodb-kafka","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniv-devops%2Fpython-mongodb-kafka/lists"}