DEV Community

Michel Bruchet
Michel Bruchet

Posted on

Why We Built NFlux: Simplifying Real-Time Orchestration and Domain-Driven Design in .NET

I built NFlux after years of struggling with boilerplate event code in trading platforms. My goal is to help others avoid the same pitfalls and accelerate their journey into event-driven architectures.

What is Nflux?

Designing real-time systems is one of the hardest challenges in modern software engineering.

Whether you’re building trading platforms, IoT applications, or high-throughput APIs, you need low-latency, fault-tolerant, event-driven architectures that can scale.

That’s exactly what NFlux was created for.

NFlux is an open-source framework built on .NET 9 that makes it easier to design, orchestrate, and observe event-driven domains. Instead of writing endless boilerplate code, you can focus on your business logic, while NFlux handles orchestration, lifecycle management, observability, and integration patterns.

Why NFlux?

Let’s face it:

Writing event publishers and consumers by hand is repetitive.

Keeping track of domain cycles, retries, and orchestration timers is tricky.

Adding metrics, logs, and tracing on top of that often becomes an afterthought.

NFlux removes that friction. It gives you a structured way to:

✅ Define domains that react to events and commands
✅ Orchestrate tenant cycles with built-in timers (inactivity, recycle, retry)
✅ Normalize and process data in real-time pipelines
✅ Expose endpoints with automatic discovery
✅ Collect metrics out of the box using OpenTelemetry

Core Concepts

  1. Domains

In NFlux, a domain represents a self-contained business capability.
Each domain reacts to events and executes commands.

This maps naturally to DDD (Domain-Driven Design): your trading engine, your symbol watcher, or your risk manager can all become independent domains.

  1. Events & Commands

Events describe what happened.

Commands describe what should happen next.

NFlux makes publishing and handling these objects trivial, while providing in-memory event stores for testing and QA.

  1. Orchestrators

Every real-time system needs orchestration.

NFlux provides BaseSocketOrchestratorHostedService, which manages:

  1. Start/stop lifecycle
  2. Inactivity timers
  3. Recycling cycles
  4. Triggered cycles (via events)

This ensures domains keep running without manual babysitting.

  1. Observability First

NFlux integrates with IMeterFactory and OpenTelemetry.
Every endpoint call, event handling, and cycle is tracked with metrics.

That means you get latency histograms, error counters, and symbol metrics without writing a single line of plumbing code.

Example Use Case: Real-Time Symbol Monitoring

Imagine you need to monitor crypto trading pairs in real-time.

With NFlux, you:

  1. Define a DownloadSymbols domain that fetches raw market data.
  2. Normalize symbols into consistent business objects (close price, volume, sparkline, technical indicators).
  3. Orchestrate real-time tickers via a RealtimeSymbolsOrchestrator.

Expose QA endpoints:

  • /qa/metrics → view system health and counts
  • /qa/registry/{TenantId} → view current registry state
  • /qa/watcher/publish → inject fake tickers for E2E testing

Your devs can test the full pipeline by publishing fake tickers and observing the updates flow through the system.

Developer Experience

  1. One of the biggest strengths of NFlux is developer productivity.
  2. Integration tests validate domains in isolation
  3. End-to-End tests (E2E) run against Aspire environments with QA endpoints
  4. In-memory registries and event stores simplify local testing
  5. Auto-discovery of endpoints keeps controllers minimal

This means faster iteration cycles, less boilerplate, and more confidence in production deployments.

Benefits at a Glance

🔹 Strongly-typed events and commands (no weakly typed messaging)
🔹 Event-driven orchestration with tenant awareness
🔹 Plug-and-play observability with OpenTelemetry metrics
🔹 Built-in support for QA and testing endpoints
🔹 Works seamlessly with .NET 9 and Aspire

Next steps for NFlux

  1. Publish stable builds on NuGet.org
  2. Expand documentation with case studies
  3. Provide ready-to-use templates for Aspire projects
  4. Grow the community with contributions and plugins

Github: https://github.com/startpointcorporate/Nflux?tab=readme-ov-file

Conclusion

NFlux is not just another .NET library.
It’s a framework for building reliable, event-driven systems where domains, orchestration, and observability come together.

If you’ve ever struggled with boilerplate event code, missing metrics, or orchestration hacks, NFlux is here to change that.

👉 Explore the repo on GitHub
👉 Install from NuGet (coming soon)
👉 Join the community and contribute

Have you already built event-driven systems in .NET? What were the biggest challenges you faced? Leave a comment — I’d love to hear your experiences and start a discussion

Top comments (0)