Hey Developers!
I'm currently building a custom segmentation engine for Shopify-based e-commerce customers — something similar to what Klaviyo offers with its rule-based dynamic segments. I’ve gone through the Segment API Guide and understood how flexible and powerful Klaviyo’s segmentation is.
Right now, I'm trying to design a backend structure that can support conditions across multiple models (like customers, orders, products, etc.) with operators like within_last_days
, contains
, gte
, and more.
Before I go too deep into implementation, I’d love to know from you: How does Klaviyo optimize segment recalculations for large datasets?
Any recommendations on caching strategies or batch evaluations vs real-time evaluations?
If you’ve built something similar, how did you manage parsing user-created conditions into efficient queries?
Would love to hear your thoughts or any best practices. Thanks in advance!