TekTree Event Catalog
Version: 1.0.0 Last Updated: 2025-12-16 Status: Foundation (Pre-Implementation)Document Purpose
This document serves as the complete catalog of domain events in the TekTree platform. It defines event schemas, producers, consumers, choreography patterns, versioning strategy, and retention policies.Event Taxonomy
Events are organized by domain and follow a hierarchical naming convention: Format:{domain}.{aggregate}.{action}
Examples:
user.registeredknowledge.question.postedgamification.achievement.unlockedpayment.subscription.upgraded
Event Schema Standards
All events follow this base schema:event_id: Unique identifier (UUID v4)event_type: Event type (dot notation)event_version: Semantic version of event schematimestamp: ISO 8601 UTC timestampsource_service: Service that emitted the eventpayload: Event-specific data
trace_id: Distributed tracing IDcorrelation_id: Links related eventsproducer_id: Instance that produced eventmetadata: Contextual information (user, IP, etc.)
1. User Domain Events
Event: user.registered
Version: 1.0.0
Producer: User Service
Consumers: Gamification Service, Payment Service, Email Service
Description: Emitted when a new user successfully completes registration.
Schema:
- Gamification Service: Award +100 XP welcome bonus
- Payment Service: Create free tier subscription
- Email Service: Send welcome email + verification email
Event: user.profile.updated
Version: 1.0.0
Producer: User Service
Consumers: Search Service, Cache Service
Description: Emitted when user updates their profile information.
Schema:
- Search Service: Reindex user profile
- Cache Service: Invalidate user profile cache
Event: user.authenticated
Version: 1.0.0
Producer: User Service
Consumers: Analytics Service, Gamification Service (streak tracking)
Description: Emitted when user successfully logs in.
Schema:
- Analytics Service: Track active users (DAU)
- Gamification Service: Update streak (daily activity)
2. Knowledge Domain Events
Event: knowledge.question.posted
Version: 1.0.0
Producer: Knowledge Service
Consumers: Gamification Service, Search Service, Notification Service
Description: Emitted when a user posts a new question.
Schema:
- Gamification Service: Award +5 XP to user
- Search Service: Index question for search
- Notification Service: Notify followers of related areas
Event: knowledge.answer.submitted
Version: 1.0.0
Producer: Knowledge Service
Consumers: Gamification Service, Notification Service
Description: Emitted when a user submits an answer to a question.
Schema:
- Gamification Service: Award +10 XP to answerer
- Notification Service: Notify question author
Event: knowledge.answer.accepted
Version: 1.0.0
Producer: Knowledge Service
Consumers: Gamification Service, Notification Service
Description: Emitted when question author accepts an answer as the best answer.
Schema:
- Gamification Service: Award +50 XP to answer author
- Notification Service: Notify answer author
Event: knowledge.insight.published
Version: 1.0.0
Producer: Knowledge Service
Consumers: Gamification Service, Search Service, Notification Service
Description: Emitted when a user publishes an insight.
Schema:
- Gamification Service: Award +25 XP
- Search Service: Index insight
- Notification Service: Notify followers
Event: knowledge.discussion.started
Version: 1.0.0
Producer: Knowledge Service
Consumers: Gamification Service, Search Service, Notification Service
Description: Emitted when a user starts a discussion.
Schema:
- Gamification Service: Award +10 XP
- Search Service: Index discussion
- Notification Service: Notify area followers
Event: knowledge.resource.shared
Version: 1.0.0
Producer: Knowledge Service
Consumers: Gamification Service, Search Service
Description: Emitted when a user shares a resource.
Schema:
- Gamification Service: Award +5 XP
- Search Service: Index resource
3. Social Domain Events
Event: social.content.liked
Version: 1.0.0
Producer: Knowledge Service
Consumers: Gamification Service, Notification Service
Description: Emitted when a user likes content.
Schema:
- Gamification Service: Award +2 XP to content author
- Notification Service: Notify content author (batched)
Event: social.comment.added
Version: 1.0.0
Producer: Knowledge Service
Consumers: Gamification Service, Notification Service
Description: Emitted when a user adds a comment.
Schema:
- Gamification Service: Award +3 XP to commenter
- Notification Service: Notify content author and parent commenter
Event: social.content.upvoted
Version: 1.0.0
Producer: Knowledge Service
Consumers: Gamification Service, Notification Service
Description: Emitted when a user upvotes content.
Schema:
- Gamification Service: Award +5 XP to content author
- Notification Service: Notify content author (batched)
Event: social.user.followed
Version: 1.0.0
Producer: User Service
Consumers: Gamification Service, Notification Service
Description: Emitted when a user follows another user.
Schema:
- Gamification Service: Check follower milestones (10, 100, 1000 followers)
- Notification Service: Notify followed user
4. Gamification Domain Events
Event: gamification.xp.earned
Version: 1.0.0
Producer: Gamification Service
Consumers: Real-Time Service, Notification Service
Description: Emitted when a user earns XP.
Schema:
- Real-Time Service: Push XP notification to user’s active WebSocket
- Notification Service: Add to notification feed
Event: gamification.level.up
Version: 1.0.0
Producer: Gamification Service
Consumers: Real-Time Service, Notification Service, User Service
Description: Emitted when a user levels up.
Schema:
- Real-Time Service: Show level-up animation
- Notification Service: Send congratulatory notification
- User Service: Update user level badge
Event: gamification.achievement.unlocked
Version: 1.0.0
Producer: Gamification Service
Consumers: Real-Time Service, Notification Service
Description: Emitted when a user unlocks an achievement.
Schema:
- Real-Time Service: Show achievement unlock animation
- Notification Service: Send achievement notification
Event: gamification.streak.extended
Version: 1.0.0
Producer: Gamification Service
Consumers: Real-Time Service
Description: Emitted when a user extends their daily streak.
Schema:
- Real-Time Service: Update streak counter UI
Event: gamification.leaderboard.updated
Version: 1.0.0
Producer: Gamification Service
Consumers: Real-Time Service
Description: Emitted when leaderboard rankings change (throttled to avoid spam).
Schema:
- Real-Time Service: Push leaderboard updates to subscribed clients
5. Payment Domain Events
Event: payment.subscription.created
Version: 1.0.0
Producer: Payment Service
Consumers: User Service, Analytics Service
Description: Emitted when a subscription is created (including free tier).
Schema:
- User Service: Update user tier badge
- Analytics Service: Track subscription creation
Event: payment.subscription.upgraded
Version: 1.0.0
Producer: Payment Service
Consumers: User Service, Gamification Service, Notification Service
Description: Emitted when a user upgrades their subscription tier.
Schema:
- User Service: Update user tier badge
- Gamification Service: Award +200 XP bonus
- Notification Service: Send upgrade confirmation
Event: payment.quota.exceeded
Version: 1.0.0
Producer: Payment Service (quota check)
Consumers: Notification Service
Description: Emitted when a user exceeds their quota limit.
Schema:
- Notification Service: Send upgrade prompt notification
Event: payment.webhook.received
Version: 1.0.0
Producer: Payment Service
Consumers: Analytics Service (for auditing)
Description: Emitted when a Polar webhook is received (for audit trail).
Schema:
- Analytics Service: Log webhook for debugging
6. Real-Time Domain Events
Event: realtime.user.joined
Version: 1.0.0
Producer: Real-Time Service
Consumers: Analytics Service
Description: Emitted when a user joins a real-time channel (presence).
Schema:
- Analytics Service: Track real-time engagement
Event: notification.sent
Version: 1.0.0
Producer: Notification Service
Consumers: Analytics Service
Description: Emitted when a notification is successfully sent.
Schema:
- Analytics Service: Track notification engagement
Event Choreography Patterns
Pattern 1: User Registration Flow
Pattern 2: Content Engagement Flow
Pattern 3: Achievement Unlock Flow
Event Versioning Strategy
Semantic Versioning
Events follow semantic versioning (MAJOR.MINOR.PATCH):- MAJOR: Breaking changes (field removed, type changed)
- MINOR: Backward-compatible additions (new field)
- PATCH: Documentation or clarification changes
Versioning Rules
- Always include
event_versionfield in event payload - Consumers must handle multiple versions gracefully
- Deprecated versions supported for 6 months before removal
- Breaking changes require migration plan
Example: Adding a New Field (Minor Version)
v1.0.0:Event Retention Policies
| Event Category | Retention Period | Storage | Rationale |
|---|---|---|---|
| User events | Indefinite | Event Store | Audit trail |
| Knowledge events | Indefinite | Event Store | Content history |
| Gamification events | 2 years | Event Store | Historical analytics |
| Payment events | 7 years | Event Store | Legal compliance |
| Social events | 1 year | Event Store | Recent activity |
| Real-time events | 7 days | Redis Streams | Operational only |
| Notification events | 30 days | MongoDB | Recent history |
- Events older than retention period moved to cold storage (S3)
- Archived events compressed (gzip)
- Archived events indexed for compliance queries
- Automatic archival job runs weekly
Event Publishing Guarantees
At-Least-Once Delivery
TekTree uses at-least-once delivery semantics:- Events may be delivered multiple times
- Consumers must be idempotent
- Use
event_idfor deduplication
Idempotency Pattern
Event Ordering Guarantees
Per-Aggregate Ordering
Events for the same aggregate are processed in order:- Use
correlation_idto group related events - Redis Streams guarantees order within a stream
- Consumers use consumer groups for parallel processing
Global Ordering
Global ordering is not guaranteed:- Events from different services may arrive out of order
- Use timestamps for eventual consistency
- Design for commutative operations where possible
Dead Letter Queue (DLQ)
DLQ Policy
Events that fail processing after 3 retries are moved to DLQ:- First retry: Immediate
- Second retry: 10 seconds delay
- Third retry: 60 seconds delay
- If still failing: Move to DLQ
DLQ Monitoring
- Alert when DLQ size > 100
- Daily DLQ report sent to operations team
- Manual review and reprocessing
Event Bus Performance Targets
| Metric | Target |
|---|---|
| Event publishing latency (p95) | < 10ms |
| Event delivery latency (p95) | < 100ms |
| Throughput (sustained) | 1,000 events/sec |
| Throughput (burst) | 5,000 events/sec |
| Event backlog size (max) | 10,000 events |
Event Catalog Maintenance
Ownership
- Domain Event Owner: Team responsible for the domain (User, Knowledge, etc.)
- Event Catalog Maintainer: Platform team
- Review Frequency: Quarterly
Change Process
- Propose event schema change (GitHub PR to this document)
- Review with domain team
- Update event version if breaking change
- Update consumers to handle new version
- Deploy consumers before deploying producers
- Monitor for errors
Document Status: ✅ Complete Related Documents:
ARCHITECTURE_OVERVIEW.md, DATA_MODELS.md, API_CONTRACTS.md