Cron Jobs & Background Tasks
Relevant source files
The following files were used as context for generating this wiki page:
The background task infrastructure in KudosWall is designed to handle asynchronous processing, maintenance, and automated marketing workflows without impacting the performance of the core web application. These tasks primarily focus on video transcript refinement, automated email sequencing via Loops.so, and high-fidelity content analysis.
By leveraging an edge-compatible architecture on Cloudflare and Vercel, the system offloads heavy operations—such as AI-driven sentiment analysis and video processing—to background handlers. This ensures the Master Tutorial remains fast for end-users while complex data enrichment happens behind the scenes.
Sources: README.md:21-25, loops-email-collection.md:3-8
Background AI Processing
KudosWall utilizes an "AI Core" for analyzing testimonials and video transcripts as background operations. These tasks are guided by a structured SYSTEM_PROMPT that defines operational boundaries for content analysis, sentiment detection, and spam filtering.
Video Transcript Refinement
One of the primary background tasks is cleaning speech-to-text data for subtitles and quotes. This process removes disfluencies and fixes run-on sentences while preserving the original voice of the customer.
The diagram above shows how raw video data is processed through background AI refinement to produce marketing-ready assets.
Sources: apps/web/src/lib/ai/prompts.ts:109-120, README.md:43-46
Intelligence & Triage Tasks
The system performs bulk analysis of customer testimonials to identify recurring feature requests or pain points. These "Intelligence Engine" tasks inform product roadmaps and generate automated response suggestions.
| Task Type | Objective | Output Schema |
|---|---|---|
| Sentiment Analysis | Identify positive/negative/neutral tone | analysis |
| Spam Detection | Filter marketing bots and toxic content | spam |
| Feature Suggestion | Identify recurring customer needs | feature_suggestion |
| SEO Enrichment | Refine content for AI search engines | Markdown |
Sources: apps/web/src/lib/ai/prompts.ts:40-100, apps/web/src/lib/ai/prompts.ts:169-180
Marketing & Communication Loops
Background tasks are integrated with Loops.so to manage the user lifecycle and communication triggers. This includes syncing contact properties and sending transactional emails based on real-time events.
Automated Email Workflows
When specific events occur in the application, background triggers notify the Loops API to update contact data or send emails.
This sequence illustrates how background events in the application drive external marketing and transactional communication.
Sources: loops-email-collection.md:10-23
Contact Property Syncing
Properties such as plan, testimonialCount, and widgetCount are updated via background PUT requests to the /v1/contacts/update endpoint. This ensures that marketing segments in Loops stay synchronized with the actual usage metrics in the KudosWall database.
Sources: loops-email-collection.md:12-18, loops-email-collection.md:28-32
Data Maintenance & SEO Tasks
Background operations extend to database maintenance and the generation of SEO-optimized assets.
Cache & Metadata Management
KudosWall uses unstable_cache with specific tags (e.g., "collection", "wall") and revalidation intervals (e.g., 600 seconds) to ensure that high-traffic public walls are served efficiently. Background revalidation ensures that testimonials remain current without requiring a full database query on every request.
Sources: apps/web/src/app/wall/[slug]/page.tsx:61-125
Structured Data Injection
The system automatically generates JSON-LD schema for Products and ItemLists. This background preparation of metadata allows search engines to correctly index 5-star verified social proof.
This flow depicts the background generation and injection of structured data for SEO visibility.
Sources: apps/web/src/app/wall/[slug]/page.tsx:142-185, README.md:47-48
Operational Guidelines for Tasks
All background logic must adhere to the project's strict quality standards.
- Edge Compatibility: Background handlers (like
src/proxy.ts) must remain compatible with Cloudflare Edge execution to ensure zero latency. - Audit Logging: Critical operations, including CRUD actions processed in the background, should be logged to the
audit_logtable for traceability. - Error Handling: Background tasks must use type-safe error classes or standard result objects to handle expected failures gracefully.
Sources: AGENTS.md:58-62, AGENTS.md:85-88
In summary, KudosWall's cron and background task system is a multi-layered infrastructure that combines AI processing, external marketing syncs, and automated SEO management to support a high-performance SaaS environment.