How moleculerjs/moleculer works
Main Components
a. Core Framework Components:
• Service Broker (central component)
• Service Registry
• Transit System
• Context System
• Middleware Pipeline
b. Plugin Systems:
• Transporters (TCP, NATS, MQTT, Redis, Kafka, AMQP)
• Serializers (JSON, Avro, MsgPack, ProtoBuf, etc.)
• Cachers (Memory, Redis)
• Validators
• Loggers
• Metrics & Tracing systems
c. Service Management:
• Service Discovery
• Load Balancing
• Fault Tolerance features
┌─────────────────────────────────────────────────────────┐
• Client Applications │
• ┘
• ↕
┌─────────────────────────────────────────────────────────┐
• API Gateway │
• ┘
• ↕
┌─────────────────────────────────────────────────────────┐
• Service Broker Layer │
• ┬─────────────┬──────────────┬─────────────┤
• Registry │ Transit │ Middleware │ Context │
• ┴─────────────┴──────────────┴─────────────┘
• ↕
┌─────────────────────────────────────────────────────────┐
• Plugin Systems │
• ┬──────────┬─────────┬──────────┬─────────────┤
• Transport │Serializer│ Cacher │ Validator│ Logger │
• ┴──────────┴─────────┴──────────┴─────────────┘
• ↕
┌─────────────────────────────────────────────────────────┐
• Services Layer │
• ┬─────────────┬──────────────┬─────────────┤
• Service A │ Service B │ Service C │ Service D │
• ┴─────────────┴──────────────┴─────────────┘
Important Relationships
• Service-to-Service communication paths
• Broker-to-Broker communication
• Plugin integration points
• Event flow paths
• Request-reply patterns
Additional Elements
• Fault tolerance patterns (Circuit Breaker, Bulkhead, Retry)
• Metrics and tracing flows
• Service discovery mechanisms
Technical Details
• Transport protocol options
• Serialization formats
• Caching mechanisms
• Load balancing strategies
• Service lifecycle hooks
Specific Implementation Notes
• Version numbers for services
• Scalability points
• Hot-reload capabilities