# Backend Overview

The Influtics backend runs entirely on Cloudflare Workers with Supabase (PostgreSQL) as the database. All async processing uses Cloudflare Queues.


# Architecture Principles

  • Stateless workers — no persistent state in workers; all state lives in Supabase
  • Queue-driven async — long-running tasks (video fetching, stats updates, sheet sync) are always offloaded to queues
  • Scheduled crons — nightly and periodic jobs run as Cloudflare scheduled events
  • Organization-scoped — all data is scoped to organization_id; RLS enforced at DB level

# Workers at a Glance

Worker Type Responsibilities
campaigns-worker HTTP Campaign-level analytics — aggregated stats, budget/cpm metrics, timeseries, video lists
dashboard-worker HTTP Video management, start/stop tracking, campaign/tag/budget assignment
bloggers-worker HTTP + Scheduled Blogger account management, midnight/noon batch scheduler
blogger-video-consumer Queue Consumer Fetches videos from TikTok/Instagram/YouTube on initial tracking and batch runs
queue-producer Scheduled Nightly video stats refresh — enqueues tracked videos for stats update
queue-processor Queue Consumer Fetches video stats from RapidAPI and saves to DB
google-sheets HTTP Google Sheets OAuth, worksheet select, export config
excel-processor Queue Consumer Processes Excel/Sheets worksheet batches, upserts video records
google-sheets-updater Queue Consumer Writes analytics data back to Google Sheets
google-sheets-resync-scheduler Scheduled Triggers import resync every 4 hours
excel-import-export HTTP Direct Excel file import/export via HTTP
organizations-worker HTTP Org registration, team management (invite/accept/decline/remove), settings, user preferences
limits-worker HTTP (service binding) Subscription limit checks, custom per-org overrides, plan defaults
notifications-worker HTTP + Scheduled Notification settings, Telegram linking, scheduled reports cron
notifications-consumer Queue Consumer Sends notifications via Email (Loops) and Telegram

# Queues at a Glance

Queue Producer Consumer Purpose
BLOGGER_VIDEO_QUEUE bloggers-worker blogger-video-consumer Blogger video fetches (initial + midnight)
HIGH_PRIORITY_QUEUE dashboard-worker, blogger-video-consumer queue-processor Single video stat fetch (high priority)
LOW_PRIORITY_QUEUE queue-producer queue-processor Nightly bulk video stat refresh
EXCEL_QUEUE excel-import-export excel-processor Direct Excel file import batches
excel-processing-queue google-sheets excel-processor Google Sheets worksheet processing
google-sheets-update-queue google-sheets, excel-processor google-sheets-updater Export DB stats → Google Sheets
NOTIFICATIONS_QUEUE notifications-worker, queue-processor notifications-consumer Email and Telegram notifications

# Database

Provider: Supabase (PostgreSQL)

Key tables: videos, video_statistics, tracked_accounts, blogger_information, google_sheet_integrations, google_sheet_sources, import_jobs, subscription_plan_limits, organization_custom_limits

All tables have Row Level Security (RLS) policies scoped to organization_id.


# Documentation by Domain

Domain Description
Analytics Video stats, shared analytics, dashboard metrics
Bloggers Creator accounts, video fetching
Campaigns Campaign analytics, budget tracking, timeseries
Dashboard Frontend dashboard data endpoints
Google Sheets Import/export via Google Sheets
Import/Export Excel file processing
Limits Subscription limits and quotas
Notifications Email/Telegram notifications, scheduled reports
Organizations Team management, settings