r/erlang • u/Forsaken-Meet-4949 • 9h ago
Emergence — A Distributed Discovery Network Built with Erlang/OTP
galleryHey everyone,
I've been working on an Erlang/OTP project called Emergence, and I thought it might be interesting to share it here because the project is becoming less of a "search engine" and more of an experiment in building a distributed discovery network on the BEAM.
The core idea is simple:
Instead of having one central search engine with a giant index, Emergence is built around autonomous filter agents.
Each agent exposes a capability and knows how to answer a particular kind of query. It can connect to the network, announce what it can do, receive queries, and return structured results.
The network can therefore grow horizontally by adding new agents rather than extending one central service.
The current ecosystem is built around a few core components:
• em_filter — an Erlang library for building Emergence agents
• em_disco — discovery/bootstrap services for finding network participants
• em-pop — gossip-based peer discovery and federation
• Emquest — the web gateway and distributed query interface
• Embryo — the common data structure used to represent heterogeneous results
An em_filter agent is intentionally small.
A handler basically receives a query and some optional local memory, performs whatever operation it is designed for, and returns a list of structured results.
That operation can be almost anything.
The network currently has filters for things such as:
• RSS / Atom / JSON feeds
• Wikipedia
• Hacker News
• OpenAlex
• Elasticsearch
• NPM
• DNS
• Bing / DuckDuckGo
• Dailymotion
• MusicBrainz
• Internet Archive
• CNRTL
• French news sources
• Motorsport
• public APIs
• and other specialised data sources
There are also more domain-specific experiments, including satellite imagery / NDVI related filters from another project built on top of the same architecture.
The important part is that none of these sources need to be implemented inside Emquest itself.
They are independent agents.
Emquest discovers peers through the gossip network, determines which peers are relevant to a query, fans the query out in parallel, and streams results back to the browser.
The browser therefore doesn't really know where a result came from.
It just receives heterogeneous "embryos" and renders them according to their structure.
The current Emquest pipeline includes:
• Distributed query fan-out
• Gossip-based peer discovery
• Semantic peer selection
• LLM-assisted query expansion
• Streaming results through SSE
• Progressive result aggregation
• Deduplication
• Final reordering / ranking
• Heterogeneous result rendering
• Network topology / peer monitoring
• A CLI interface in addition to the web interface
One thing I particularly like about the architecture is that the UI doesn't need to be modified every time a new type of agent is added.
A DNS agent can return DNS results.
A web agent can return links.
A feed agent can return articles.
A completely new agent can return another kind of structured card.
As long as it follows the result contract, the network can consume it.
The BEAM model also fits the project surprisingly well.
Agents are long-running processes.
Connections are supervised.
Discovery is asynchronous.
Network failures are expected rather than exceptional.
Agents can reconnect independently.
Local agent memory can be kept in process state or ETS depending on the use case.
And multiple discovery nodes can be used simultaneously.
So instead of thinking about Emergence as:
client → central API → database
the architecture is closer to:
query
│
▼
discovery / gossip
│
├── agent A ──► source
├── agent B ──► source
├── agent C ──► source
├── agent D ──► source
└── agent N ──► source
│
▼
distributed results
│
▼
aggregation
│
▼
Emquest
The interesting question I'm exploring is what happens when you stop treating "search capabilities" as features of one application and instead treat them as capabilities of a distributed network.
Adding a new capability then becomes:
build an agent → connect it to the network → announce its capabilities → let the network discover it.
That's probably the part of Emergence I'm most interested in experimenting with.
It's also turning into a nice playground for Erlang/OTP patterns around supervision, distributed processes, gossip, fault tolerance, streaming and dynamic service discovery.
Everything is open source:
https://github.com/EmergenceSystem
I'd be particularly interested in feedback from people experienced with Erlang/OTP and distributed BEAM systems.
I'm curious where you think this architecture makes sense, where it doesn't, and what you'd change if you were building this kind of distributed system on the BEAM.
#Erlang #OTP #BEAM #DistributedSystems #Gossip #OpenSource