Real-time, AI-powered personalization engine that adapts to every user's unique aura. Dynamically segments users and delivers hyper-personalized website experiences.
AURA = Adaptive User Response Agent
- Overview
- Architecture
- Prerequisites
- Quick Start
- Installation
- Configuration
- API Reference
- Development
- Testing
- Deployment
- Monitoring
- Troubleshooting
- Contributing
AURA (Adaptive User Response Agent) is a real-time personalization platform that perceives each user's unique digital aura and adapts content accordingly. The system:
- Perceives user behavior through event streams
- Segments users into dynamic micro-segments based on intent and behavior
- Decides which content to show using contextual multi-armed bandits
- Learns continuously through reinforcement learning
- 🎯 Real-time micro-segmentation with intent inference
- 🤖 Contextual bandit decisioning (Thompson Sampling / LinUCB)
- 📊 Built-in experimentation framework (A/B + MAB)
- 🔒 Privacy-first with GDPR/CCPA/DPDP compliance
- ⚡ <100ms p95 latency at 500+ RPS
- 📈 10-20% conversion rate uplift
- Homepage hero modules
- Blog/article index ordering
- Product listing pages
- Promotional banners
flowchart TB
subgraph Client["Client Layer"]
SDK[Web/App SDK]
Tracker[Event Tracker]
end
subgraph Edge["Edge Layer"]
Collector[Event Collector]
CDN[CDN/Cache]
end
subgraph Data["Data Layer"]
CDP[CDP/Analytics]
Stream[Event Stream]
Warehouse[Data Warehouse]
FeatureStore[Feature Store]
VectorDB[Vector Database]
end
subgraph AI["AI Agent Core"]
Perception[Perception Service]
Segmentation[Segmentation Engine]
Decisioning[Decisioning API]
ContentIndex[Content Index]
end
subgraph Exp["Experimentation"]
FlagService[Feature Flags]
Analytics[Analytics Engine]
Learning[Learning Loop]
end
SDK --> Tracker --> Collector
Collector --> CDP --> Stream
Stream --> Warehouse --> FeatureStore
Stream --> Perception
FeatureStore --> Segmentation
ContentIndex --> VectorDB
Segmentation --> Decisioning
VectorDB --> Decisioning
Decisioning --> CDN
CDN --> SDK
Decisioning --> FlagService
FlagService --> Analytics
Analytics --> Learning
Learning -.->|Model Updates| Segmentation
Learning -.->|Model Updates| Decisioning
| Layer | Technology | Purpose |
|---|---|---|
| Client | JavaScript SDK | Event tracking, consent management |
| Edge | Cloudflare Workers / Lambda@Edge | Request routing, caching |
| API | FastAPI (Python 3.10+) | Decisioning & ranking service |
| Data Pipeline | Apache Kafka / Google Pub/Sub | Event streaming |
| Storage | BigQuery / Snowflake | Data warehouse |
| Features | Feast / Tecton | Feature store |
| Vectors | Pinecone / pgvector | Embedding search |
| Search | Elasticsearch / OpenSearch | Content indexing |
| ML | scikit-learn, PyTorch | Segmentation & bandits |
| Experiments | GrowthBook / Optimizely | A/B testing framework |
| Monitoring | Datadog / Prometheus + Grafana | Observability |
- Python: 3.10 or higher
- Node.js: 18.x or higher
- Docker: 24.x or higher
- Kubernetes: 1.28+ (production)
- Data warehouse (BigQuery, Snowflake, or Redshift)
- Feature store (Feast or Tecton)
- Vector database (Pinecone, Weaviate, or pgvector)
- Search engine (Elasticsearch or OpenSearch)
- Message queue (Kafka, Pub/Sub, or Kinesis)
- CMS with API access (Contentful, Strapi, or Sanity)
- Cloud provider account (AWS, GCP, or Azure)
- API keys for third-party services
- Database credentials
- CDN configuration access
# Clone repository
git clone https://github.com/your-org/ai-content-agent.git
cd ai-content-agent
# Install dependencies
make install
# Copy environment template
cp .env.example .envEdit .env with your credentials:
# Data Services
WAREHOUSE_URL=bigquery://project/dataset
FEATURE_STORE_URL=feast://localhost:6565
VECTOR_DB_URL=pinecone://api-key@index-name
# Event Streaming
KAFKA_BROKERS=localhost:9092
KAFKA_TOPIC=content-events
# CMS
CMS_API_URL=https://api.contentful.com
CMS_API_KEY=your_api_key# Start infrastructure (Kafka, Redis, Postgres)
docker-compose up -d
# Initialize databases
make db-migrate
# Start services
make run-local# Health check
curl http://localhost:8000/health
# Test ranking endpoint
curl -X POST http://localhost:8000/v1/rank \
-H "Content-Type: application/json" \
-d '{
"surface_id": "homepage.hero",
"user_ctx": {
"anon_id": "test-user-123",
"device": "mobile",
"consent": ["analytics", "personalization"]
}
}'# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install Python dependencies
pip install -r requirements.txt
pip install -r requirements-dev.txt
# Install Node dependencies (for SDK)
cd sdk && npm install && cd ..
# Install pre-commit hooks
pre-commit install# Build images
docker-compose build
# Start all services
docker-compose up
# Run tests
docker-compose run --rm api pytest# Build production image
docker build -t ai-content-agent:latest .
# Deploy to Kubernetes
kubectl apply -f k8s/
# Verify deployment
kubectl get pods -n personalization# API Service
API_PORT=8000
API_WORKERS=4
API_LOG_LEVEL=info
# Feature Store
FEAST_REPO_PATH=/app/feature_repo
FEAST_ONLINE_STORE=redis://localhost:6379
# Vector DB
PINECONE_API_KEY=your_key
PINECONE_ENVIRONMENT=us-west1-gcp
PINECONE_INDEX=content-embeddings# Event Collection
EVENT_BATCH_SIZE=1000
EVENT_FLUSH_INTERVAL=5
# Warehouse
BQ_PROJECT_ID=your-project
BQ_DATASET=personalization
BQ_CREDENTIALS_PATH=/secrets/bq-key.json# Segmentation
SEGMENT_MODEL_PATH=/models/segments/v1
SEGMENT_CONFIDENCE_THRESHOLD=0.7
SEGMENT_REFRESH_INTERVAL=3600
# Decisioning
BANDIT_ALGORITHM=thompson_sampling
EXPLORATION_RATE=0.08
DIVERSITY_CONSTRAINT=max_1_per_topic
FRESHNESS_HALF_LIFE=14# Consent Management
CMP_PROVIDER=onetrust
CONSENT_REQUIRED=true
PII_SCRUBBING=enabled
# Data Retention
EVENT_RETENTION_DAYS=395
FEATURE_RETENTION_DAYS=90
MODEL_RETENTION_VERSIONS=5The system expects content in the CMS with these fields:
content:
id: string (PK)
title: string
url: string
summary: text
body: text
# NLP-derived (auto-generated)
topics: array<string>
personas: array<string> # beginner, intermediate, advanced
industries: array<string>
sentiment: float # -1 to 1
complexity: float # Flesch-Kincaid grade
# Metadata
published_at: timestamp
updated_at: timestamp
freshness_score: float
quality_score: float
# Embeddings
embedding: vector<float>[384]
# Constraints
jurisdictions: array<string> # US, EU, UK, etc.
policy_flags: array<string> # legal, medical, age_restricted
device_suitability: array<string> # mobile, desktop, tabletCreate config/policies.yaml:
decisioning:
exploration:
global_budget: 0.08
per_user_cap: 0.15
throttle_high_traffic: true
diversity:
max_per_topic_cluster: 1
min_topic_distance: 0.3
enforce_in_top_n: 5
freshness:
decay_function: exponential
half_life_days: 14
minimum_score: 0.3
eligibility:
check_jurisdiction: true
check_consent: true
check_policy_flags: true
check_device: true
segmentation:
cold_start:
use_rules: true
use_popularity: true
min_events: 3
confidence:
assignment_threshold: 0.7
holdout_below: 0.5
fairness:
k_anonymity_threshold: 50
exclude_protected_attributes: trueGet personalized content ranking for a surface.
Request:
{
"surface_id": "homepage.hero",
"user_ctx": {
"anon_id": "anon_abc123",
"session_id": "sess_xyz789",
"device": "mobile",
"referrer": "https://google.com",
"page_type": "index",
"consent": ["analytics", "personalization"],
"geo": {
"country": "US",
"region": "CA"
}
},
"candidates": ["c123", "c456", "c789"], // optional
"limit": 5,
"context": {
"campaign": "summer_sale",
"time_of_day": "evening"
}
}Response:
{
"request_id": "req_a1b2c3",
"surface": "homepage.hero",
"items": [
{
"content_id": "c123",
"score": 0.81,
"reason": "beginner+mobile+intent:learn",
"metadata": {
"title": "Getting Started Guide",
"url": "/guides/getting-started",
"topics": ["tutorial", "basics"]
}
},
{
"content_id": "c987",
"score": 0.72,
"reason": "case-study+finance+high-confidence",
"metadata": {
"title": "Finance Industry Case Study",
"url": "/case-studies/finance"
}
}
],
"segment": {
"id": "seg_learn_mobile_new",
"confidence": 0.85,
"intent": "learn"
},
"experiment": {
"variant": "treatment_b",
"holdout": false
},
"policy_version": "2025-10-01",
"cache_ttl": 300
}Status Codes:
200- Success400- Invalid request403- Insufficient consent429- Rate limit exceeded500- Internal error
Submit reward signal for a ranking request.
Request:
{
"request_id": "req_a1b2c3",
"item_id": "c123",
"reward": {
"type": "click",
"value": 1.0,
"timestamp": "2025-10-09T14:30:00Z"
},
"context": {
"position": 1,
"dwell_time": 45.2,
"scroll_depth": 0.8
}
}Response:
{
"status": "accepted",
"feedback_id": "fb_xyz789"
}Get segment assignment for a user.
Response:
{
"user_id": "anon_abc123",
"segments": [
{
"id": "seg_learn_mobile_new",
"name": "Learning-focused Mobile Users (New)",
"confidence": 0.85,
"features": {
"intent": "learn",
"device_class": "mobile",
"recency": "new",
"price_sensitivity": "medium"
},
"assigned_at": "2025-10-09T14:25:00Z"
}
]
}Search content by semantic similarity.
Request:
{
"query": "how to optimize conversion rates",
"filters": {
"topics": ["marketing", "analytics"],
"personas": ["intermediate"],
"jurisdictions": ["US", "UK"]
},
"limit": 10
}Response:
{
"results": [
{
"content_id": "c456",
"title": "Conversion Rate Optimization Guide",
"url": "/guides/cro",
"similarity": 0.89,
"topics": ["marketing", "analytics", "optimization"],
"freshness_score": 0.95
}
]
}Trigger content index refresh.
Trigger segment model retraining.
Detailed health check with component status.
ai-content-agent/
├── src/
│ ├── api/ # FastAPI application
│ │ ├── routes/ # API endpoints
│ │ ├── middleware/ # Auth, logging, etc.
│ │ └── schemas/ # Pydantic models
│ ├── agents/ # AI Agent core
│ │ ├── perception/ # Event processing
│ │ ├── segmentation/ # User segmentation
│ │ └── decisioning/ # Ranking & bandits
│ ├── content/ # Content intelligence
│ │ ├── indexer/ # CMS sync & indexing
│ │ ├── nlp/ # NLP tagging pipeline
│ │ └── embeddings/ # Vector generation
│ ├── data/ # Data layer
│ │ ├── warehouse/ # Warehouse connectors
│ │ ├── features/ # Feature engineering
│ │ └── stream/ # Event streaming
│ ├── ml/ # ML models
│ │ ├── bandits/ # Bandit algorithms
│ │ ├── clustering/ # Segmentation models
│ │ └── training/ # Training pipelines
│ └── utils/ # Shared utilities
├── sdk/ # JavaScript SDK
│ ├── src/
│ │ ├── tracker.js # Event tracking
│ │ ├── consent.js # Consent management
│ │ └── client.js # API client
│ └── examples/ # Integration examples
├── pipelines/ # Data pipelines
│ ├── content_indexing/ # Content ETL
│ ├── feature_engineering/ # Feature computation
│ └── model_training/ # ML training jobs
├── tests/
│ ├── unit/
│ ├── integration/
│ └── e2e/
├── k8s/ # Kubernetes manifests
├── terraform/ # Infrastructure as code
└── docs/ # Documentation
# Start services
make dev
# Run tests in watch mode
make test-watch
# Lint and format
make lint
make format
# Type checking
make typecheck
# Generate API docs
make docs- Define the surface in
config/surfaces.yaml:
surfaces:
product_listing:
type: ranking
max_items: 20
diversity: true
freshness_boost: 0.2
eligible_content_types: [product, category]- Add ranking logic in
src/agents/decisioning/rankers/:
class ProductListingRanker(BaseRanker):
def rank(self, context: RankingContext) -> List[RankedItem]:
# Implement surface-specific logic
pass-
Register route in
src/api/routes/ranking.py -
Add tests in
tests/unit/rankers/test_product_listing.py -
Update documentation in
docs/surfaces/
# src/data/features/custom_features.py
from feast import FeatureView, Field
from feast.types import Float32, String
user_engagement_features = FeatureView(
name="user_engagement",
entities=["user"],
schema=[
Field(name="avg_session_duration", dtype=Float32),
Field(name="pages_per_session", dtype=Float32),
Field(name="last_visit_intent", dtype=String),
],
online=True,
source=user_engagement_source,
ttl=timedelta(days=7),
)Register in feature store:
feast apply# Run all unit tests
pytest tests/unit/
# Run specific test file
pytest tests/unit/agents/test_decisioning.py
# Run with coverage
pytest --cov=src tests/unit/# Start test infrastructure
docker-compose -f docker-compose.test.yml up -d
# Run integration tests
pytest tests/integration/
# Cleanup
docker-compose -f docker-compose.test.yml down# Deploy to test environment
make deploy-test
# Run E2E suite
pytest tests/e2e/ --env=test
# Verify metrics
make verify-metrics# Run load test (requires k6)
k6 run tests/load/ranking_api.js
# Sustained load test
k6 run --vus 100 --duration 30m tests/load/sustained.js# Run A/A test
python scripts/run_aa_test.py --surface homepage.hero --duration 7d
# Validate metrics
python scripts/validate_experiment.py --experiment exp_123# Deploy to staging
kubectl apply -f k8s/overlays/staging/
# Deploy to production (requires approval)
kubectl apply -f k8s/overlays/production/
# Check rollout status
kubectl rollout status deployment/ai-content-agent -n personalization# k8s/canary.yaml
apiVersion: flagger.app/v1beta1
kind: Canary
metadata:
name: ai-content-agent
spec:
targetRef:
apiVersion: apps/v1
kind: Deployment
name: ai-content-agent
progressDeadlineSeconds: 600
service:
port: 8000
analysis:
interval: 1m
threshold: 10
maxWeight: 50
stepWeight: 5
metrics:
- name: request-success-rate
thresholdRange:
min: 99
- name: request-duration
thresholdRange:
max: 500Deploy canary:
kubectl apply -f k8s/canary.yaml# Package model
python scripts/package_model.py --model-path models/segmentation/v2
# Upload to registry
python scripts/upload_model.py --model-id seg_v2
# Deploy model
python scripts/deploy_model.py --model-id seg_v2 --canary-pct 10
# Monitor and promote
python scripts/promote_model.py --model-id seg_v2# Create migration
alembic revision --autogenerate -m "add segment confidence column"
# Apply migration
alembic upgrade head
# Rollback
alembic downgrade -1- Latency: p50, p95, p99 response times
- Throughput: Requests per second
- Error Rate: 4xx and 5xx errors
- Cache Hit Rate: CDN and application cache
- Conversion Rate: Per surface and overall
- Click-Through Rate: On personalized content
- Revenue Per Session: Total and by segment
- Segment Coverage: % of sessions with segment assignment
- Model Latency: Inference time per model
- Prediction Quality: Confidence distributions
- Exploration Rate: % of exploratory decisions
- Regret: Cumulative regret curves
Access monitoring dashboards:
- Operations:
https://monitoring.company.com/d/api-overview - Business KPIs:
https://monitoring.company.com/d/business-metrics - ML Performance:
https://monitoring.company.com/d/ml-metrics - Experiments:
https://experiments.company.com
Critical alerts are configured for:
- API latency p95 > 100ms for 5 minutes
- Error rate > 1% for 5 minutes
- Segment assignment rate < 80% for 10 minutes
- Model serving failures > 0.5% for 5 minutes
- Experiment metric degradation > 5% for surface
import logging
from src.utils.logging import get_logger
logger = get_logger(__name__)
# Structured logging
logger.info("ranking_request", extra={
"surface_id": "homepage.hero",
"user_id": user_id,
"segment_id": segment_id,
"latency_ms": latency,
})Logs are aggregated in your log management system (DataDog, CloudWatch, etc.).
Distributed tracing is enabled via OpenTelemetry:
from opentelemetry import trace
tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span("rank_content"):
# Ranking logic
passSymptom: p95 latency > 200ms
Diagnosis:
# Check feature store latency
python scripts/diagnose_latency.py --component feature_store
# Check vector DB performance
python scripts/diagnose_latency.py --component vector_dbSolutions:
- Increase feature store cache TTL
- Add vector DB read replicas
- Optimize candidate generation query
Symptom: < 80% of sessions have segment assignments
Diagnosis:
# Check segment confidence distribution
python scripts/analyze_segments.py --metric confidence
# Review cold-start rules
python scripts/analyze_segments.py --metric cold_startSolutions:
- Lower confidence threshold (0.7 → 0.6)
- Improve cold-start rule coverage
- Retrain segmentation model
Symptom: Freshness scores declining
Diagnosis:
# Check indexer status
curl http://localhost:8000/v1/admin/indexer/status
# Verify CMS webhook delivery
python scripts/check_webhooks.pySolutions:
- Trigger manual content refresh
- Fix webhook delivery issues
- Adjust freshness decay parameters
Symptom: Negative treatment effect
Diagnosis:
# Analyze experiment results
python scripts/analyze_experiment.py --exp-id exp_123
# Check for Simpson's paradox
python scripts/analyze_experiment.py --exp-id exp_123 --stratify device,sourceSolutions:
- Roll back to control variant
- Investigate segment-level effects
- Review policy constraints
Enable verbose logging:
export LOG_LEVEL=debug
export DEBUG_MODE=true
python -m src.api.main# Profile API endpoint
python -m cProfile -o profile.stats scripts/profile_api.py
# Analyze with snakeviz
snakeviz profile.stats- Code Style: Follow PEP 8 (Python) and Airbnb (JavaScript)
- Type Hints: Required for all Python functions
- Documentation: Docstrings required for public APIs
- Testing: Minimum 80% code coverage for new code
- Commits: Use conventional commits format
- Create feature branch:
git checkout -b feature/your-feature - Make changes with tests
- Run linters:
make lint - Run tests:
make test - Push and create PR
- Request review from 2+ maintainers
- Squash and merge after approval
- Tests pass and coverage maintained
- Documentation updated
- No performance regressions
- Privacy/security considerations addressed
- Backward compatibility maintained
- Monitoring/alerts added if needed
MIT License - see LICENSE file for details.
- Documentation: docs.company.com/ai-content-agent
- Issues: github.com/your-org/ai-content-agent/issues
- Slack: #ai-content-agent
- Email: ai-personalization@company.com
See CHANGELOG.md for version history and release notes.