Skip to main content

Database

Database-per-service model

The current repository uses a separate MySQL schema per service.

Schemas created by docker/mysql/init.sql

  • bookstore_auth_db
  • bookstore_user_db
  • bookstore_books_db
  • bookstore_order_db
  • bookstore_notification_db
  • bookstore_payment_db

Additional schema referenced in code

  • bookstore_analytics_db

This analytics schema is referenced by analytics-service, but not created in docker/mysql/init.sql.

Important tables

ServiceTables
auth-serviceauth_users, refresh_tokens
user-serviceusers
book-servicebooks, authors, categories, publishers, book_images, book_authors
order-serviceorders, order_items
payment-servicepayments, payment_items
notification-servicenotifications
analytics-servicedaily_metrics, book_sales, pending_order_items, processed_events

Transaction strategy

  • order-service persists orders and publishes events after commit
  • payment-service persists payment state around Stripe interaction and then publishes outcome events
  • analytics-service uses deduplication rather than distributed transactions