{"id":15187363,"url":"https://github.com/thejasmeetsingh/go-ecommerce","last_synced_at":"2025-04-19T20:24:24.107Z","repository":{"id":214581596,"uuid":"736615355","full_name":"thejasmeetsingh/go-ecommerce","owner":"thejasmeetsingh","description":"A basic e-commerce application is built using Go/Gin and follows micro-service architecture","archived":false,"fork":false,"pushed_at":"2024-02-22T11:06:59.000Z","size":5032,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T12:51:20.865Z","etag":null,"topics":["docker","e-commerce","gin-gonic","go","golang","goose","grafana","jwt-authentication","microservices","microservices-architecture","pessimistic-locking","postgresql","prometheus","rate-limiter","redis-cache","restful-api","sqlc"],"latest_commit_sha":null,"homepage":"","language":"Go","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/thejasmeetsingh.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":"2023-12-28T11:40:41.000Z","updated_at":"2024-11-28T05:16:34.000Z","dependencies_parsed_at":"2024-01-15T09:06:34.439Z","dependency_job_id":"87280e51-daa1-4304-b5ce-b61ddd17f65b","html_url":"https://github.com/thejasmeetsingh/go-ecommerce","commit_stats":{"total_commits":46,"total_committers":2,"mean_commits":23.0,"dds":"0.021739130434782594","last_synced_commit":"f63f1bdfd44d82b57b884f0e16b9eb76cf327951"},"previous_names":["thejasmeetsingh/go-ecommerce"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thejasmeetsingh%2Fgo-ecommerce","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thejasmeetsingh%2Fgo-ecommerce/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thejasmeetsingh%2Fgo-ecommerce/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thejasmeetsingh%2Fgo-ecommerce/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thejasmeetsingh","download_url":"https://codeload.github.com/thejasmeetsingh/go-ecommerce/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249793223,"owners_count":21326510,"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":["docker","e-commerce","gin-gonic","go","golang","goose","grafana","jwt-authentication","microservices","microservices-architecture","pessimistic-locking","postgresql","prometheus","rate-limiter","redis-cache","restful-api","sqlc"],"created_at":"2024-09-27T18:20:33.089Z","updated_at":"2025-04-19T20:24:24.088Z","avatar_url":"https://github.com/thejasmeetsingh.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# E-Commerce\nThis is a simple e-commerce project developed using Golang and the Gin framework, embracing a microservices architecture. The system is composed of three microservices:\n\n1. User Service:\n    - Manages user authentication using JWT.\n    - Handles user profile retrieval, update, and deletion.\n    - Implements basic unit tests for functionality assurance.\n\n2. Product Service:\n    - Facilitates CRUD operations for products.\n    - Users can only update or delete their created products.\n    - Allows users to view product list and detail.\n    - Incorporates basic unit tests for quality assurance.\n\n3. Order Service:\n    - Manages the creation and deletion of orders.\n    - Users can view lists, details of their own orders, and delete their own orders as well.\n    - Utilizes basic unit tests for robustness.\n\n## Architecture Overview\n\nBelow diagram depict the architecture of each service:\n![](./assets/single-service-arch.png)\n\n### Microservices:\n- Adopts a microservices architecture for modularity and scalability.\n\n### Database Transactions:\n- Utilizes database transactions (commit and rollback) and pessimistic locking for effective concurrency control.\n\n### Security Measures:\n- Implements JWT authentication for users.\n- Employs a Rate Limiter to prevent API exploitation.\n- Integrates CORS middleware for secure cross-origin resource sharing.\n\n### Database Communication:\n- Utilizes SQLC for generating database schemas.\n- Manages database migrations using Goose.\n\n### Inter-Service Communication:\n- Makes synchronous calls to other microservices using HTTP RESTful APIs.\n- Secures APIs using different secret keys in headers to ensure requests come from within the project.\n\n### Services for Each Microservice:\n- **Database:** PostgreSQL for persistent data storage.\n- **Redis Cache:** Enhances database performance and stores IPs for the rate limiter service.\n- **Monitoring and Alerts:** Utilizes Prometheus and Grafana.\n\n### Containerization:\n- Each microservice is Dockerized for easy deployment and management.\n\n### Automation:\n- Includes shell scripts to start all services at once and for running test cases.\n- GitHub workflow automates unit tests when a pull request is raised to the main/master branch.\n\n## Getting Started\n1. Clone the repository\n\n2. Install below softwares/libraries \n    - [Docker](https://www.docker.com/products/docker-desktop/)\n    - [Go](https://go.dev/doc/install) (Needed if you want to execute the test cases)\n    - [Goose](https://pressly.github.io/goose/installation/) (Needed if you want to execute the test cases)\n\n3. Navigate into the project and run this command `bash run_services.sh`. It'll start all services one-by-one.\n\n4. Access the services using the postman collection: \n\n[\u003cimg src=\"https://run.pstmn.io/button.svg\" alt=\"Run In Postman\" style=\"width: 128px; height: 32px;\"\u003e](https://app.getpostman.com/run-collection/17396704-c06ae1fb-79a9-4afa-a122-fb97f668683f?action=collection%2Ffork\u0026source=rip_markdown\u0026collection-url=entityId%3D17396704-c06ae1fb-79a9-4afa-a122-fb97f668683f%26entityType%3Dcollection%26workspaceId%3D392b781a-05ab-415b-9eb8-456aca6f3129)\n\n### Testing\nTo run unit tests, You can navigate to the respected service and run this command `bash run_unit_test.sh`\n\n## GitHub Workflow\nThe project includes a GitHub workflow that automatically runs unit tests when a pull request is raised to the master branch.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthejasmeetsingh%2Fgo-ecommerce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthejasmeetsingh%2Fgo-ecommerce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthejasmeetsingh%2Fgo-ecommerce/lists"}