Skip to content

feat: add booking sample application#2

Merged
alexeyzimarev merged 8 commits intomainfrom
feat/booking-sample
Mar 25, 2026
Merged

feat: add booking sample application#2
alexeyzimarev merged 8 commits intomainfrom
feat/booking-sample

Conversation

@alexeyzimarev
Copy link
Copy Markdown
Contributor

Summary

  • Adds a complete booking sample app (samples/booking/) demonstrating the full Eventuous Go event sourcing cycle: commands → events → store → subscribe → project → query
  • Functional command service with 3 handlers (BookRoom, RecordPayment, CancelBooking), KurrentDB event store, catch-up subscription, and two in-memory read model projections (BookingDetails + MyBookings)
  • HTTP API with 5 endpoints using stdlib net/http, graceful shutdown, error mapping
  • 24 tests across domain, readmodel, and httpapi packages — all passing with -race

Test plan

  • go test -race ./... passes in samples/booking/
  • gofmt -l clean
  • go vet ./... clean
  • core module tests unaffected
  • Manual smoke test with running KurrentDB (KURRENTDB_URL=esdb://localhost:2113?tls=false go run .)

🤖 Generated with Claude Code

alexeyzimarev and others added 8 commits March 25, 2026 19:56
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…kings projections

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Wires KurrentDB client, codec, event store, functional command service
with three handlers, in-memory read model, catch-up subscription with
logging middleware, and HTTP server with graceful shutdown.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…HTTP tests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b28ab5715d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +45 to +49
if state.Paid {
return nil, ErrBookingAlreadyPaid
}
return []any{
PaymentRecorded{
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reject invalid payment amounts before recording event

HandleRecordPayment only checks cancellation/paid flags and then always emits PaymentRecorded with cmd.Amount. This allows amount <= 0 (which can increase outstanding balance) and amount > state.Outstanding (which drives outstanding negative), so write-side state and API responses can become financially invalid for a booking.

Useful? React with 👍 / 👎.

Comment on lines +50 to +53
BookingID: cmd.BookingID,
Amount: cmd.Amount,
Currency: cmd.Currency,
PaymentID: cmd.PaymentID,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Enforce payment currency matches booking currency

The payment handler never validates cmd.Currency against state.Currency before recording the event, so a booking priced in one currency can be marked paid by a payment in another currency without conversion. That produces incorrect balances whenever clients submit a mismatched currency code.

Useful? React with 👍 / 👎.

@alexeyzimarev
Copy link
Copy Markdown
Contributor Author

/review

@alexeyzimarev alexeyzimarev merged commit ee5bd75 into main Mar 25, 2026
7 checks passed
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.

1 participant