How romanitalian/durapay works
Durapay is a reference payment application built around durable, resumable order-payment workflows. The main path is client order submission through REST or gRPC, order creation and workflow enqueueing, then worker-side payment, event publication, and notification. Separate branches provide administrative order/user/feature-flag operations, authentication, and observability. README statements describe workflow steps and PostgreSQL durability; sampled runtime and handler excerpts establish several wiring and call relationships. Other subsystem details are retained where documented, without inferring unsampled connections.
Main entry points: runtime.go Runtime wiring · order_payment.go Payment workflow · order_repo.go Order repository · admin_service.go Admin service
Components 20
Order interfaces
- REST API
internal/handler/httpapi/handler.go - gRPC API
internal/handler/grpcapi/server.go - Order service
internal/service/order_service.go - Order repository
internal/repo/order_repo.go
Payment processing
- Worker process
cmd/worker/main.go - Payment workflow
internal/workflow/order_payment.go - Mock payment provider
internal/payment/provider.go - Circuit breaker
internal/circuitbreaker/breaker.go - NATS events
internal/natsx/publisher.go - Notification fanout
internal/alert/notifier.go
Administration
- Admin console
internal/handler/adminui/handler.go - Admin service
internal/service/admin_service.go - Admin authentication
internal/adminauth/auth.go - Cognito OIDC
internal/adminauth/cognito_oidc.go - Admin repositories
internal/repo - Feature flags
internal/featureflag/store.go
Runtime services
- PostgreSQL
- Runtime wiring
internal/app/runtime.go - Observability
internal/telemetry/otel.go
Other components
- Client
Connections 27
- Client → REST API: submits orders
README.md - REST API → Order service: calls
internal/handler/httpapi/handler.go - gRPC API → Order service: calls
internal/handler/grpcapi/server.go - Order service → Order repository: persists orders
internal/service/order_service.go - Order service → Payment workflow: starts workflow
internal/service/order_service.go - Payment workflow → Mock payment provider: charges payment
internal/workflow/order_payment.go - Payment workflow → Order repository: updates order
README.md - Mock payment provider → Order repository: stores charges
internal/payment/provider.go - Mock payment provider → Circuit breaker: checks failures
internal/payment/provider.go - Payment workflow → NATS events: publishes paid event
README.md - Payment workflow → Notification fanout: runs fanout
README.md - Worker process → Payment workflow: registers workflow
cmd/worker/main.go - Order repository → PostgreSQL: reads and writes
README.md - Admin console → Admin authentication: authenticates requests
internal/handler/adminui/handler.go - Admin console → Cognito OIDC: exchanges login code
internal/handler/adminui/handler.go - Admin console → Admin service: handles admin actions
internal/handler/adminui/handler.go - Admin service → Order repository: reads order data
internal/service/admin_service.go - Admin service → Payment workflow: re-enqueues retry
internal/service/admin_service.go - Admin service → Notification fanout: resends notifications
internal/service/admin_service.go - Admin service → Admin repositories: manages users and flags
internal/service/admin_service.go - Runtime wiring → REST API: builds handler
internal/app/runtime.go - Runtime wiring → gRPC API: registers server
internal/app/runtime.go - Runtime wiring → Order repository: creates repository
internal/app/runtime.go - Runtime wiring → Mock payment provider: configures provider
internal/app/runtime.go - Runtime wiring → NATS events: connects publisher
internal/app/runtime.go - Runtime wiring → Observability: initializes tracing
- Runtime wiring → Feature flags: provides flag store
internal/app/runtime.go