Real-time personalization engine & edge CDP β unify customer identities with deterministic + DBSCAN resolution, build audience segments with an AST-based rule engine, personalize experiences with multi-armed bandits, and run A/B tests with Bayesian statistics β all at the edge.
Data Pipeline β’ Quick Start β’ Architecture β’ API β’ Modules β’ Contributing
β Personalizing at scale? Star EdgePersona to support open-source CDP!
ββββββββββββββββββββββββ
β Raw Event Stream β
β (click, view, β
β purchase, login) β
ββββββββββββ¬ββββββββββββ
β
ββββββββββββΌββββββββββββ
β Identity Resolution β
β β
β Deterministic (65%) β
β ββββββββββββββββββ β
β β email + phone β β
β β match β merge β β
β ββββββββββββββββββ β
β + β
β DBSCAN (92%) β
β ββββββββββββββββββ β
β β behavioral β β
β β clustering β β
β ββββββββββββββββββ β
ββββββββββββ¬ββββββββββββ
β
ββββββββββββββββββββΌβββββββββββββββββββ
β β β
ββββββββββΌβββββββ βββββββββΌββββββββ βββββββββΌβββββββ
β Unified β β Segment β β Profile β
β Profile β β Engine (AST) β β Store β
β (canonical β β AND / OR / β β (Redis) β
β JSON) β β NOT / Cond β β < 5ms read β
βββββββββββββββββ βββββββββ¬ββββββββ ββββββββββββββββ
β
ββββββββββΌββββββββ
β Personalize β
β β
β Thompson β
β Sampling UCB1 β
β Rule-based β
ββββββββββ¬ββββββββ
β
ββββββββββΌββββββββ
β Response β
β (content, β
β offer, β
β layout) β
ββββββββββββββββββ
| Feature | Description | Performance |
|---|---|---|
| Identity Resolution | Deterministic (email/phone) + DBSCAN behavioral clustering | 92-95% match rate |
| Segment AST | AND / OR / NOT / Condition expression tree β evaluate in < 1ms | 1M eval/sec |
| Multi-Armed Bandit | Thompson Sampling + UCB1 for explore/exploit | 22% lift vs control |
| A/B Test Engine | Bayesian significance testing with sequential stopping | p-value in real-time |
| Edge Cache | Redis-backed profile store with < 5ms read latency | 10K reads/sec |
| FastAPI Server | Async REST API with auto-docs, OpenAPI, and Pydantic validation | 5K req/sec |
pip install edgepersona
# Start the personalization server
edgepersona serve --port 8000 --redis redis://localhost:6379from edgepersona.segments.engine import SegmentEngine
from edgepersona.segments.ast import And, Or, Condition
# Build a segment: (US OR Canada) AND spent > $500
segment = And([
Or([
Condition("geo.country", "==", "US"),
Condition("geo.country", "==", "CA"),
]),
Condition("lifetime_value", ">", 500),
])
engine = SegmentEngine()
matched = engine.evaluate(segment, user_profile)
# True β user is from US with LTV of $1,200from edgepersona.personalization.bandit import ThompsonSamplingBandit
bandit = ThompsonSamplingBandit(
arms=["control", "variant_a", "variant_b"],
alpha=1.0, beta=1.0,
)
# Select an arm for a user
arm = bandit.select(user_id="u123") # "variant_a"
# Record outcome
bandit.update(arm, reward=1) # Click!
print(bandit.arm_stats)
# [{"arm": "control", "pulls": 1000, "rewards": 120},
# {"arm": "variant_a", "pulls": 1050, "rewards": 210},
# {"arm": "variant_b", "pulls": 950, "rewards": 95}]flowchart TB
subgraph Events["Event Ingestion"]
E1[Click Stream] --> G[Event Gateway]
E2[Server Events] --> G
E3[Mobile Events] --> G
end
subgraph Identity["Identity Layer"]
G --> IR[Identity Resolver]
IR --> DET[Deterministic Match]
IR --> DB[DBSCAN Cluster]
DET --> UP[(Unified Profile)]
DB --> UP
end
subgraph Segmentation["Segmentation"]
UP --> SE[Segment Engine]
R[Rule Definitions] --> AST[AST Parser]
AST --> SE
SE --> SEG[Active Segments]
end
subgraph Personalization["Personalization"]
SEG --> PE[Personalization Engine]
PE --> BT[Multi-Armed Bandit]
PE --> RB[Rule-Based]
PE --> EXP[Experiments]
BT --> DEC[Decision]
RB --> DEC
EXP --> DEC
end
subgraph Delivery["Delivery"]
DEC --> API[FastAPI Response]
DEC --> CACHE[Edge Cache]
CACHE --> FAST[< 5ms Delivery]
end
from edgepersona.experimentation.stats import ab_test
result = ab_test(
control=[0.12, 0.15, 0.11, 0.14, 0.13], # Conversion rates
treatment=[0.18, 0.22, 0.19, 0.21, 0.20],
)
print(f"p-value: {result.p_value:.4f}") # 0.0012
print(f"uplift: {result.uplift:.1%}") # 45.3%
print(f"power: {result.power:.1%}") # 94.2%
print(result.significant) # True β winner!# Get personalized experience
curl http://localhost:8000/api/v1/personalize \
-H "X-User-ID: u123" \
-H "X-Session-ID: sess_abc"
# Track event
curl -X POST http://localhost:8000/api/v1/events \
-H "Content-Type: application/json" \
-d '{"type": "purchase", "user_id": "u123", "value": 49.99}'
# Resolve identity
curl -X POST http://localhost:8000/api/v1/identity/resolve \
-d '{"email": "user@example.com", "device_id": "dev_abc"}'
# Create segment
curl -X PUT http://localhost:8000/api/v1/segments \
-d '{"name": "high_value_us", "rule": {"and": [{"geo.country": "US"}, {"lifetime_value >": 500}]}}'src/edgepersona/
βββ api/
β βββ server.py # FastAPI server (auto-docs at /docs)
βββ identity/
β βββ resolver.py # Deterministic + DBSCAN resolution
βββ segments/
β βββ engine.py # AST-based segment evaluation
β βββ ast.py # Segment expression tree parser
βββ personalization/
β βββ engine.py # Personalization dispatch
β βββ bandit.py # UCB1, Thompson Sampling
βββ experimentation/
β βββ stats.py # Bayesian A/B test analysis
βββ stores/
βββ redis_store.py # Redis-backed profile store
See CONTRIBUTING.md for guidelines.
All repos are free and open-source. β Star what you use!
| Category | Repos |
|---|---|
| LLM & AI | SpecInferKit Β· AetherAgents Β· PromptShield |
| Marketing | AdVerify Β· Attributor Β· InfluencerHub Β· EdgePersona Β· AdVantage Β· BrandMuse Β· CampaignForge |
| Simulation | CivSim Β· EvalScope |
| Operations | OpsFlow |