Skip to content

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

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.

Files to be modified/created:

  • src/core/events.ts (or .js) - New EventBus implementation.
  • src/core/events.test.ts - Unit tests for the bus.
  • Refactoring existing core service files to use the new bus.

Activity

  1. Diwakar-odds commented on Jul 14, 2026

    @Diwakar-odds
    Author

    Hi maintainers! I would love to be assigned to this issue for ECSoC 2026. I am highly interested in building this core backend architecture.

    Understanding the Issue

    The core modules are tightly coupled. Direct function calls between distinct systems (e.g., inventory management, reporting, and external integrations) create rigid dependencies, making the system hard to scale and test.

    Proposed Implementation Plan

    • Implement an Event Bus or Pub/Sub mechanism (using standard Node EventEmitter or a robust alternative) to act as the central communication nervous system.
    • Refactor the core components into independent Observers that subscribe to generic lifecycle events (e.g., onInventoryUpdated, onReportGenerated).
    • Ensure the event payloads follow strict interface contracts so components remain completely agnostic of one another's implementation.

    Files to be Modified/Created

    • src/core/events.ts (NEW) - The central event dispatcher.
    • src/services/... - Refactor tightly coupled calls into event emissions and subscriptions.

    Expected Output

    A highly modular, decoupled architecture where core systems operate completely independently, drastically reducing technical debt and improving testability.

    Please assign me so I can start working on the PR!

  2. github-actions commented on Jul 14, 2026

    @github-actions

    Hi @Diwakar-odds! 👋

    Thank you for your interest in contributing to this repository! Please wait until a maintainer officially assigns you to this issue before opening a Pull Request.

    While you wait, please consider starring ⭐ this repository to show your support! We review requests regularly and will assign it as soon as possible if it's available. Happy coding! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions