Skip to content

feat(arch): implement event-driven architecture and decoupled observer pattern for core modules #225

Description

@Diwakar-odds

Summary

Currently, the core modules appear to be tightly coupled when handling state changes and cross-module communication. Implementing a robust Event-Driven Architecture (using an EventEmitter or Pub-Sub pattern) will decouple these services and improve the scalability and maintainability of the codebase.

Motivation

Tightly coupled services make unit testing difficult and increase the risk of regressions when modifying core flows. By introducing an event bus, we can allow different components to react to state changes asynchronously.

Acceptance Criteria

  • Implement a centralized Event Bus / Pub-Sub broker.
  • Refactor at least one core workflow to use the new event system instead of direct method calls.
  • Add unit tests verifying the decoupled event firing and handling.

How to Test

  • Run the unit test suite to ensure the event bus routes messages correctly.
  • Verify that the refactored workflow behaves functionally identically to the old direct-invocation approach.

Assignment Request (L3/Core Feature)

I would like to be assigned to this issue. Below is my proposed implementation plan:

Step-by-Step Implementation Plan:

  1. Design Event Bus: Create a centralized EventBus class.
  2. Define Event Contracts: Define strict types/interfaces for the event payloads to ensure type safety across the application.
  3. Refactor Core Service: Identify a core service currently using direct dependencies, and replace the direct call with an EventBus.emit() and corresponding .on() listener.
  4. Testing: Write unit tests for the EventBus, verifying single, multiple, and wildcard event listeners.

Could you also please add the ECSoC26 label?

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions