50K self-hosted installations from a single repository at Chatwoot

By Shivam Mishra

Elevator Pitch

At Chatwoot with over 50K self-hosted installs, we manage both community and enterprise editions in a single repository. The talk is about how we achieve seamless transitions between them, our approach when developing features that ensure the software works when the enterprise code is stripped away.

Description

Chatwoot is an open source customer engagement and communication platform with close to 20K stars on GitHub. We have over 50,000 community installations. Our SaaS platform has scaled to over 40K active accounts, 1 Million messages weekly from various sources like Email, Facebook, Instagram, WhatsApp and more. Our tech stack is fairly boring, we have a Rails Monolith, realtime events (a lot of them) with ActionCable, background jobs with Sidekiq, PostgreSQL and Redis, and growing healthily with a 99.99% uptime for the past 1 year which we have managed to scale to processing 50 Million messages so far.

Chatwoot is a dual license project, most of our codebase is permissively licensed (MIT Expat) but for customers that want more features or want to run Chatwoot as a SaaS platform themselves, we have an enterprise edition. The code for all enterprise features is in the same repository as the community edition under the enterprise folder, however when building the community docker, we delete the entire folder. We have had to take special care to ensure that the app continues to function without any hiccups even when the code folder is removed, and can seamlessly transition to the enterprise edition when required.

There are other ways to achieve this, this talk will discuss the alternatives, the architectural decisions we have to take when building something like this and our early inspirations from GitLab. I’ll also briefly mention the new challenges we are facing with respect to modularity of the software and how we’re planning to tackle it.

Notes

This talk is mostly focused on code organization and architecture, the best audience for this would be someone already working with Ruby for a while. Our way has proven successful with over 50K installations, and we have discovered a lot about how to do this perfectly over the last few years maintaining this. This talk is unique such that it doesn’t talk about a specific feature of Ruby or Rails, just talks about smartly using module instance methods like include, extend, and prepend. I’ll include real examples from our codebase, for example how we extend a class to provide extra AI features in the enterprise edition while still reusing the core module from the community edition.