At my job, we’ve built a data visualization platform1, ATLAS, around a small number of close client relationships. Now that we’ve reached a level of maturity, we want to demo the platform to prospective clients, but the best demo material lives in the tenancies themselves. It is, after all, the details that make and break a product like ours. So we need a rich demo tenancy with the look and feel of a real tenancy.

We initially thought of fuzzing a tenant’s data beyond recognition, while maintaining important trends and features of the data. Throw some random multipliers into the numerical fields and create mappings for the descriptive fields and you’re doing pretty well. But because of the risk of exposing client data, security reviews of this demo tenancy would have to be very thorough, and tying our demos to a particular tenancy is a risky business. Further, we would have to choose between using a historical snapshot of the client’s (fuzzed) tenancy or taking on the ongoing maintenance costs and security risks associated with keeping our demo tenancy in lock step with the original tenancy.

Outside of special circumstances, we’ve nixed the idea of fuzzing a live tenancy for demo purposes.

Simulating demo data

Our tool, ATLAS, is built on data integration and stories. To show off its best features, the demo data has to have a rich network of datasets from which analysts and AI can create meaningful analyses. Can a simulation be rich enough to show off the features of our tool? And if it’s rich enough, will it have enough internal consistency so that e.g. AI can generate meaningful analysis of the whole data world?

If you generate synthetic data with too much randomness, it won’t make sense. You might find that there are more lead submissions that pageviews on the page where you submit leads. The number of constraints in “the world” is enormous, and building those into a simple random number generator is a non-starter.

In college I experimented with agent-based simulations using NetLogo. If you’re familiar with elementary cellular automata or Conway’s Game of Life, you’ll know that you can get surprisingly organic, emergent behaviors by having simple agents interact with each other, governed by some rules.

I thought this type of simulation would work well for our demo tenancy – not cellular automata but “turtles” (to use NetLogo’s term) that interact with each other and their environment and generate internally consistent data. Ultimately, we want to model users in some domain, like automotive. Potential buyers in an automotive world might get influenced by advertising, browse the brand website, transfer to a dealership site, submit a lead for a car, and then purchase that car.

I’m going to keep using this automotive demo tenant for this post.

There are two parts to such a simulation: running the simulation and generating artifacts. Artifacts in this case are datasets that describe the interactions and outcomes of the turtles in the simulation. One dataset tracks website interactions. Another tracks leads and their outcomes. Another tracks car sales from both leads and “spontaneous” buyers.

The simulation is just a collection of Python objects like World, Website, and Person. When you run World.start(), it spawns the whole world and starts a ticking clock. At each tick, a set of actions take place by invoking methods on the classes within the world. You can make use of randomness to add variety and otherwise just let “nature” run its course.

Generating artifacts

The most interesting design challenge for me was generating the artifacts. In an early version of the simulation, each agent (User, Visit, etc.) was responsible for sending their data to a particular data writer object, which would collect data and periodically write it out. Each Vist object (which represents a visit to the website) sends website interaction data to a WebsiteWriter instance, and when the visit includes a lead submission, then another message is sent to a LeadWriter instance to generate a leads dataset.

While this worked, it was a hassle. Each time we added a dataset to our list of artifacts, we had to update all of the objects in the simulation to send messages to that writer. There was also a lot of duplication of messages, as a Sales writer needs to know about each lead so it can decide whether to convert it to a sale or not. Or maybe the leads writer is responsible for converting leads to sales, so it can mark certain leads as closed? Roles and responsibilities started to get confusing.

Pub/sub pattern

We looked for a way to separate events in the world from the writers who convert those events to datasets. When we phrased the question like this, the answer became clearer: a pub/sub pattern with a message bus. Agents in the simulation can interact with the “world” and publish their activities to a bus, and then writers can subscribe to certain types of messages on the bus that they’re interested in.

This pub/sub pattern turned out to be perfect for our simulation. Visits publish Hit messages when they interact with the site, Hit and Lead messages when they submit a lead, and so on. Each message can be consumed by any number of writers who are interested in the happenings of the world, and each writer can subscribe to multiple types of messages. Messages on the bus are given an expiration, and consumers are responsible for recognizing messages that they’ve already processed.

The world goes on whether or not there are writers, and new datasets can be generated by selecting streams they want to use to write rows. There’s no longer a need for data producers to know anything about data consumers.

What’s more, the pub/sub pattern allows writers to communicate with each other. The LeadWriter picks random leads to convert to sales and publishes those sales as messages on the bus, and the SalesWriter subscribes to that stream. In this way, the leads writer becomes a participant in the world. And if that doesn’t suit you, you can add a LeadCloser actor in the simulation that provides the same role. As long as the message format is the same, the SalesWriter doesn’t care about the refactor.

With Cursor or Claude, setting up a simulation like this takes no time at all: define the artifacts, give some background on the simulation and the pub/sub style of interactions, and you’ve got rich, consistent demo data.

  1. Of course it’s more than just a visualization tool, but for this blogpost, I’m not in sales mode. ↩

Updated: