How knadh/otpgateway works
OTP Gateway is a standalone, multi-tenant service for initiating address-verification challenges, delivering codes through configurable providers, and checking verification status. Clients can use authenticated HTTP/JSON APIs or the built-in web flow, including its JavaScript modal; users may enter an address when one was not supplied. Redis stores challenge state and attempts. The graph reflects the sampled routing, initialization, handler, and provider code plus README capabilities; unsampled view and handler details are represented conservatively.
Main entry points: handlers.go OTP API and flow handlers · main.go HTTP server and routes · init.go Provider initialization · redis.go Redis OTP store
Components 19
Gateway
- HTTP server and routes
cmd/otpgateway/main.go - Provider initialization
cmd/otpgateway/init.go
Verification
- OTP API and flow handlers
cmd/otpgateway/handlers.go - OTP and provider contracts
pkg/models/models.go
Delivery providers
- SMTP delivery
internal/providers/smtp/smtp.go - Pinpoint SMS
internal/providers/pinpoint/pinpoint.go - Kaleyra SMS and WhatsApp
internal/providers/kaleyra/kaleyra.go - Webhook delivery
internal/providers/webhook/webhook.go
Challenge state
- Store interface
internal/store/store.go - Redis OTP store
internal/store/redis/redis.go
Web experience
- Verification web views
static - JavaScript modal
static/otp.js
Other components
- Application client
- Verifying user
- Redis service
- SMTP service
- AWS Pinpoint
- Kaleyra service
- Webhook endpoint
Connections 26
- Application client → HTTP server and routes: calls APIs
README.md - HTTP server and routes → OTP API and flow handlers: routes requests
cmd/otpgateway/main.go - OTP API and flow handlers → Store interface: reads and updates
cmd/otpgateway/handlers.go - OTP API and flow handlers → OTP and provider contracts: uses OTP data
cmd/otpgateway/handlers.go - OTP API and flow handlers → SMTP delivery: dispatches delivery
- OTP API and flow handlers → Pinpoint SMS: dispatches delivery
- OTP API and flow handlers → Kaleyra SMS and WhatsApp: dispatches delivery
- OTP API and flow handlers → Webhook delivery: dispatches delivery
- HTTP server and routes → Provider initialization: initializes providers
cmd/otpgateway/main.go - Provider initialization → SMTP delivery: constructs provider
cmd/otpgateway/init.go - Provider initialization → Pinpoint SMS: constructs provider
cmd/otpgateway/init.go - Provider initialization → Kaleyra SMS and WhatsApp: constructs provider
cmd/otpgateway/init.go - Provider initialization → Webhook delivery: constructs provider
cmd/otpgateway/init.go - Store interface → OTP and provider contracts: defines OTP operations
internal/store/store.go - Redis OTP store → Store interface: implements
internal/store/redis/redis.go - HTTP server and routes → Redis OTP store: initializes and pings
cmd/otpgateway/main.go - Redis OTP store → Redis service: reads and writes
internal/store/redis/redis.go - SMTP delivery → SMTP service: sends email
internal/providers/smtp/smtp.go - Pinpoint SMS → AWS Pinpoint: sends SMS
internal/providers/pinpoint/pinpoint.go - Kaleyra SMS and WhatsApp → Kaleyra service: sends messages
internal/providers/kaleyra/kaleyra.go - Webhook delivery → Webhook endpoint: posts OTP payload
internal/providers/webhook/webhook.go - Verifying user → Verification web views: uses verification flow
README.md - HTTP server and routes → Verification web views: serves views and assets
cmd/otpgateway/main.go - Verifying user → JavaScript modal: opens modal
static/otp.js - JavaScript modal → HTTP server and routes: loads OTP view
static/otp.js - JavaScript modal → Application client: returns completion callback
README.md