The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
New case study and blog (#38732)
Danny White274ecd8ba36c
diff --git a/apps/www/_blog/2025-09-12-processing-large-jobs-with-edge-functions.mdx b/apps/www/_blog/2025-09-12-processing-large-jobs-with-edge-functions.mdxnew file mode 100644index 00000000000..35dc7d0132a--- /dev/null+++ b/apps/www/_blog/2025-09-12-processing-large-jobs-with-edge-functions.mdx@@ -0,0 +1,402 @@+---+title: Processing large jobs with Edge Functions, Cron, and Queues+description: Learn how to build scalable data processing pipelines using Supabase Edge Functions, cron jobs, and database queues and handle large workloads without timeouts or crashes.+author: prashant+image: 2025-09-processing-large-jobs-with-edge-functions/og.png+thumb: 2025-09-processing-large-jobs-with-edge-functions/og.png+categories:+ - postgres+ - edge functions+ - cron+ - queues+date: 2025-09-16:08:00+toc_depth: 2+---++When you're building applications that process large amounts of data, you quickly run into a fundamental problem: trying to do everything at once leads to timeouts, crashes, and frustrated users. The solution isn't to buy bigger servers. It's to break big jobs into small, manageable pieces.++Supabase gives you three tools that work beautifully together for this: [Edge Functions](/edge-functions) for serverless compute, [Cron](/modules/cron) for scheduling, and database [queues](/modules/queues) for reliable job processing.++Here's how to use them to build a system that can handle serious scale.++## The three-layer pattern++The architecture is simple but powerful. Think of it like an assembly line:++**Collection**: Cron jobs run Edge Functions that discover work and add tasks to queues++**Distribution**: Other cron jobs route tasks from main queues to specialized processing queues++**Processing**: Specialized workers handle specific types of tasks from their assigned queues++<Img+ src={{+ dark: '/images/blog/2025-09-processing-large-jobs-with-edge-functions/three-layer-pattern-diagram.png',+ light:+ '/images/blog/2025-09-processing-large-jobs-with-edge-functions/three-layer-pattern-diagram.png',+ }}+ alt="A diagram showing the three-layer pattern described above"+/>++This breaks apart the complexity. Instead of one giant function that scrapes websites, processes content with AI, and stores everything, you have focused functions that each do one thing well.++## Real example: Building an NFL news aggregator++Let's say you want to build a dashboard that tracks NFL (American football) news from multiple sources including NFL-related websites and NFL-related videos on YouTube, automatically tags articles by topic, and lets users search by player or team. When they see an article they’re interested in, they can click on it and visit the website that hosts the article. It’s like a dedicated Twitter feed for the NFL without any of the toxicity.++This sounds straightforward, but at scale this becomes complex fast. You need to monitor dozens of news sites, process hundreds of articles daily, make API calls to OpenAI for content analysis, generate vector embeddings for search, and store everything efficiently. Do this wrong and a single broken webpage crashes your entire pipeline.++We need to build a more resilient approach. With Supabase Edge Functions, Cron, and Queues, we have the building blocks for a robust content extraction and categorization pipeline.++## Setting up the foundation++Everything starts with the [database](/database), and Supabase is Postgres at its core. We know what we’re getting: scalable, dependable, and standard.++The database design for the application follows a clean pattern. You have content tables for storing articles and videos, queue tables for managing work, entity tables for NFL players and teams, and relationship tables linking everything together. For example:++```sql+create table articles (+ url text unique not null,+ headline text,+ content text,+ embedding vector(1536)+);+```++## Collection: Finding new content++The collection layer seeks out new NFL-related content and runs on a schedule to discover new articles and videos. We create a collector for every site we want to search. A cron job triggers every 30 minutes to begin collection:++```sql+SELECT cron.schedule(+ 'nfl-collector',+ '*/30 * * * *',+ $$SELECT net.http_post(url := '[https://your-project.supabase.co/functions/v1/collect-content')$$](https://your-project.supabase.co/functions/v1/collect-content')$$)+);+```++The Edge Function does the actual scraping. The trick is being selective about what you collect:++```tsx+function isRelevantArticle(url: string): boolean {+ return url.includes('/news/') && !url.includes('/video/')+}+```++This simple filter prevents collecting promotional content or videos. You only want actual news articles.++When parsing HTML, you need to handle relative URLs properly:++```tsx+if (href.startsWith('/')) {+ href = BASE_URL + href+}+```++And always deduplicate within a single scraping session:++```tsx+const seen = new Set<string>()+if (!seen.has(href)) {+ seen.add(href)+ articles.push({ url: href, site: 'nfl' })+}+```++For database insertion, let the database handle duplicates rather than checking in your application:++```tsx+const { error } = await supabase.from('articles').insert({ url, site })+if (error && !error.message.includes('duplicate')) {+ console.error(`Error inserting: ${url}`, error)+}+```++This approach is more reliable than complex application-level deduplication logic.++## Distribution: Smart routing++The distribution layer identifies articles that need processing and routes them to appropriate queues. The key insight is using separate queue tables for different content sources. [NFL.com](http://NFL.com) articles need different parsing than ESPN articles, so they get routed to specialized processors. It runs more frequently than collection: every 5 minutes:++```sql+SELECT cron.schedule(+ 'distributor',+ '*/5 * * * *',+ $$SELECT net.http_post(url := '[https://your-project.supabase.co/functions/v1/distribute-work')$$](https://your-project.supabase.co/functions/v1/distribute-work')$$)+);+```++The Edge Function finds unprocessed articles using a simple SQL query:++```tsx+const { data } = await supabase+ .from('articles')+ .select('url, site')+ .is('headline', null) // Missing headline means unprocessed+ .limit(50)+```++Then it routes based on the source site:++```tsx+if ([article.site](http://article.site) === "nfl") {+ await supabase.from("nfl_queue").insert({ url: article.url });+} else if ([article.site](http://article.site) === "espn") {+ await supabase.from("espn_queue").insert({ url: article.url });+}+```++This separation is crucial because each site has different HTML structures and parsing requirements.++## Processing: The heavy lifting++Each content source gets its own processor that runs on its own schedule. [NFL.com](http://NFL.com) gets processed every 15 seconds because it's high-priority:++```sql+SELECT cron.schedule(+ 'nfl-processor',+ '*/15 * * * *',+ $$SELECT net.http_post(url := '[https://your-project.supabase.co/functions/v1/process-nfl')$$](https://your-project.supabase.co/functions/v1/process-nfl')$$)+);+```++The processor handles one article at a time to stay within Edge Function timeout limits:++```tsx+const { data } = await supabase+ .from('nfl_queue')+ .select('id, url')+ .eq('processed', false)+ .order('created_at')+ .limit(1)+```++Content extraction requires site-specific CSS selectors:++```tsx+const headline = $('h1').first().text().trim()+const content = $('.article-body').text().trim() || $('article').text().trim()+```++Date parsing often needs custom logic for each site's format:++```tsx+const dateText = $('.publish-date').text()+const match = dateText.match(/(\w+ \d+, \d{4})/)+if (match) {+ publication_date = new Date(match[1])+}+```++After scraping, the article gets analyzed with AI to extract entities:++```tsx+const result = await classifyArticle(headline, content)+const playerIds = await upsertPlayers(supabase, result.players)+const teamIds = await upsertTeams(supabase, result.teams)+```++Finally, create the relationships and generate embeddings:++```tsx+await supabase.from("article_players").insert(+ [playerIds.map](http://playerIds.map)(id => ({ article_url: url, player_id: id }))+);++const embedding = await generateEmbedding(`${headline}\n${content}`);+await supabase.from("articles").update({ embedding }).eq("url", url);+```++The critical pattern is the finally block. We use it to always mark queue items as processed, preventing infinite loops when articles fail to process:++```tsx+try {+ // Process article+} finally {+ await supabase.from("nfl_queue")+ .update({ processed: true })+ .eq("id", [item.id](http://item.id));+}+```++### Monitoring with Sentry++While the finally block prevents infinite loops, you still need visibility into what's actually failing. Sentry integration gives you detailed error tracking for your Edge Functions.++First, set up Sentry in your Edge Function:++```jsx+import { captureException, init } from 'https://deno.land/x/sentry/index.js'++init({+ dsn: Deno.env.get('SENTRY_DSN'),+ environment: Deno.env.get('ENVIRONMENT') || 'production',+})+```++Then wrap your processing logic with proper error capture:++```jsx+try {+ const content = await scrapeArticle(url);+ const analysis = await classifyArticle(headline, content);+ await storeArticle(article, analysis);+} catch (error) {+ *// Capture the full context for debugging*+ captureException(error, {+ tags: {+ function: "nfl-processor",+ site: article.site+ },+ extra: {+ url: article.url,+ queueId: queueItem.id+ }+ });+ console.error(`Failed to process ${url}:`, error);+} finally {+ await supabase.from("nfl_queue")+ .update({ processed: true })+ .eq("id", queueItem.id);+}+```++This gives you real-time alerts when processors fail and detailed context for debugging production issues.++## Processing user interactions through the pipeline++The same pipeline pattern works for user-generated events. When someone clicks, shares, or saves an article, you don't want to block their response while updating trending scores for every player and team mentioned in that article.++Instead, treat interactions like any other job to be processed:++```tsx+// Just record the interaction quickly+await supabase.from('interaction_queue').insert({+ article_url: url,+ user_id: userId,+ interaction_type: 'share',+})+```++Then let a separate cron job process the trending updates in batches:++```sql+SELECT cron.schedule(+ 'process-interactions',+ '*/2 * * * *', -- Every 2 minutes+ $$SELECT net.http_post(url := '[https://your-project.supabase.co/functions/v1/process-interactions')$$](https://your-project.supabase.co/functions/v1/process-interactions')$$)+);+```++The processor can handle multiple interactions efficiently:++```tsx+const { data: interactions } = await supabase+ .from('interaction_queue')+ .select('*')+ .eq('processed', false)+ .limit(100)+```++This keeps your user interface snappy while ensuring trending scores get updated reliably. If the trending processor goes down, interactions are safely queued and will be processed when it recovers.++## AI-powered content scoring++To surface the most important content automatically, use AI to analyze article context and assign importance scores.++Define scores for different news types:++```tsx+const CONTEXT_SCORES = {+ championship: 9,+ trade: 6,+ injury: 4,+ practice: 1,+}+```++Prompt OpenAI with structured output:++```tsx+const prompt = `Analyze this headline: "${headline}"+Return JSON: {"context": "trade|injury|etc", "score": 1-9}`;++const result = await [openai.chat](http://openai.chat).completions.create({+ model: "gpt-3.5-turbo",+ response_format: { type: "json_object" }+});+```++Process articles in batches to manage API costs:++```tsx+const unprocessed = articles.filter((a) => !processedUrls.has(a.url)).slice(0, 10)++for (const article of unprocessed) {+ const analysis = await analyzeArticle(article)+ await storeAnalysis(article.url, analysis)+}+```++## Background tasks for expensive operations++Some operations are too expensive to run synchronously, even in your cron-triggered processors. Vector embedding generation and bulk AI analysis benefit from background task patterns.++Edge Functions support background tasks that continue processing after the main response completes:++typescript++```jsx+*// In your article processor*+const article = await scrapeAndStore(url);++*// Start expensive operations in background*+const backgroundTasks = [+ generateEmbedding(article),+ analyzeWithAI(article),+ updateRelatedContent(article)+];++*// Run background tasks without blocking the main flow*+Promise.all(backgroundTasks).catch(error => {+ captureException(error, {+ tags: { operation: "background-tasks" },+ extra: { articleUrl: url }+ });+});++*// Main processing continues immediately*+await markAsProcessed(queueItem.id);+```++For operations that might take longer than Edge Function limits, break them into smaller background chunks:++typescript++```jsx+async function generateEmbeddingInBackground(article: Article) {+ *// Process content in chunks*+ const chunks = splitIntoChunks(article.content, 1000);++ for (const chunk of chunks) {+ await new Promise(resolve => {+ *// Use background task for each chunk*+ setTimeout(async () => {+ const embedding = await generateEmbedding(chunk);+ await storeEmbedding(article.id, embedding);+ resolve(void 0);+ }, 0);+ });+ }+}+```++This pattern keeps your main processing pipeline fast while ensuring expensive operations complete reliably.++## Why this works++This pattern succeeds because it embraces the constraints of serverless computing rather than fighting them. Edge Functions have time limits, so you process one item at a time. External APIs have rate limits, so you control timing with cron schedules. Failures happen, so you isolate them to individual tasks.++The result is a system that scales horizontally by adding more cron jobs and queues. Each component can fail independently without bringing down the whole pipeline. Users get fresh content as it becomes available rather than waiting for batch jobs to complete.++Most importantly, it's built entirely with Supabase primitives — no external queue systems or job schedulers required. You get enterprise-grade reliability with startup simplicity.diff --git a/apps/www/_customers/juniver.mdx b/apps/www/_customers/juniver.mdxnew file mode 100644index 00000000000..aa19fbf1f98--- /dev/null+++ b/apps/www/_customers/juniver.mdx@@ -0,0 +1,110 @@+---+name: Juniver+title: 'Juniver built a self-serve B2B platform with Supabase to scale eating disorder recovery'+# Use meta_title to add a custom meta title. Otherwise it defaults to '{name} | Supabase Customer Stories':+# meta_title:+description: Juniver switched from Firebase to Supabase and saw immediate improvements in developer experience and performance.+# Use meta_description to add a custom meta description. Otherwise it defaults to {description}:+meta_description: Juniver switched from Firebase to Supabase and saw immediate improvements in developer experience and performance.+author: prashant+author_title: Prashant Sridharan+author_url: https://github.com/CoolAssPuppy+author_image_url: https://avatars.githubusercontent.com/u/914007?v=4+logo: /images/customers/logos/juniver.png+logo_inverse: /images/customers/logos/light/juniver.png+og_image: /images/customers/og/juniver.jpg+tags:+ - supabase+date: '2025-01-15'+company_url: https://www.joinjuniver.com+misc: [{ label: 'Founded', text: 'United Kingdom' }]+about: Science-based recovery program for disordered eating+# "healthcare" | "fintech" | "ecommerce" | "education" | "gaming" | "media" | "real-estate" | "saas" | "social" | "analytics" | "ai" | "developer-tools"+industry: ['healthcare', 'ai', 'saas']+# "startup" | "enterprise" | "indie_dev"+company_size: 'startup'+# "Asia" | "Europe" | "North America" | "South America" | "Africa" | "Oceania"+region: 'Europe'+# "database" | "auth" | "storage" | "realtime" | "functions" | "vector"+supabase_products: ['database', 'auth', 'functions']+---++<Quote img="nick-farrant-juniver.jpg" caption="Nick Farrant, Founding Engineer, Juniver">+ For me, the biggest benefit of Supabase is developer experience. My expertise doesn't lie in+ databases and infrastructure. It really didn't take much time at all to spin up this product with+ Supabase.+</Quote>++[Juniver](https://www.joinjuniver.com/) is an iOS app that guides people through recovery from eating disorders and disordered eating. The product combines an AI recovery coach, a thoroughly researched curriculum, and self-serve tools designed for moments of need. Juniver is expanding from B2C into B2B2C, licensing its platform to clinics and clinicians who then offer it to patients.++## The challenge++Juniver needed to evolve its backend to support a new B2B2C product, without risking the stability of its consumer app.++- Launch a self-serve, automated, scalable platform for clinics and clinicians+- Enforce strict privacy and access controls across clinics, clinicians, patients, and licenses+- Integrate tightly with Stripe and webhooks to automate onboarding and license provisioning+- Move quickly with a lean team, choosing tools that won't have to be replaced in a few years++They also faced significant friction with their previous Firebase setup:++- Document-based storage made data relationships difficult to manage+- Manual relationship handling slowed development+- Limited scalability for complex B2B requirements+- Developer productivity was constrained by Firebase's limitations++<Quote img="nick-farrant-juniver.jpg" caption="Nick Farrant, Founding Engineer, Juniver">+ Time is such a big currency in startup world. With Firebase, we were really struggling with+ relationships within our data. It was all done very manually, as you can expect with+ document-based storage. Supabase is a relational database and it's much easier and we can move+ faster.+</Quote>++## Choosing Supabase++Juniver had long run on Google Cloud with Firebase for the mobile app. The new B2B product created a clean slate to evaluate alternatives and set a foundation for future scale. Supabase offered a relational core (Postgres) and an integrated developer experience that aligned with Juniver's needs now and later.++**Why Supabase**++- A relational database (Postgres) to model clean, maintainable relationships+- Integrated developer experience: visual Table Editor with inline SQL, clear logs, SDKs+- Strong security posture with Row Level Security, plus an easy way to "view as user" to validate policies+- Built-in primitives (Auth, Functions) to save time and build with best-of-breed products++<Quote img="nick-farrant-juniver.jpg" caption="Nick Farrant, Founding Engineer, Juniver">+ The Supabase developer experience is so clear. I've got everything at my fingertips. I'm in the+ Table Editor. The SQL editor is literally right below the table editor. The feature you have to+ see the table from a different user's perspective to test your Row Level Security is a wonderful+ little feature that I use all the time.+</Quote>++## The approach++Juniver used the B2B product as a greenfield build on Supabase, avoiding risky dependencies on the legacy Firebase data while preparing for an eventual B2C migration.++- **Getting started**+ - Spun up a new Supabase project and schema for clinics, clinicians, patients, and licenses+ - Leaned on documentation and the iOS SDK to accelerate the build+- **Implementation highlights**+ - **Database (Postgres):** Relational schema with strict Row Level Security; frequent use of "view as user" to validate policies+ - **Auth & OAuth:** Managing identities for clinics and patients with fine-grained access+ - **Webhooks + Edge Functions:** Stripe purchase triggers an automated sequence to authenticate partners, provision license codes, and send emails+ - **Operational visibility:** Edge Function logs and an integrated console for fast debugging and iteration++<Quote img="nick-farrant-juniver.jpg" caption="Nick Farrant, Founding Engineer, Juniver">+ You have to expect, plan, and build for scale. We can scale exponentially with Supabase.+</Quote>++## The results++Juniver's B2B platform is out in the wild and early in adoption, but the team is already seeing meaningful wins in developer experience and delivery speed.++- Rapidly build-out of a self-serve, automated B2B platform using out-of-the-box Supabase features+- Faster iteration through an integrated UI, inline SQL, clear logs, and RLS policy testing+- A relational foundation that supports today's B2B needs and tomorrow's B2C migration+- Streamlined development process with Supabase's integrated tooling++<Quote img="nick-farrant-juniver.jpg" caption="Nick Farrant, Founding Engineer, Juniver">+ My advice to developers thinking of moving to Supabase: Try it, it's free. Replicate your project.+ You'll see how much easier it is to think about your data from a relational point of view.+</Quote>diff --git a/apps/www/data/CustomerStories.ts b/apps/www/data/CustomerStories.tsindex b12e56ac878..063854d9d2a 100644--- a/apps/www/data/CustomerStories.ts+++ b/apps/www/data/CustomerStories.ts@@ -18,6 +18,18 @@ export type CustomerStoryType = {}export const data: CustomerStoryType[] = [+ {+ type: 'Customer Story',+ title:+ 'Juniver built automated B2B workflows with Supabase Edge Functions and Row Level Security',+ description:+ 'Juniver switched from Firebase to Supabase and saw immediate improvements in developer experience and performance.',+ organization: 'Juniver',+ imgUrl: 'images/customers/logos/juniver.png',+ logo: '/images/customers/logos/juniver.png',+ logo_inverse: '/images/customers/logos/light/juniver.png',+ url: '/customers/juniver',+ },{type: 'Customer Story',title: 'Kayhan Space saw 8x improvement in developer speed when moving to Supabase',diff --git a/apps/www/public/customers-rss.xml b/apps/www/public/customers-rss.xmlindex 2c776ae0310..57ff2acef84 100644--- a/apps/www/public/customers-rss.xml+++ b/apps/www/public/customers-rss.xml@@ -70,6 +70,13 @@<description>Scaling seamlessly to 5,000+ paying customers & millions of emails sent daily with Supabase</description><pubDate>Fri, 21 Feb 2025 00:00:00 -0700</pubDate></item>+<item>+ <guid>https://supabase.com/customers/juniver</guid>+ <title>Juniver built a self-serve B2B platform with Supabase to scale eating disorder recovery</title>+ <link>https://supabase.com/customers/juniver</link>+ <description>Juniver switched from Firebase to Supabase and saw immediate improvements in developer experience and performance.</description>+ <pubDate>Wed, 15 Jan 2025 00:00:00 -0700</pubDate>+</item><item><guid>https://supabase.com/customers/e2b</guid><title>E2B: Accelerating AI-Driven Development with Supabase</title>diff --git a/apps/www/public/images/blog/2025-09-processing-large-jobs-with-edge-functions/og.png b/apps/www/public/images/blog/2025-09-processing-large-jobs-with-edge-functions/og.pngnew file mode 100644index 00000000000..cca6165b211Binary files /dev/null and b/apps/www/public/images/blog/2025-09-processing-large-jobs-with-edge-functions/og.png differdiff --git a/apps/www/public/images/blog/2025-09-processing-large-jobs-with-edge-functions/three-layer-pattern-diagram.png b/apps/www/public/images/blog/2025-09-processing-large-jobs-with-edge-functions/three-layer-pattern-diagram.pngnew file mode 100644index 00000000000..3046914da42Binary files /dev/null and b/apps/www/public/images/blog/2025-09-processing-large-jobs-with-edge-functions/three-layer-pattern-diagram.png differdiff --git a/apps/www/public/images/blog/avatars/nick-farrant-juniver.jpg b/apps/www/public/images/blog/avatars/nick-farrant-juniver.jpgnew file mode 100644index 00000000000..49c7335de71Binary files /dev/null and b/apps/www/public/images/blog/avatars/nick-farrant-juniver.jpg differdiff --git a/apps/www/public/images/customers/logos/juniver.png b/apps/www/public/images/customers/logos/juniver.pngnew file mode 100644index 00000000000..bbdadd32efdBinary files /dev/null and b/apps/www/public/images/customers/logos/juniver.png differdiff --git a/apps/www/public/images/customers/logos/light/juniver.png b/apps/www/public/images/customers/logos/light/juniver.pngnew file mode 100644index 00000000000..90f22bdd80dBinary files /dev/null and b/apps/www/public/images/customers/logos/light/juniver.png differdiff --git a/apps/www/public/sitemap_www.xml b/apps/www/public/sitemap_www.xmlindex 0d54ecc0896..e5aa94c39fc 100644--- a/apps/www/public/sitemap_www.xml+++ b/apps/www/public/sitemap_www.xml@@ -2209,6 +2209,12 @@<changefreq>weekly</changefreq><priority>0.5</priority></url>++ <url>+ <loc>https://supabase.com/customers/juniver</loc>+ <changefreq>weekly</changefreq>+ <priority>0.5</priority>+ </url><url><loc>https://supabase.com/customers/kayhanspace</loc>