Skip to content

feat: introduce modular production-grade architecture for Pi SDK JS#1

Open
Clawue884 wants to merge 13 commits into
pi-apps:mainfrom
Clawue884:main
Open

feat: introduce modular production-grade architecture for Pi SDK JS#1
Clawue884 wants to merge 13 commits into
pi-apps:mainfrom
Clawue884:main

Conversation

@Clawue884

Copy link
Copy Markdown

🚀 Summary

This PR upgrades pi-sdk-js from a thin browser wrapper into a modular, production-grade SDK architecture suitable for real-world Pi applications such as marketplaces, SaaS platforms, and SuperApps.

The refactor preserves full compatibility with the official Pi Browser SDK while significantly improving maintainability, extensibility, and developer experience.


🧠 Key Improvements

  • ✅ Modular architecture (separation of concerns)
  • ✅ Clear SDK core vs feature modules
  • ✅ Typed payment lifecycle engine
  • ✅ Event-driven design (payment & user events)
  • ✅ Marketplace-ready structure (merchant registry)
  • ✅ Plugin system foundation
  • ✅ Audit trail for payments
  • ✅ Mock-friendly & production-safe design

🗂️ New Structure

src/ ├─ core/ # config, event bus, payment engine ├─ auth/ # Pi authentication ├─ payment/ # payment creation & lifecycle ├─ marketplace/ # merchant abstraction ├─ plugins/ # SDK extension system ├─ audit/ # audit & traceability ├─ types/ # shared TypeScript types ├─ sdk.ts # main SDK class └─ index.ts # public exports


🔄 Backward Compatibility

  • No breaking changes to the underlying Pi Browser SDK usage
  • Still relies on window.Pi as the source of truth
  • Designed as an application-layer SDK, not a consensus or ledger abstraction

🎯 Motivation

This refactor enables:

  • Cleaner long-term maintenance
  • Easier community contribution
  • Advanced use cases (marketplace, escrow, plugins, analytics)
  • Alignment with professional SDK standards (Stripe-like architecture)

🧩 Next Possible Extensions (Out of Scope)

  • Server-side payment verification helpers
  • Escrow & split-payment logic
  • Fraud / analytics plugins
  • Official marketplace examples

Status: Ready for review
Impact: Structural (non-breaking, additive)
Audience: SDK & application developers

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