{"id":27222910,"url":"https://github.com/rasadov/EcommerceAPI","last_synced_at":"2025-04-10T09:01:56.279Z","repository":{"id":273643414,"uuid":"914858214","full_name":"rasadov/EcommerceAPI","owner":"rasadov","description":"Modular e-commerce backend with a GraphQL gateway and gRPC microservices for accounts, products, orders, and recommendations.","archived":false,"fork":false,"pushed_at":"2025-04-09T14:16:59.000Z","size":505,"stargazers_count":276,"open_issues_count":0,"forks_count":27,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-09T15:30:08.416Z","etag":null,"topics":["backend","docker","docker-compose","ecommerce","elasticsearch","event-driven","gin","go","gqlgen","graphql","grpc","kafka","microservices","postgresql","protobuf","python","recommendation-system","recommender-system"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rasadov.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":"2025-01-10T13:02:51.000Z","updated_at":"2025-04-09T14:17:03.000Z","dependencies_parsed_at":"2025-04-09T15:35:40.671Z","dependency_job_id":null,"html_url":"https://github.com/rasadov/EcommerceAPI","commit_stats":null,"previous_names":["rasadov/ecommercemicroservices","rasadov/ecommerceapi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rasadov%2FEcommerceAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rasadov%2FEcommerceAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rasadov%2FEcommerceAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rasadov%2FEcommerceAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rasadov","download_url":"https://codeload.github.com/rasadov/EcommerceAPI/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248190499,"owners_count":21062282,"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":["backend","docker","docker-compose","ecommerce","elasticsearch","event-driven","gin","go","gqlgen","graphql","grpc","kafka","microservices","postgresql","protobuf","python","recommendation-system","recommender-system"],"created_at":"2025-04-10T09:01:09.721Z","updated_at":"2025-04-10T09:01:56.263Z","avatar_url":"https://github.com/rasadov.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# ECOMMERCE MICROSERVICES\n\nThis repository hosts a sample **e-commerce platform** demonstrating a **microservices architecture** using multiple **Go services** alongside a **Python-based Recommender service**. The project showcases:\n\n- gRPC communication between services\n- Kafka-based event streaming pipeline\n- A unified GraphQL API gateway for clients\n- Elasticsearch integration for product search\n\n---\n\n## 📚 Table of Contents\n\n- [Overview](#-overview)\n- [Architecture Diagram](#-architecture-diagram)\n- [Services](#-services)\n- [Getting Started](#-getting-started)\n- [Usage](#-usage-graphql)\n- [Contributing](#-contributing)\n- [Author](#-author)\n- [License](#-license)\n\n---\n\n## 🧭 Overview\n\nThe system comprises several microservices:\n\n- **Account** (Go): Manages user accounts, authentication, and authorization.\n- **Product** (Go): CRUD for products; indexes product data in **Elasticsearch**.\n- **Order** (Go): Handles order creation and persistence; publishes events to Kafka.\n- **Recommender** (Python): Consumes Kafka events and builds product recommendations.\n- **API Gateway** (Go): A GraphQL service exposing a unified API for front-end clients.\n\nThe entire ecosystem is containerized using **Docker Compose**. Datastores include **PostgreSQL**, **Elasticsearch**, and **Kafka**.\n\n---\n\n## 🏗 Architecture Diagram\n\nBelow is a high-level overview of the system architecture:\n\n![API Design](./design.png)\n\n### Communication Overview\n\n- `API Gateway (GraphQL)` talks to:\n    - `Account client` → `Account server` → `Postgres`\n    - `Product client` → `Product server` → `ElasticSearch`\n    - `Order client` → `Order server` → `Postgres` + Kafka  \n      (also communicates with Product service via gRPC)\n    - `Recommender client` → `Recommender server` (Python) → `Postgres (Replica)`\n\n- **Event Flow**:\n    - `Order` and `Product` services act as **Kafka producers**.\n    - `Recommender` service is a **Kafka consumer**, ingesting order/product events and updating internal state for recommendations.\n\n---\n\n## ⚙ Services\n\n### 🧑‍💼 Account Service (Go)\n- Responsibilities: Register, login, fetch account data, generate JWT tokens.\n- Database: PostgreSQL\n\n### 📦 Product Service (Go)\n- Responsibilities: Product CRUD operations, indexing to Elasticsearch, event publishing to Kafka.\n- Database: Elasticsearch\n\n### 🛒 Order Service (Go)\n- Responsibilities: Order creation, price calculation, data persistence, Kafka event publishing.\n- Dependencies: Calls product service to retrieve product info.\n\n### 🧠 Recommender Service (Python)\n- Responsibilities: Kafka consumer that builds recommendations based on product/order events.\n- Tech Stack: Python + gRPC + PostgreSQL (replica of product DB)\n\n### 🚪 API Gateway (Go)\n- Responsibilities: Unified GraphQL endpoint at `/graphql`.\n- Implementation: Uses gRPC clients for all microservices and schema stitching.\n\n---\n## 🚀 Getting Started\n\n### ✅ Prerequisites\n\nBefore running the project, ensure you have the following installed:\n\n- [Docker](https://www.docker.com/get-started) \u0026 [Docker Compose](https://docs.docker.com/compose/)\n- [Git](https://git-scm.com/)\n\n---\n\n### 📥 Clone the Repository\n\n```bash\n  git clone https://github.com/rasadov/EcommerceAPI.git\n  cd ecommercemicroservices\n```\n\n---\n\n### 🐳 Run the Stack\n\nTo build and start all services using Docker Compose, run:\n\n```bash\n  docker-compose up --build\n```\n\nThis will start:\n\n- Go microservices (`account`, `order`, `product`, `graphql`)\n- Python-based `recommender` service\n- Databases: PostgreSQL, Elasticsearch\n- Kafka + Zookeeper\n- GraphQL gateway\n\n---\n\n### 🌐 Access the API\n\nOnce everything is running, open your browser to:\n\n- **GraphQL API endpoint**:  \n  [http://localhost:8080/graphql](http://localhost:8080/graphql)\n\n- **GraphQL Playground (interactive testing)**:  \n  [http://localhost:8080/playground](http://localhost:8080/playground)\n\n---\n\n## 📬 Usage (GraphQL)\n\nBelow are example GraphQL queries and mutations you can test in the [GraphQL Playground](http://localhost:8080/playground).\n\n---\n\n### 📝 Register a New Account\n\n```graphql\nmutation {\n  register(account: {\n    name: \"Alice\"\n    email: \"alice@example.com\"\n    password: \"secret123\"\n  }) {\n    token\n  }\n}\n```\n\n---\n\n### 🔐 Login\n\n```graphql\nmutation {\n  login(account: {\n    email: \"alice@example.com\"\n    password: \"secret123\"\n  }) {\n    token\n  }\n}\n```\n\n---\n\n### ➕ Create a Product\n\n```graphql\nmutation {\n  createProduct(product: {\n    name: \"Camera\"\n    description: \"A digital camera\"\n    price: 99.99\n  }) {\n    id\n    name\n  }\n}\n```\n\n---\n\n### 🔍 Query Products\n\n```graphql\nquery {\n  product(pagination: { skip: 0, take: 10 }) {\n    id\n    name\n    price\n  }\n}\n```\n\n---\n\n### 🛒 Create an Order\n\n```graphql\nmutation {\n  createOrder(order: {\n    products: [\n      { id: \"PRODUCT_ID\", quantity: 2 }\n    ]\n  }) {\n    id\n    totalPrice\n    products {\n      name\n      quantity\n    }\n  }\n}\n```\n\n## 🤝 Contributing\nWe welcome contributions! To contribute:\n\nFork the repository\n\nCreate a new branch\n\nCommit and push your changes\n\nOpen a Pull Request\n\n## 👤 Author\n\n**Rauf Asadov**  \nGitHub: [@rasadov](https://github.com/rasadov)  \nLinkedIn: [Rauf Asadov](https://www.linkedin.com/in/rauf-asadov/)  \nEmail: raufasadov23@gmail.com\n\n## 🪪 License\nThis project is licensed under the Apache License 2.0.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frasadov%2FEcommerceAPI","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frasadov%2FEcommerceAPI","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frasadov%2FEcommerceAPI/lists"}