Engineering Design
Plugin Architecture

Plugin Architecture

Medusa v2 Plugin System

Medusa v2 plugins are Node packages that export modules, API routes, workflows, and subscribers. Plugins are registered in medusa-config.ts under the plugins array.

Vespertene Plugin Strategy

The invite system and download delivery are reusable across future Vespertene client stores. Extract them as plugins after their respective sprints are stable, even while they live in the monorepo.

PluginPackage nameExtracts when
Invite system@vespertene/medusa-plugin-invitesAfter Sprint 5 is stable
Digital downloads@vespertene/medusa-plugin-downloadsAfter Sprint 4 is stable
Promo codes (extended)@vespertene/medusa-plugin-promosPhase 2

Workflow Hooks for Extensibility

Every custom workflow should expose hooks at meaningful points so future plugins can inject logic without forking the workflow.

// expose a hook after download links are created
export const createDownloadLinksWorkflow = createWorkflow(
  "create-download-links",
  (input) => {
    const links = createLinksStep(input)
    createDownloadLinksWorkflow.hooks.linksCreated({ links })
    return new WorkflowResponse(links)
  }
)