Event Bus & Data Flow
Relevant source files
The following files were used as context for generating this wiki page:
NeXifyAI operates as an event-driven platform where data flows through a centralized order system and an autonomous delivery fabric. The system utilizes BullMQ and Redis for native event-driven workflow services to coordinate between specialized AI agents and system components. All operations, from runtime event detection to final deployment, follow a strict state machine governed by immutable audit trails and quality gates.
Sources: packages/workflows/package.json, services/api/domain.py:12-25, services/api/agents/brain_agents/order-workflow-specialist.md:10-15
Event-Driven Architecture & Delivery Fabric
The platform implements a "Self-Evolving Delivery Fabric" that manages the complete autonomous pipeline from detection to resolution. This fabric processes runtime events and converts them into actionable system entities.
Delivery Fabric Pipeline
The delivery fabric executes a 12-step sequential process to handle system changes and incidents:
- Runtime Event Detection: The Watchdog identifies system changes or drifts.
- Incident Classification: The system classifies the event severity.
- Strategic Planning: The Planner defines the resolution strategy.
- Task Graph Generation: The system decomposes the plan into a directed graph of tasks.
- Team Assembly: The Organization agent selects the appropriate AI experts.
- Workflow Execution: The Autonomous layer runs the actual work.
- PR Generation: The Delivery agent produces code or configuration changes.
- Governance Validation: The Governance layer audits the output.
- Deployment: The Delivery agent pushes changes to production.
- Convergence: The system verifies the desired state is reached.
- Learning & Prevention: The Learning agent stores lessons in the Brain.
- Oracle Update: The final system state is recorded in the Oracle.
Sources: services/runtime/autonomous/self_evolving_delivery_fabric.py:13-28
Workflow Service Stack
The event bus infrastructure relies on the following technologies:
| Component | Technology | Description |
|---|---|---|
| Queue Management | BullMQ | Handles message queuing and job distribution. |
| Message Broker | ioredis | Provides the Redis client for job persistence. |
| Schema Validation | Zod | Ensures event payloads match expected structures. |
| Language | TypeScript | Primary language for workflow service implementation. |
Sources: packages/workflows/package.json:13-17
Data Flow & State Machine
Every task and agent execution in the platform must pass through the order system. The system enforces a strict state machine to ensure data integrity and process visibility.
Order Lifecycle States
The order-workflow-specialist manages the transition of data through the following states:
This diagram shows the mandatory state transitions for every production order within the platform.
Sources: services/api/agents/brain_agents/order-workflow-specialist.md:20-25
Timeline & Audit Events
The system maintains an append-only audit trail through Timeline Events. These events track the history of entities including contacts, conversations, offers, and invoices. Each event records the actor type (AI, admin, customer, or system) and specific action details.
Sources: services/api/domain.py:202-215
Agent Communication & Handoffs
Data flows between agents through a formal Handoff Protocol. This protocol ensures that context is preserved as tasks move between specialized experts.
Handoff Requirements
Every handoff between agents must specify:
- Source and Destination: The sending agent, the receiving agent, and current state.
- Acceptance Criteria: Explicit expectations for the receiving agent.
- Constraints: Forbidden actions or specific procedures to follow.
- Deliverables: The required output format and storage location.
Sources: services/api/agents/brain_agents/order-workflow-specialist.md:55-61
Data Flow Sequence
The following sequence diagram illustrates the flow of a standard task from creation to deployment:
This diagram shows the interaction between the core governance systems, memory layers, and execution agents.
Sources: services/api/agents/brain_agents/order-workflow-specialist.md:40-53, services/api/agents/brain_agents/senior-quality-auditor.md:20-55
Quality Gates & Verification
Data cannot reach production without passing through seven mandatory Quality Gates. These gates act as synchronous blockers in the event flow.
| Gate | Focus | Verification Metric |
|---|---|---|
| 1. Documentation | Architecture | API docs, ADRs, and SOP references exist. |
| 2. Testing | Reliability | Unit coverage ≥80% for P0 tasks. |
| 3. Security | Integrity | No CVEs; secrets stored in vault. |
| 4. Architecture | Consistency | Fits 12-System model; no duplication. |
| 5. Performance | Latency | API p95 <200ms; agent response <5s. |
| 6. Workflow | Traceability | Order exists in workflow system. |
| 7. Agent Quality | Compliance | Brain-First enabled; heartbeat active. |
Sources: services/api/agents/brain_agents/senior-quality-auditor.md:20-55
Summary
The Event Bus and Data Flow in NeXifyAI are characterized by a highly structured, "order-first" approach. By utilizing a 12-step delivery fabric and a BullMQ-backed workflow service, the platform ensures that every system event is classified, planned, and audited. The integration of 7 mandatory quality gates and a formal handoff protocol prevents unverified data or code from reaching production, maintaining high standards for security and architectural integrity.