How ashhketchup/cec-microservices works
Project type and purpose
• This is a Go-based microservices e-commerce assignment that uses gRPC and gRPC-Gateway to expose services over HTTP and gRPC. It’s containerized with Docker and deployed via Kubernetes (you also have a docker-compose fallback).
File structure
• Top-level key dirs/files:
• services/ – contains each Go microservice (auth, cart, delivery, product) plus the API-Gateway service
• pkg/ – shared libraries (db, logger, middleware)
• k8s/ – Kubernetes manifests (namespaces, services, deployments, configs, secrets, volumes, ingress)
• docker-compose.yaml – for local compose-based deployment
• buf.yaml / buf.gen.yaml – proto compilation config
• Each service has:
• proto definitions → codegen under services/<svc>/proto/gen or services/api-gateway/gen
• Dockerfile + Go modules
• internal/db, internal/handler implementing business logic
• External infra: MySQL and Postgres init scripts in services/mysql/ and services/postgres/
Extract architecture insights from README
• All services communicate via gRPC. An API-Gateway (gRPC-Gateway) exposes HTTP endpoints by translating REST calls into gRPC.
• Kubernetes is used to host each service in its own Deployment + Service, with an Ingress/Gateway routing external traffic.
• Databases run as StatefulSets (MySQL, Postgres) with init jobs and PersistentVolumes.
Main components & interactions (to feature
a. API-Gateway
• Receives external HTTP/JSON requests
• Uses gRPC-Gateway handlers (gen code) to forward to microservices via internal gRPC endpoints
b. Microservices (Auth, Cart, Delivery, Product)
• Each runs a gRPC server
• Each has its own database:
• Auth, Cart, Delivery, Product → typically MySQL/Postgres instances (check config)
• Business logic in handler.go, data access in db/database.go
c. Databases
• MySQL and Postgres StatefulSets with init SQL jobs
• Secrets and ConfigMaps for credentials (k8s/secrets/*.yaml, k8s/configs/*.yaml)
d. Kubernetes Control Plane
• Namespaces isolate microservices
• Deployments manage pods per service
• Services (ClusterIP) route internal traffic
• Ingress/Gateway routes external traffic to the API-Gateway service
Relationships & data flow
• Client → Ingress (IngressController) → API-Gateway (HTTP port)
• API-Gateway → gRPC calls → Auth/Cart/Delivery/Product services
• Each service → SQL queries → its DB
• Optionally: inter-service calls (e.g., Cart might call Product or Auth) via gRPC
Architectural patterns & tech
• Microservices with bounded contexts
• API-Gateway pattern for unified HTTP interface
• gRPC + gRPC-Gateway for polyglot clients and strict contracts
• Kubernetes microservices orchestration (Deployments, Services, ConfigMaps, Secrets, Ingress)
• Docker for containerization