Skip to content

Implement wallet transfer service with idempotency, ledger, and concurrency safety - #106

Open
ashish-kumar-1 wants to merge 14 commits into
Robustrade:mainfrom
ashish-kumar-1:ashish-kumar
Open

Implement wallet transfer service with idempotency, ledger, and concurrency safety#106
ashish-kumar-1 wants to merge 14 commits into
Robustrade:mainfrom
ashish-kumar-1:ashish-kumar

Conversation

@ashish-kumar-1

Copy link
Copy Markdown

Summary

Describe your solution briefly.

AI disclosure

Detail how you used AI to help with your submission (including the tools you used, how
you used them and what your prompts were).
Include these points in detail

  1. What tool you used (Cursor, Claude Code, Antigratvity etc.)
  2. How you generally use the tool for your work.
  3. A transcript of your entire session with your AI tool of choice. You can add this to the repo or email it to us with your submission. If for some reason, this is not possible, give us all the prompts that you used with the AI.

Schema Design

Describe the tables, constraints, and indexes you introduced.

Idempotency Strategy

Explain how duplicate requests are handled safely.

Concurrency Strategy

Explain how you prevent race conditions and double spending.

How to Run

How to Test

Tradeoffs / Assumptions

Checklist

  • Tests pass
  • Lint passes
  • Format check passes
  • README or notes updated
  • PR description explains schema, idempotency, and concurrency

Copilot AI review requested due to automatic review settings July 5, 2026 08:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements a small Go HTTP wallet-to-wallet transfer service with idempotent request handling, double-entry ledger posting, and concurrency-safe balance updates, along with a Postgres-backed repository, an in-memory test store, and a basic server wiring.

Changes:

  • Added TransferService implementing validation, idempotency claim/replay, wallet locking, balance updates, ledger posting, and transfer state transitions.
  • Introduced a repository contract (TxStore / Tx) with Postgres and in-memory implementations plus a Postgres schema.
  • Added unit, HTTP handler, and concurrency tests plus supporting documentation.

Reviewed changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
WALLET_TRANSFER_README.md Documents architecture, schema, idempotency, concurrency, and how to run/test
internal/service/transfer_service.go Core transfer business logic: idempotency + locking + ledger workflow
internal/service/transfer_service_test.go Service-level tests for validation, idempotency, failure modes, and ledger balancing
internal/service/concurrency_test.go Concurrency tests for overdraw prevention and duplicate idempotency keys
internal/repository/repository.go Defines persistence interfaces and idempotency record contract
internal/repository/postgres/postgres.go Postgres implementation: row locks, savepointed idempotency claim, persistence operations
internal/repository/memory/memory.go In-memory TxStore for tests
internal/idgen/idgen.go Random ID generation helper used for transfers/ledger entries
internal/handler/http_handler.go HTTP transport layer mapping domain/service errors to HTTP responses
internal/handler/http_handler_test.go HTTP handler tests for status codes and idempotent replay
internal/domain/wallet.go Wallet entity definition
internal/domain/transfer.go Transfer state machine + ledger entry domain types
internal/domain/errors.go Domain sentinel errors consumed by handler/service
db/schema.sql Postgres DDL for wallets, transfers, ledger entries, idempotency records
cmd/server/main.go Server wiring: DB, store, service, handler, routing
go.mod Go module definition and pgx dependency
go.sum Dependency checksums
AI_USAGE.md AI usage disclosure template

Comment thread internal/service/transfer_service.go Outdated
Comment thread internal/repository/memory/memory.go Outdated
Comment thread internal/repository/postgres/postgres.go Outdated
Comment thread internal/repository/postgres/postgres.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants