System Overview
6 specialized Lambda functions orchestrated by event-driven patterns
Key Innovation: Intelligent AI Selection
Unlike traditional systems that use AI for every request, PulseShrine implements a sophisticated worthiness algorithm that analyzes content quality, duration, and emotional journey to make cost-effective AI enhancement decisions. This reduces AI costs by 60% while ensuring valuable sessions receive premium treatment.
AI Selection Algorithm
Multi-dimensional worthiness calculation with 750+ lines of sophisticated logic
# Sophisticated AI Worthiness Calculation
def calculate_worthiness(self, pulse_data: Dict[str, Any], user_id: str) -> float:
# Extract key data with actual time calculations
intent = pulse_data.get("intent", "")
reflection = pulse_data.get("reflection", "")
actual_duration = self._calculate_actual_duration(pulse_data)
intent_emotion = pulse_data.get("intent_emotion", "")
reflection_emotion = pulse_data.get("reflection_emotion", "")
# Multi-dimensional scoring
length_score = self._calculate_length_score(intent, reflection) # 40%
duration_score = self._calculate_duration_score(actual_duration) # 30%
depth_score = self._calculate_reflection_depth( # 20%
intent, reflection, intent_emotion, reflection_emotion
)
frequency_score = self._calculate_frequency_bonus(user_id) # 10%
# Weighted calculation
worthiness = (
length_score * 0.4 +
duration_score * 0.3 +
depth_score * 0.2 +
frequency_score * 0.1
)
return min(1.0, worthiness) # Cap at 1.0
Event-Driven Data Flow
Real-time processing with EventBridge Pipes and Step Functions
Technical Specifications
Production-ready serverless architecture with cost optimization
6 specialized functions with ARM64 architecture for cost efficiency
- AI Selection: 1024MB, 30s timeout
- Bedrock Enhancement: 1024MB, 120s
- Standard Enhancement: 512MB, 30s
- Pure Ingest: 256MB, 10s
- API Handlers: 512MB, 15s
3-table architecture with TTL-based cost optimization
- Start Pulse: TTL 4 hours
- Stop Pulse: TTL 7 days
- Ingested: Permanent storage
- On-demand billing mode
Multi-model Bedrock with region-aware selection
- Nova Lite (preferred): $0.06/1M tokens
- Claude Haiku (fallback): $0.25/1M tokens
- Automatic model availability testing
- Cost estimation: 0.01-2.0¢ per enhancement
EventBridge Pipes with Step Functions orchestration
- Express workflows for speed
- Batch size: 1 (immediate processing)
- DLQ + 3 retries error handling
- 25K executions/second capacity