Skip to content

docs: ecommerce-as-plugin ADR + README plugins section#54

Open
thunpisit wants to merge 2 commits into
mainfrom
feat/ecommerce-plugin-adr
Open

docs: ecommerce-as-plugin ADR + README plugins section#54
thunpisit wants to merge 2 commits into
mainfrom
feat/ecommerce-plugin-adr

Conversation

@thunpisit

Copy link
Copy Markdown
Contributor

Summary

Proposes an official plugin mechanism for Khao Pad and ships the ADR for the first plugin: `@khaopad/plugin-shop` — small ecommerce for Thailand-first sites using BeamCheckout.

Why

The `codustry/bactrack-website` fork (live at bactrack.in.th) has a working, production-tested shop implementation with:

  • 8 D1 tables (`carts`, `cart_items`, `orders`, `order_items`, `discount_codes`, `discount_redemptions`, `affiliates`, `affiliate_referrals`)
  • BeamCheckout integration — PromptPay QR + credit card 3DS + LINE Pay + TrueMoney
  • Public store surface (cart / checkout / pay / order / lookup)
  • CMS admin at `/cms/shop/{orders,discount-codes,affiliates}`
  • Money in integer satang (never float)
  • Discount codes + affiliate referrals + receipt emails via Resend
  • Product catalog as static TypeScript (not D1 rows) — perfect fit for small catalogs (5-50 SKUs)

The whole thing sits cleanly beside Khao Pad's v2.0 surface — never modifies core tables, never assumes a shop exists in any core code path. That structure is exactly what a plugin should look like. Formalizing it lets:

  • BACtrack become maintainable via `pnpm update` instead of manual upstream sync
  • Any future Codustry client site add commerce without a fork
  • Core Khao Pad stay lean for the 90% of sites that never need ecommerce

What's in this PR

  • `docs/adr/0001-shop-as-optional-plugin.md` — full ADR (context, decision, plugin contract, schema list, routes, settings card, rationale, consequences, roadmap through v0.3, alternatives considered, open questions)
  • `README.md` — new "Plugins (proposed for post-v2.0)" section between v2.0 and Platform fundamentals; describes the shop plugin at a high level and links the ADR

Explicitly not in this PR

The plugin mechanism itself. This PR is docs-only — an ADR to socialize the design before writing plugin infrastructure code. If reception is positive, next PR would be:

  1. Plugin loader (schema concat + route mount + sidebar merge + audit + webhook + settings + i18n)
  2. `@khaopad/plugin-shop` v0.1 based on the ADR

Estimated ~2 weeks focused work for both.

Test plan

  • Doc-only PR — no code changes, no build to verify
  • Links check (all internal doc paths + external Beam docs URL)
  • Feedback on the ADR before writing any plugin infrastructure

🤖 Generated with Claude Code

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