What Gets Created
| Entity | Count | Details |
|---|---|---|
| Data Schemas + DDL Tables | 3 | starbucks_customers (1000 rows), starbucks_offers (10 rows), starbucks_events (500 rows) |
| Categories | 3 | Acquisition (BOGO), Retention (Discount), Engagement (Informational) |
| Channels | 4 | Web (banner), Email (email), Mobile (push), Social (social_post) |
| Offers | 10 | 4 BOGO, 4 Discount, 2 Informational — priorities 55-85 |
| Creatives | 40 | 10 offers x 4 channels — each with channel-specific content |
| Qualification Rules | 2 | Min Age 18, Min Income $30k |
| Contact Policies | 2 | Max 3/day frequency cap, 24hr cooldown |
| Outcome Types | 5 | impression, click, accept, convert, dismiss |
| Algorithm Models | 3 | Scorecard, Bayesian (Naive Bayes), Thompson Bandit |
| Experiment | 1 | Scorecard vs Bayesian (80/20 split) |
| Decision Flow | 1 | Full pipeline with 7 stages |
| Segment | 1 | High-Income Members (income > $70k, tenure > 365 days) |
| Interaction History | 500 | 90-day window of synthetic interactions |
| Interaction Summaries | 500 | Materialized aggregates for contact policy enforcement |
Step-by-Step Walkthrough
curl -X POST "http://localhost:3000/api/v1/seed-dataset/starbucks?force=true" \
-H "Content-Type: application/json" \
-H "X-Requested-With: XMLHttpRequest"
The
?force=true parameter removes any previously loaded dataset before seeding. Without it, you will get a 409 Conflict if data already exists.Priority (0-100) determines offer ranking. Score formula:
(priority / 100) x (creative.weight / 100) x fitMultiplier. Higher priority offers score higher in the pipeline.Attributes use schema-prefixed dot notation as literal keys, NOT nested objects. The qualification engine does
context.attributes["starbucks_customers.age"] — so the key must match exactly:curl -X POST "http://localhost:3000/api/v1/algorithm-models/<model-uuid>/train" \
-H "X-Requested-With: XMLHttpRequest"
The pre-loaded experiment splits traffic 80/20 between Scorecard (champion) and Bayesian (challenger):
Key Features Demonstrated
Qualification Rules
Two hard-gate rules filter customers:| Rule | Type | Condition | Priority |
|---|---|---|---|
| Min Age 18 | attribute_condition | starbucks_customers.age >= 18 | 100 (Critical) |
| Min Income $30k | attribute_condition | starbucks_customers.income >= 30000 | 90 (Critical) |
Contact Policies
| Policy | Type | Config |
|---|---|---|
| Max 3 per Day | frequency_cap | maxPerDay: 3 |
| 24hr Cooldown | cooldown | cooldownHours: 24 |
Three Model Types
| Model | Type | How It Learns | Best For |
|---|---|---|---|
| Scorecard | scorecard | Rule-based (manual) | Transparent, explainable scoring |
| Bayesian | bayesian | Auto-incremental, updates every 100 outcomes | Adapts to changing preferences |
| Thompson Bandit | thompson_bandit | Updates Beta(alpha, beta) per arm on each outcome | Exploration/exploitation for new offers |
Decision Pipeline
The pipeline processes candidates through 7 stages:- Inventory — Filters by schedule, flattens offers x creatives into candidates
- Qualification — Hard-gate rules (age, income, segment). Fail = removed
- Contact Policy — Frequency cap, cooldown, mutual exclusion
- Consent — Channel-level consent check
- Guardrails — Business constraint rules
- Scoring — Model-based or priority-weighted
- Ranking — Sort by score, apply limit, diversity constraints
Batch Email via Segments
Use the pre-loaded High-Income Members segment for batch email campaigns:What to Look For
- Qualification blocking: Request without attributes returns 0 decisions. The
debugTraceshows which rules blocked each offer. - Contact policy enforcement: After 3 recommendations in a day, the frequency cap blocks further contact. The 24hr cooldown prevents re-contact too soon.
- Experiment routing: The same customer always lands in the same experiment arm (deterministic hashing). 80% of customers get Scorecard scoring, 20% get Bayesian.
- Adaptive learning: After recording outcomes via
/respond, Bayesian models auto-update every 100 outcomes. Thompson Bandit updates alpha/beta per outcome immediately. - Multi-channel creatives: Each of the 10 offers has 4 creatives (web banner, email, push, social) with channel-appropriate content.
API Quick Reference
| Action | Method | Endpoint |
|---|---|---|
| Load sample data | POST | /api/v1/seed-dataset/starbucks |
| List offers | GET | /api/v1/actions |
| List channels | GET | /api/v1/channels |
| List creatives | GET | /api/v1/treatments |
| Get recommendations | POST | /api/v1/recommend |
| Record outcome | POST | /api/v1/respond |
| Query interaction history | GET | /api/v1/interaction-history |
| Run batch simulation | POST | /api/v1/simulate |
| Train model | POST | /api/v1/algorithm-models/{id}/train |
| Score customer | POST | /api/v1/algorithm-models/{id}/score |
| Create experiment | POST | /api/v1/experiments |