{"id":28151688,"url":"https://github.com/khdevops/shopping_list","last_synced_at":"2025-05-15T04:14:08.656Z","repository":{"id":285436219,"uuid":"958135139","full_name":"KHDevOps/shopping_list","owner":"KHDevOps","description":"Shopping List API - Serverless Deployment on Google Cloud","archived":false,"fork":false,"pushed_at":"2025-04-03T13:07:36.000Z","size":54,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-06T14:45:27.005Z","etag":null,"topics":["artifact-registry","bash","cloudrun","cloudsql","docker","google-cloud-platform","python","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","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/KHDevOps.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,"zenodo":null}},"created_at":"2025-03-31T17:45:20.000Z","updated_at":"2025-04-03T13:07:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"ee0aec43-2d30-46ad-9233-0233aadbccc4","html_url":"https://github.com/KHDevOps/shopping_list","commit_stats":null,"previous_names":["leomendoza13/shopping_list","khdevops/shopping_list"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KHDevOps%2Fshopping_list","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KHDevOps%2Fshopping_list/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KHDevOps%2Fshopping_list/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KHDevOps%2Fshopping_list/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KHDevOps","download_url":"https://codeload.github.com/KHDevOps/shopping_list/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254270665,"owners_count":22042863,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["artifact-registry","bash","cloudrun","cloudsql","docker","google-cloud-platform","python","terraform"],"created_at":"2025-05-15T04:12:59.760Z","updated_at":"2025-05-15T04:14:08.646Z","avatar_url":"https://github.com/KHDevOps.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Shopping List API - Serverless Deployment on Google Cloud\n\nThis project provides a serverless API for managing a shopping list. The application is containerized using Docker and deployed on Google Cloud Run. Infrastructure is managed with Terraform to ensure minimal cost and reduced maintenance.\n\n## Project Overview\n\nThis API allows users to:\n\n1. Add an item to the shopping list.\n2. Remove an item from the shopping list.\n3. View the current shopping list.\n\n## Architecture Overview\n\nA high-level overview of the architecture:\n\n- **Cloud Storage** stores the Terraform state.\n- **Artifact Registry** stores the Docker image.\n- **Cloud Run** hosts the containerized application, ensuring scalability and availability.\n- **Cloud SQL** (PostgreSQL) stores the shopping list persistently.\n\n## Project Structure\n\n```\n.\n├── LICENSE\n├── Makefile\n├── README.md\n├── dockerfile\n├── requirements.txt\n├── src\n│   └── app.py\n└── terraform\n    ├── env\n    │   ├── dev\n    │   │   ├── backend.tf\n    │   │   ├── cloud_run.tf\n    │   │   ├── example.tfvars\n    │   │   ├── iam.tf\n    │   │   ├── main.tf\n    │   │   ├── provider.tf\n    │   │   ├── setup\n    │   │   │   ├── state_bucket.tf\n    │   │   │   ├── variables.tf\n    │   │   │   └── versions.tf\n    │   │   ├── storage.tf\n    │   │   ├── variables.tf\n    │   │   └── vpc.tf\n    │   ├── prod\n    │   │   └── main.tf\n    │   └── staging\n    │       └── main.tf\n    └── modules\n        ├── cloudrun\n        │   ├── main.tf\n        │   ├── outputs.tf\n        │   └── variables.tf\n        ├── iam\n        │   ├── main.tf\n        │   ├── outputs.tf\n        │   └── variables.tf\n        ├── network\n        │   ├── main.tf\n        │   ├── outputs.tf\n        │   └── variables.tf\n        └── storage\n            ├── main.tf\n            ├── outputs.tf\n            └── variables.tf\n```\n\n## Prerequisites\n\n- **Google Cloud Platform** account with billing enabled.\n- **gcloud CLI** installed and configured.\n- **Terraform** installed on your machine.\n- **Docker** installed for local development.\n\n## Setup Instructions\n\n### Step 1: Clone the Repository\n\n```bash\ngit clone git@github.com:Leomendoza13/shopping_list.git\ncd shopping_list\n```\n\n### Step 2: Configure GCloud CLI\n\n1. Install [gcloud CLI](https://cloud.google.com/sdk/docs/install) if it’s not already installed.\n\n2. Authenticate with Google Cloud:\n\n```bash\ngcloud auth application-default login\n```\n\nThis will generate an URL in your CLI, click on it, and log in to your Google Cloud account.\n\n3. Set the project ID:\n\n```bash\ngcloud config set project recrutement-polyconseil\n```\n\n4. And then activate the neccessary api:\n\n```bash\ngcloud services enable artifactregistry.googleapis.com\ngcloud services enable run.googleapis.com\ngcloud services enable compute.googleapis.com\ngcloud services enable vpcaccess.googleapis.com\n``` \n\n### Step 3: Configure Terraform Variables\n\n1. Install [Terraform](https://developer.hashicorp.com/terraform/tutorials/gcp-get-started/install-cli) if it is not already installed.\n\n2. Create a `terraform.tfvars` file based on `example.tfvars`:\n\n```bash\ncp terraform/env/dev/example.tfvars terraform/env/dev/terraform.tfvars\n```\n\n3. Edit `terraform/env/dev/terraform.tfvars` to add your specific values:\n\n```bash\n#User to connect to the database\ndatabase_user     = \"your-user\"\n\n#Password to connect to the database\ndatabase_password = \"your-password\"\n```\n\n### Step 4: Configure Docker\n\n1. Install [Docker](https://docs.docker.com/engine/install/) if it is not already installed.\n\n2. Install [Docker Desktop](https://www.docker.com/products/docker-desktop/) for windows and open it.\n\n### Step 5: Deploy the Application\n\n1. Deploy the application using the provided Makefile:\n\n```bash\nmake\n```\n\n2. Write yes in the CLI whenever it is asked to do so.\n\nThe application takes approximately 12 minutes to deploy.\n\n### Step 6: Using the API\n\n1. Add an item\n\n```bash\ncurl -X POST -H \"Authorization: Bearer $(gcloud auth print-identity-token)\" -d item=apple https://cloudrun-service-dev-676021926380.europe-west1.run.app/add_item\n```\n\n2. Remove an item\n\n```bash\ncurl -X POST -H \"Authorization: Bearer $(gcloud auth print-identity-token)\" -d id=1 https://cloudrun-service-dev-676021926380.europe-west1.run.app/del_item\n```\n\n3. Get the Shopping List\n```bash\ncurl -X GET -H \"Authorization: Bearer $(gcloud auth print-identity-token)\" https://cloudrun-service-dev-676021926380.europe-west1.run.app/get_items\n```\n\n### **Step 8: ⚠️ DON'T FORGET TO `terraform destroy` WHEN YOU ARE DONE ⚠️**\n\nTo destroy the infrastructure and avoid unnecessary costs, run the makefile rule:\n\n```bash\nmake destroy\n```\n\n## TODO for V2\n\n1. Replace Cloud SQL with Firestore\n2. Use Google Secret Manager for database access\n3. Add logging with Google Cloud Logging\n4. Implement stronger CI/CD pipeline for automated deployments\n5. Restrict database access to private network only\n6. Configure backup and recovery protocols\n7. Configure multiple environments (staging, production)\n8. Configure service accounts with least privilege principle\n9. Set up VPC connector for Cloud Run to secure internal resource\n10. Implement API authentication beyond identity tokens\n11. Configure alerting for system anomalies (Google Cloud Monitoring Alerting, Prometheus)\n12. Implement data encryption at rest and in transit\n13. Configure auto-scaling based on demand and traffic patterns\n14. Configure network firewall rules to restrict traffic\n\n## License\n\nThis project is licensed under the MIT License. See the LICENSE file for details.\n\n## Author\n\nDeveloped by Léo Mendoza. Feel free to reach out for questions, contributions, or feedback at [leo.mendoza.pro@gmail.com](mailto:leo.mendoza.pro@gmail.com).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhdevops%2Fshopping_list","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkhdevops%2Fshopping_list","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhdevops%2Fshopping_list/lists"}