How mamangrust/payment-gateway-grpc works
Main System Components
a) Client-Facing Layer:
• REST API (Echo Framework)
• gRPC Server
• Authentication/Authorization Middleware
b) Core Services Layer:
• Auth Service
• User Service
• Card Service
• Merchant Service
• Transaction Service
• Transfer Service
• TopUp Service
• Withdraw Service
• Saldo Service
c) Data Layer:
• PostgreSQL Database
• Migration System
Architectural Patterns to Highlight
The project follows a clean architecture pattern with clear separation of concerns:
• Handler Layer (internal/handler/api and internal/handler/gapi)
• Service Layer (internal/service)
• Repository Layer (internal/repository)
• Domain Layer (internal/domain)
┌─────────────────────────────────────────────────────────┐
• Client Applications │
• (Mobile Apps, Frontend Apps, External Integrations) │
• ┘
• ↓ ↑
┌─────────────────────────────────────────────────────────┐
• Gateway Layer │
• ┌───────────────┐ ┌──────────────────┐ │
• REST API │ │ gRPC Server │ │
• (Echo) │ │ │ │
• ┘ └──────────────────┘ │
• ┘
• ↓ ↑
┌─────────────────────────────────────────────────────────┐
• Middleware Layer │
• Auth Middleware | Role Middleware | API Key │
• ┘
• ↓ ↑
┌─────────────────────────────────────────────────────────┐
• Service Layer │
• ┌────────────┐ ┌────────────┐ ┌────────────────────┐ │
• Auth Service│ │User Service│ │Transaction Service │ │
• ┘ └────────────┘ └────────────────────┘ │
• ┌────────────┐ ┌────────────┐ ┌────────────────────┐ │
• Card Service│ │Merchant Svc│ │Transfer Service │ │
• ┘ └────────────┘ └────────────────────┘ │
• ┘
• ↓ ↑
┌─────────────────────────────────────────────────────────┐
• Repository Layer │
• (Database Access Layer with SQL Queries) │
• ┘
• ↓ ↑
┌─────────────────────────────────────────────────────────┐
• Database Layer │
• PostgreSQL │
• ┘
Additional Elements
a) External Components:
• Authentication system (JWT)
• API Key validation
• Database migrations
b) Cross-Cutting Concerns:
• Logging system
• Error handling
• Data validation
Important Relationships
• Client → API Gateway (REST/gRPC)
• API Gateway → Middleware → Services
• Services → Repositories
• Repositories → Database
• Cross-service communication patterns
Technical Details to Note
• Protocol Buffers definitions (pkg/proto)
• Database migrations (pkg/database/migrations)
• Test coverage (tests/integration_test, tests/unit_test)
• Configuration management (.env, docker.env)