Civic Innovations

Technology, Government Innovation, and Open Data


Revisiting an Old Idea: Building a Rules Engine with CouchDB

A few years back, while working at 18F, I created a prototype that explored something a bit unconventional: using CouchDB’s document validation functions as the foundation for a rules engine. The idea was to leverage CouchDB’s built-in validation capabilities to create business rules that could be applied to documents as they’re inserted or updated.

I’ve always been somewhat obsessed with CouchDB—there’s something elegant about its document-oriented approach and the way it handles replication, versioning, and distributed architectures. (Here’s a video I made over 10 years ago showing how to load polling location data into a CouchDB instance.) So even though my prototype remained just that, the concept has continued to bubble in the back of my brain.

Recently, I decided to dust off this old project and give it the attention it deserves. I’ve worked to develop a comprehensive roadmap to transform the basic prototype into a more functional and usable product that truly leverages CouchDB’s unique strengths.

What Makes This Interesting

Instead of building yet another traditional rules engine, this approach uses CouchDB’s native validation functions as the rule execution environment. This means:

The roadmap I’ve created takes my earlier work from a proof-of-concept to a (hopefully) production-ready system with a web-based rule management interface, comprehensive testing infrastructure, and advanced rule capabilities—all while maintaining the elegance of the core CouchDB foundation.

Looking Ahead

Over the next few weeks (again, hopefully), I’ll be working through the development phases, starting with a modern testing framework and a clean web interface for rule management. The goal is to create something that demonstrates how CouchDB’s unique features can be leveraged in ways that traditional databases simply can’t match.

If you’re interested in following along or have thoughts about creative uses for CouchDB, I’d love to hear from you. Sometimes the most interesting solutions come from pushing familiar tools in unexpected directions.

Fediverse Reactions

4 responses to “Revisiting an Old Idea: Building a Rules Engine with CouchDB”

  1. @civic.io This reminds me of a blog post I wrote a while back:https://blog.cloudant.com/2020/07/24/JSON-Schema-Validation.html – but it sounds like you're taking this to the next level!

  2. @civic.io @mheadd As it happens, the project I'm on is leveraging SpiffWorkflow, which brings BPMN and DMN into the range of two-pizza teams… and makes a pretty good foundation for a shared-service! Here's an example of how easy it is to expose DMN rules as an API.
    https://youtu.be/q5VIOuaWx30?si=xy22zaFE0qbW6hHB

  3. @civic.io @mheadd There are docs here, though they don't go into the full power of DMN. For example, tables can ladder up into higher level decisions in a Decision Requirements Diagram (DRD).
    https://spiff-arena.readthedocs.io/en/latest/reference/bpmn/decision_tables.html

  4. […] Headd has embarked on building a rules engine using CouchDB [Mark Headd on Civic Innovations and […]

Leave a comment

About Me

I am the former Chief Data Officer for the City of Philadelphia. I also served as Director of Government Relations at Code for America, and as Director of the State of Delaware’s Government Information Center. For about six years, I served in the General Services Administration’s Technology Transformation Services (TTS), and helped pioneer their work with state and local governments. I also led platform evangelism efforts for TTS’ cloud platform, which supports over 30 critical federal agency systems.