# meenachinmay/microservices-golang architecture

> Architecture diagram of the GitHub repository meenachinmay/microservices-golang, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/meenachinmay/microservices-golang
- Repository: https://github.com/meenachinmay/microservices-golang

## Overview

##### 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).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    Client["Client (Next.js App)"]:::client
    FrontEndUI["Front-end (Go Web UI)"]:::client

    %% API Gateway
    APIGW["API Gateway\n(broker-service)"]:::gateway

    %% Core Services
    subgraph "Core Services"
        Auth["Authentication Service"]:::service
        Enquiry["Enquiry Service"]:::service
        Payment["Payment Service"]:::service
    end

    %% Event & Messaging
    subgraph "Event Processing" 
        RabbitMQ["RabbitMQ\nMessage Broker"]:::broker
        Listener["Listener Service"]:::processor
        Mailer["Mailer Service"]:::service
        Logger["Logger Service"]:::service
    end

    %% Databases & External
    Postgres["PostgreSQL\n(Auth & Enquiry)"]:::db
    Mongo["MongoDB\n(Logger)"]:::db
    Stripe["Stripe API"]:::external
    DockerCompose["Docker Compose"]:::infra

    %% Flows
    Client -->|"HTTP"| APIGW
    FrontEndUI -->|"HTTP"| APIGW

    APIGW -->|"HTTP"| Auth
    APIGW -->|"HTTP"| Enquiry
    APIGW -->|"gRPC"| Payment

    APIGW -->|AMQP| RabbitMQ
    Auth -->|SQL| Postgres
    Enquiry -->|SQL| Postgres

    RabbitMQ -->|AMQP| Listener
    Listener -->|"HTTP"| Logger
    Listener -->|"HTTP"| Mailer

    Logger -->|NoSQL| Mongo
    Mailer -->|—| Mongo

    Payment -->|"Stripe REST"| Stripe
    Payment -->|AMQP| RabbitMQ

    DockerCompose---APIGW
    DockerCompose---Auth
    DockerCompose---Enquiry
    DockerCompose---Payment
    DockerCompose---Logger
    DockerCompose---Mailer
    DockerCompose---Listener
    DockerCompose---RabbitMQ
    DockerCompose---Client
    DockerCompose---FrontEndUI

    %% Click Events
    click Client "https://github.com/meenachinmay/microservices-golang/tree/main/client/"
    click FrontEndUI "https://github.com/meenachinmay/microservices-golang/tree/main/front-end/"
    click APIGW "https://github.com/meenachinmay/microservices-golang/tree/main/broker-service/"
    click Auth "https://github.com/meenachinmay/microservices-golang/tree/main/authentication-service/"
    click Enquiry "https://github.com/meenachinmay/microservices-golang/tree/main/enquiry-service/"
    click Payment "https://github.com/meenachinmay/microservices-golang/tree/main/payment-service/"
    click Logger "https://github.com/meenachinmay/microservices-golang/tree/main/logger-service/"
    click Mailer "https://github.com/meenachinmay/microservices-golang/tree/main/mail-service/"
    click Listener "https://github.com/meenachinmay/microservices-golang/tree/main/listener-service/"
    click RabbitMQ "https://github.com/meenachinmay/microservices-golang/blob/main/broker-service/actions/emitter.go"
    click Postgres "https://github.com/meenachinmay/microservices-golang/tree/main/authentication-service/sql/schema/"
    click Mongo "https://github.com/meenachinmay/microservices-golang/tree/main/logger-service/sql/schema/"
    click Stripe "https://github.com/meenachinmay/microservices-golang/tree/main/payment-service/grpc/proto/"
    click DockerCompose "https://github.com/meenachinmay/microservices-golang/blob/main/project/docker-compose.yml"

    %% Styles
    classDef client fill:#88CCEE,stroke:#333,stroke-width:1px
    classDef gateway fill:#4477AA,stroke:#333,stroke-width:1px
    classDef service fill:#44AA77,stroke:#333,stroke-width:1px
    classDef processor fill:#EE9966,stroke:#333,stroke-width:1px
    classDef broker fill:#CCBB44,stroke:#333,stroke-width:1px
    classDef db fill:#999999,stroke:#333,stroke-width:1px
    classDef external fill:#AA3377,stroke:#333,stroke-width:1px
    classDef infra fill:#DDDDDD,stroke:#333,stroke-width:1px
```
