Overview
The tag analysis system in IntelliQ automatically processes quiz content to generate relevant tags and categories, maintaining user statistics for both user-provided and AI-generated tags. This system works asynchronously using QStash to ensure smooth quiz submission experience.Flow Diagram
Data Structure
The system maintains two levels of tag data:- Quiz Level (in
quizzestable):
- User Level (in
userAnalysistable):
Response Examples
Technical Implementation
-
QStash Integration
- Uses
@upstash/qstashfor reliable async processing - Configurable delay to batch process tags
- Automatic retries on failure
- Uses
-
Cache Management
- User cache version incremented after analysis
- Ensures frontend receives updated statistics
-
Database Schema
Error Handling
The system handles various error cases:- Failed AI tag generation
- Database transaction failures
- Invalid quiz references
- Rate limiting
- Cache invalidation issues
Security Considerations
- Tag analysis endpoint protected by admin token
- User analysis data access restricted to owner
- Rate limiting on analysis requests
- Sanitization of AI-generated tags
- Validation of user-provided tags
Benefits
-
Asynchronous Processing
- No delay in quiz submission
- Better user experience
- Reduced server load
-
Rich Metadata
- Improved quiz discovery
- Better content organization
- Personalized recommendations
-
User Insights
- Track user interests
- Identify popular categories
- Guide content creation