audience
Declarative, rule-based audience segmentation. Segments are defined in
code with the defaudience macro or persisted dynamically in the
database, then evaluated against your user base through a hybrid SQL
predicate pipeline.
Key namespaces
| Namespace | Purpose |
|---|---|
|
Pure: segment records, |
|
Pure: built-in filter types and the |
|
Pure: hybrid SQL + predicate evaluation pipeline |
|
Protocols: |
|
Service orchestrating resolution, caching, and persistence |
|
REST + web endpoints (CRUD, preview, evaluate, members) |
Built-in filter types
| Filter | Matches on |
|---|---|
|
Age, gender, and other profile attributes |
|
Country, region, city |
|
Assigned user roles |
|
Time since account creation |
|
Recency of last activity |
|
Recorded user events / actions |
|
Use of specific product features |
Each filter is resolved through the filter→sql and
filter→predicate multimethods. SQL-eligible filters are pushed to the
database; the rest run as Clojure predicates over the candidate set.
Define new methods on both multimethods to add custom filter types.
Composition
Segments compose with AND / OR / NOT. Circular references between composed segments are detected and rejected at definition time.
Dynamic segments
Segments can also be stored in the database as JSON and loaded at runtime. Incoming JSON is schema-validated, and fn-typed values are rejected so persisted definitions stay data-only.
Caching
Membership results are cached in an audience_memberships table with a
configurable per-segment TTL, served through the IAudienceCache
component.
Builder UI
A segment builder is served over HTMX, with Replicant widget mount points for the filter panel and the composition builder.
Endpoints
| Endpoint group | Purpose |
|---|---|
CRUD |
Create, read, update, delete segments |
Preview |
Count + sample of matching members |
Evaluate |
Run evaluation and cache the result |
Members |
List cached members of a segment |