How rsc-labs/medusa-affiliate-discount works
Main Components
a) Core Components:
• Affiliate Discount Service (Central Component)
• Admin API Layer
• Database Models
• Event Subscribers
• Admin UI Widget
b) External Integration Points:
• Medusa Core
• Order Processing System
• Event Bus (Redis recommended)
Component Relationships
┌─────────────────┐ ┌───────────────────┐
• Admin UI │ │ Admin API │
• Widget ├────────►│ Endpoints │
• ┘ └─────────┬─────────┘
• ┌─────────▼─────────┐
• Affiliate │
• Discount Service │
• ┬─────────┘
• ┌──────────────┬──────┴───────┬────────────┐
• ▼ ▼ ▼ ▼
• ┌─────────────────┐ ┌─────┐ ┌──────────────┐ ┌─────────┐
• Event │ │ │ │ Database │ │ Medusa │
• Subscribers │ │Redis│ │ Models │ │ Core │
• ┘ └─────┘ └──────────────┘ └─────────┘
Key Elements to Highlight
a) Data Flow:
• How affiliate discount creation flows from UI to database
• Event-based calculation of earnings
• Demonstrate integration with order processing
b) Integration Points:
• Redis event bus connection
• Medusa core integration points
• Database interaction paths
Important Details
• Commission calculation flow
• Single-region limitation
• Customer-discount relationship
Technical Specifications
• TypeScript implementation
• Medusa plugin architecture
• Database migrations
• Event-driven architecture