How victorm0nteiro/payrouter works
Payrouter is an early-stage payment-instruction API. Its implemented user workflow authenticates a client, accepts an instruction idempotently, persists its initial event, and serves an authoritative read reconstructed from that event history. The README also describes reconciliation, outbox, Kafka, and projections as design goals or future work; they are not shown as running components because the README says they do not yet exist. Connections below are limited to source excerpts and explicit README statements.
Main entry points: main.go API composition · accept_instruction.go Accept instruction · server.go HTTP routes · get_instruction.go Get instruction
Components 20
API and client access
- API composition
cmd/api/main.go - HTTP routes
internal/adapters/http/server.go - Bearer middleware
internal/adapters/http/auth.go - Client administration
cmd/clientctl/main.go - Accept handler
internal/adapters/http/accept.go - Token handler
internal/adapters/http/auth.go - Instruction handler
internal/adapters/http/get.go - JWT signer
internal/adapters/jwt/signer.go
Application and domain
- Accept instruction
internal/app/accept_instruction.go - Client authentication
internal/app/auth.go - Get instruction
internal/app/get_instruction.go - Instruction state
internal/domain/instruction.go - Storage contracts
internal/app/ports.go
Postgres persistence
- Transaction boundary
internal/adapters/postgres/unitofwork.go - Event store
internal/adapters/postgres/eventstore.go - Idempotency store
internal/adapters/postgres/idempotency.go - Client store
internal/adapters/postgres/clientstore.go - Postgres
migrations/000001_init.up.sql
Other components
- API client
- Client operator
Connections 35
- API client → HTTP routes: sends requests
README.md - Client operator → Client administration: manages clients
README.md - API composition → HTTP routes: starts server
cmd/api/main.go - API composition → Accept instruction: constructs
cmd/api/main.go - API composition → Get instruction: constructs
cmd/api/main.go - API composition → Client authentication: constructs
cmd/api/main.go - API composition → JWT signer: configures
cmd/api/main.go - API composition → Transaction boundary: constructs
cmd/api/main.go - API composition → Event store: constructs
cmd/api/main.go - API composition → Client store: constructs
cmd/api/main.go - HTTP routes → Accept handler: routes to
internal/adapters/http/server.go - HTTP routes → Token handler: routes to
internal/adapters/http/server.go - HTTP routes → Instruction handler: routes to
internal/adapters/http/server.go - API client → Accept handler: submits instruction
README.md - API client → Token handler: requests token
README.md - API client → Instruction handler: queries instruction
README.md - Accept handler → Accept instruction: calls
internal/adapters/http/accept.go - Token handler → Client authentication: calls
internal/adapters/http/auth.go - Instruction handler → Get instruction: calls
internal/adapters/http/get.go - Bearer middleware → JWT signer: verifies token
internal/adapters/http/auth.go - HTTP routes → Bearer middleware: protects routes
internal/adapters/http/server.go - Accept instruction → Instruction state: creates instruction
internal/app/accept_instruction.go - Accept instruction → Transaction boundary: runs transaction
internal/app/accept_instruction.go - Accept instruction → Idempotency store: claims key
internal/app/accept_instruction.go - Accept instruction → Event store: appends event
internal/app/accept_instruction.go - Get instruction → Event store: loads history
internal/app/get_instruction.go - Get instruction → Instruction state: rehydrates state
internal/app/get_instruction.go - Accept instruction → Storage contracts: uses contracts
internal/app/accept_instruction.go - Get instruction → Storage contracts: uses contract
internal/app/get_instruction.go - Client administration → Client store: creates or deactivates
cmd/clientctl/main.go - Event store → Postgres: reads and writes events
internal/adapters/postgres/eventstore.go - Idempotency store → Postgres: reads and writes keys
internal/adapters/postgres/idempotency.go - Client store → Postgres: reads and writes clients
internal/adapters/postgres/clientstore.go - Client authentication → JWT signer: issues token
- Client authentication → Client store: looks up client