Modules
Medusa’s architecture is built around modules - isolated, pluggable packages that provide specific commerce functionality. Each module is independently developed, tested, and can be customized or replaced.What are Modules?
Modules are self-contained packages that encapsulate:- Data models - Database entities and schemas
- Business logic - Services that implement domain operations
- Type definitions - TypeScript interfaces and DTOs
- Configuration - Module registration and joiner config
Modules are designed to be swapped, extended, or replaced without affecting other parts of your application. This modular architecture enables you to customize only what you need.
Module Structure
Every module follows a consistent structure:packages/modules/api-key/src/index.ts
Module with Providers
Some modules support multiple provider implementations:packages/modules/analytics/src/index.ts
Core Commerce Modules
Medusa includes 30+ built-in commerce modules organized by domain:Product & Catalog
- Product - Product catalog, variants, options, categories, collections
- Pricing - Price lists, rules, currency management
- Inventory - Stock levels, inventory locations
- Promotion - Discounts, campaigns, promotions
Orders & Checkout
- Cart - Shopping cart management
- Order - Order processing and management
- Payment - Payment processing and providers
- Fulfillment - Shipping and fulfillment providers
Customer & Auth
- Customer - Customer profiles and management
- Auth - Authentication providers and sessions
- User - Admin users and permissions
- RBAC - Role-based access control
Regional & Multi-currency
- Region - Regional settings and configurations
- Currency - Currency definitions and conversions
- Store - Store settings and metadata
- Sales Channel - Multi-channel commerce
Platform Services
- API Key - API key management (secret & publishable)
- Notification - Notification providers and templates
- File - File storage providers
- Translation - Multi-language support
- Analytics - Analytics providers
- Tax - Tax calculation providers
- Settings - Application settings
Infrastructure
- Event Bus - Event distribution (local/Redis)
- Caching - Cache providers (in-memory/Redis)
- Locking - Distributed locking
- Workflow Engine - Background workflow execution (in-memory/Redis)
- Index - Search and indexing
- Link Modules - Dynamic entity relationships
Module Resolution
Modules are registered in the dependency injection container using theModules enum:
packages/core/core-flows/src/api-key/steps/create-api-keys.ts:35-36
Module Service Interface
All module services implement a consistent interface pattern:packages/modules/api-key/src/services/api-key-module-service.ts:44-67
Module Configuration
Configure modules in yourmedusa-config.ts:
Custom Modules
Create custom modules to extend Medusa:Next Steps
Services
Learn how to build module services with decorators
Workflows
Orchestrate module operations with workflows