How xseman/bysquare works
Main Components
a) Core Library Components:
• Encoding Module
• Decoding Module
• Validation Layer
• Helper Utilities
• Type Definitions
b) Integration Interfaces:
• CLI Interface
• Browser/Web Interface
• Node.js Interface
• Deno Interface
┌─ Integration Layer ─────────────────────────────┐
• CLI │ Browser │ Node.js │ Deno │
• ┴───────────┴───────────┴────────────────┘
┌─ Public API Layer ──────────────────────────────┐
• encode() │ decode() │ Helper Functions │
• simplePayment() │
• directDebit() │
• standingOrder() │
• ┘
┌─ Core Processing Layer ────────────────────────┐
• ┌─────────────┐ ┌──────────┐ ┌────────────┐ │
• Encoder │ │ Decoder │ │ Validator │ │
• ┘ └──────────┘ └────────────┘ │
• ┘
┌─ Utility Layer ───────────────────────────────┐
• Base32Hex │ CRC32 │ Deburr │ Helpers │
• ┘
Key Elements to Highlight
a) Data Flow:
• Input data → Validation → Encoding → QR string output
• QR string → Decoding → Data model output
b) Cross-cutting Concerns:
• Type checking (types.ts)
• Input validation (validations.ts)
• Character normalization (deburr.ts)
Important Notes
• That this is an ESM-only package
• Relationship between the core library and different runtime environments
• Validation and type checking that occurs at different stages
• Data transformation process (as shown in the README's logic.svg)
Implementation Details
• How the library handles different payment types:
• Simple Payment
• Direct Debit
• Standing Order
• Data model validation flow
• Diacritics removal process (deburr option)
• CRC32 checksum calculation
External Dependencies
• Integration points with QR code generation libraries
• Compatibility with banking apps
• File format support (JSON/JSONL)
This architecture emphasizes the library's modular design and its ability to work across different JavaScript runtimes while maintaining a consistent API for encoding and decoding PAY by square QR codes.