[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-115369":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":15,"stars7d":16,"stars30d":16,"stars90d":14,"forks30d":14,"starsTrendScore":17,"compositeScore":18,"rankGlobal":9,"rankLanguage":9,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":20,"topics":23,"createdAt":9,"pushedAt":24,"updatedAt":25,"readmeContent":26,"aiSummary":27,"trendingCount":14,"starSnapshotCount":14,"syncStatus":28,"lastSyncTime":29,"discoverSource":30},115369,"payments","dev-marker\u002Fpayments","dev-marker","Payments backend in Go microservices: the code from the YouTube course, one branch per episode",null,"Go",100,41,51,0,6,43,33,81.14,"MIT License",false,"main",true,[],"2026-11-14 00:11:18","2026-11-23 16:04:45","# Payments backend in Go: microservices, built from scratch\n\nThe code from the YouTube course **Build a Production-Grade Payments Backend with Go Microservices**. Every line was typed on camera and every decision is explained in the videos.\n\n- ▶ **Part 1** (episodes 1–14): _link coming soon_\n- ▶ **Part 2** (episodes 15–24): _link coming soon_\n- ▶ **Full course in chapters**, with your progress saved: https:\u002F\u002Fwww.fiston.dev\u002Fcourses\u002Fbuild-a-production-grade-payments-backend-in-go\n\n## Follow along: one branch per episode\n\nEach episode ends with a commit, and each episode has its own branch holding the code **as it is at the end of that episode**. To start an episode where the video starts, check out the previous episode's branch:\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments.git\ncd payments\ngit checkout ep05   # the code at the end of episode 5, where episode 6 begins\n```\n\n`main` holds the latest episode plus this README.\n\nThe Go module is named `github.com\u002Ffiston-user\u002Fpayments`, as typed in the videos. It's only a name: everything builds and runs from this clone as is.\n\n| Branch | Episode | What we build |\n|---|---|---|\n| [`ep01`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep01) | 1. Build a Production-Grade Payments Backend | Project setup and wallet service skeleton |\n| [`ep02`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep02) | 2. Designing a Double-Entry Ledger | Double-entry ledger schema and migrations |\n| [`ep03`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep03) | 3. Type-Safe SQL with sqlc + pgx | Sqlc queries, pgx pool and ledger store |\n| [`ep04`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep04) | 4. Config, Logging & Errors | Config, slog logging, request IDs, middleware and HTTP errors |\n| [`ep05`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep05) | 5. The Wallet API | Wallet API with deposits, validation and keyset pagination |\n| [`ep06`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep06) | 6. Moving Money Safely | Concurrency-safe transfers with row locks, lock ordering and retries |\n| [`ep07`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep07) | 7. Idempotency Keys | Idempotency keys for deposits and transfers, with a Redis fast path |\n| [`ep08`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep08) | 8. The Auth Service | Auth service with argon2id passwords, EdDSA access tokens and rotating refresh tokens |\n| [`ep09`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep09) | 9. gRPC Between Services | GRPC API with buf, interceptors, error codes and a client with deadlines |\n| [`ep10`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep10) | 10. The API Gateway | API gateway with JWT at the edge, Redis rate limits, CORS and timeouts; wallets owned by users |\n| [`ep11`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep11) | 11. Events with NATS JetStream | Events on NATS JetStream through a transactional outbox, with a relay and a durable consumer |\n| [`ep12`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep12) | 12. Transfer Service & Sagas | Transfer service running transfers as sagas, with holds in the wallet, retries and compensation |\n| [`ep13`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep13) | 13. Notification Service | Notification service with idempotent consumers, retries with backoff and a dead-letter queue |\n| [`ep14`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep14) | 14. Observability | OpenTelemetry tracing across HTTP, gRPC and NATS, Prometheus metrics and Grafana dashboards |\n| [`ep15`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep15) | 15. Testing Like a Pro | Integration tests on testcontainers, table tests, ledger invariants, race and fuzz fixes, and a k6 load test |\n| [`ep16`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep16) | 16. Shipping It | Distroless images, probes with draining, embedded migrations, CI, and the system in compose |\n| [`ep17`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep17) | 17. Outbound Webhooks | Signed webhook deliveries with retries, a delivery log, replay, and a verifying receiver |\n| [`ep18`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep18) | 18. Multi-currency & FX | Currency conversion with quotes that expire, exact rates and rounding, four-entry postings, and fees |\n| [`ep19`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep19) | 19. Fraud & Risk Checks | Velocity limits in Redis, a rules engine, and manual review of risky transfers |\n| [`ep20`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep20) | 20. Reconciliation & Reporting | Scheduled jobs with leader election, a nightly ledger reconciliation, and CSV statements and trial balances |\n| [`ep21`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep21) | 21. Security Hardening | MTLS between services, least-privilege database roles, reviewers from their sign-in, an audit log, and govulncheck |\n| [`ep22`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep22) | 22. Performance | A load test that tells the truth, pprof behind mTLS, a proxy buffer pool, an index for statements, and a bulkhead for reports |\n| [`ep23`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep23) | 23. Kubernetes | A kind cluster, one Helm chart for six services, rolling updates under load, and autoscaling |\n| [`ep24`](https:\u002F\u002Fgithub.com\u002Fdev-marker\u002Fpayments\u002Ftree\u002Fep24) | 24. Chaos & the Final Demo | A chaos harness that proves the books balance, Toxiproxy for network faults, and a game day |\n\n## The system\n\nSix Go services in one module, with one PostgreSQL database per service, talking over HTTP, gRPC and NATS JetStream:\n\n| Service | Port | What it does |\n|---|---|---|\n| gateway | 8080 (internal 9080) | the only public entry point: JWT checks, rate limits, routing |\n| wallet | 8081, gRPC 9081 | the double-entry ledger, holds, idempotency, FX conversion |\n| auth | 8082 | users, argon2id passwords, EdDSA access tokens, rotating refresh tokens |\n| transfer | 8083 | transfers as sagas: hold, capture or release, with retries and compensation |\n| notification | 8084 | emails from events, idempotent consumers, a dead-letter queue |\n| webhook | 8085 | signed webhook deliveries with retries, a delivery log and replay |\n\nInfrastructure (Docker Compose): PostgreSQL 17, Redis, NATS JetStream, Mailpit, Jaeger, Prometheus and Grafana.\n\nSome rules the code never breaks:\n\n- Money is an `int64` count of minor units (cents), never a float.\n- Balances are derived from ledger entries, and every transaction's entries sum to zero per currency.\n- Every write that moves money is idempotent, and events leave through a transactional outbox.\n\n## Run it\n\nYou need Go 1.26, Docker, and `make`. The [`golang-migrate`](https:\u002F\u002Fgithub.com\u002Fgolang-migrate\u002Fmigrate), [`sqlc`](https:\u002F\u002Fsqlc.dev) and [`buf`](https:\u002F\u002Fbuf.build) CLIs are only needed to create migrations or regenerate code.\n\n```bash\nmake keys                                         # throwaway signing keys for local development, in secrets\u002F\ndocker compose --profile app up -d --build --wait # infrastructure, migrations and all six services\n```\n\nThen open the `.http` files in [`api\u002F`](api) with the VS Code [REST Client](https:\u002F\u002Fmarketplace.visualstudio.com\u002Fitems?itemName=humao.rest-client) extension and send the requests, starting with `api\u002Fgateway.http`.\n\n| UI | URL |\n|---|---|\n| Mailpit (emails) | http:\u002F\u002Flocalhost:8025 |\n| Jaeger (traces) | http:\u002F\u002Flocalhost:16686 |\n| Prometheus | http:\u002F\u002Flocalhost:9090 |\n| Grafana | http:\u002F\u002Flocalhost:3000 |\n\nTo run a single service from source while you work on it, start the infrastructure with `docker compose up -d`, then `make run-wallet` (or `run-auth`, `run-transfer`, `run-notification`, `run-gateway`, `run-webhook`).\n\n## Tests\n\n```bash\nmake test             # unit tests only, fast\nmake test-integration # against real PostgreSQL, Redis and NATS in throwaway containers (needs Docker)\nmake test-race        # the same with the race detector\nmake loadtest         # a k6 load test of transfers through the gateway (the app profile must be running)\n```\n\n## License\n\n[MIT](LICENSE). This is teaching code: read it, run it, build on it. Treat it as a starting point rather than a drop-in system for moving real money.\n","这是一个基于 Go 语言构建的支付系统后端教学项目，完整复现了 YouTube 课程《Build a Production-Grade Payments Backend with Go Microservices》的代码演进过程。项目采用微服务架构，涵盖钱包服务、双式记账、类型安全 SQL（sqlc + pgx）、并发安全资金转移、幂等性控制（Redis 快路径）、JWT 认证与 gRPC 服务间通信、API 网关、NATS JetStream 事件驱动等核心能力。所有代码按课程集数分分支管理，每支代表单集结束时的可运行状态，适合学习生产级支付系统设计与 Go 微服务工程实践。",2,"2026-11-24 04:50:48","CREATED_QUERY"]