How meenachinmay/microservices-golang works
Project Type and Purpose
• This is a Golang-based microservices application demonstrating a scalable, maintainable architecture.
• It consists of an API Gateway, six backend services (Authentication, Enquiry, Logger, Mailer, Listener, Payment) plus a client front-end.
• Services communicate via REST/HTTP, RabbitMQ message queues, and gRPC where needed.
File-Structure Analysis
• Top-level directories:
• authentication-service, enquiry-service, logger-service, mail-service, listener-service, payment-service, broker-service (the API Gateway), client (Next.js front-end), front-end (Go-templated web UI), project (Docker Compose).
• Each service contains:
• cmd/api or cmd (entry point), handlers for HTTP/gRPC, helpers, data or internal packages, Dockerfile, SQL or protobuf schemas.
• The broker-service houses routing logic, gRPC clients, HTTP handlers, RabbitMQ emitters, middlewares (rate limiting).
Key README Insights
• Services expose HTTP endpoints (Gin or net/http) for synchronous calls.
• RabbitMQ is used as the async message broker for log and mail events.
• gRPC is used for Payment-gateway communication from API Gateway.
• PostgreSQL backs Authentication and Enquiry services; MongoDB (or Postgres) is used by Logger; RabbitMQ for messaging; Stripe for payment processing; Next.js for client.
Main Components
• Client (Next.js app)
• API Gateway (broker-service)
• Authentication Service
• Enquiry Service
• Logger Service
• Mailer Service
• Listener Service (RabbitMQ consumer)
• Payment Service
• RabbitMQ message broker
• Databases:
• PostgreSQL (Auth, Enquiry)
• MongoDB (Logger)
• External API: Stripe (Payment)
Relationships and Data Flows
• Client → HTTP → API Gateway
• API Gateway → HTTP → Auth Service (login/signup)
• API Gateway → HTTP → Enquiry Service (properties, schedules)
• API Gateway → gRPC → Payment Service (process payments)
• API Gateway or any service → RabbitMQ → Exchanges (logs, mails, enquiry-mails)
• Listener Service → consumes RabbitMQ queues → invokes Logger Service and Mailer Service via HTTP/gRPC
• Services → Databases for persistence
• Payment Service → Stripe API → returns result → optionally emits invoice mail event to RabbitMQ
Architectural Patterns & Principles
• Microservices: each service packaged and deployed independently (Dockerfile per service).
• API Gateway: central entry point, handles routing, rate limiting, authentication.
• Message-driven architecture: RabbitMQ for loose coupling of log and mail tasks; Listener as an event processor.
• Polyglot persistence: use the right database per domain (Postgres vs. MongoDB).
• gRPC for low-latency, strongly typed inter-service calls (Payment).