Skip to Content
Community

Community Features

Loop Health’s community platform enables members to connect, share progress, and learn from each other’s health optimization journeys.

Overview

The Circle tab provides a social experience built on:

  • GetStream - Real-time activity feeds
  • AI-Generated Content - Solves cold-start problem with data-driven posts
  • Privacy-First Architecture - No PII in community posts, aggregate data only

Key Features

🔄 Three Feed Types

  1. Timeline - Personalized feed (60% AI content + 40% member posts)
  2. Discover - Trending protocols, stacks, and insights
  3. Notifications - Activity related to you (likes, comments, follows)

🤖 AI-Generated Community Content

Problem Solved: Community cold-start - how do you populate a feed before members post?

Solution: Daily AI generation from aggregate patient data

  • Runs daily at 9am UTC via Trigger.dev
  • Queries patient_graph for aggregate stats:
    • Protocols completed (last 24h)
    • Biomarker improvements
    • Active member count
    • Top protocols, milestone achievements
  • Sends to GPT-4 for post generation
  • Privacy validation (no PII, names anonymized)
  • Publishes 5 posts to GetStream

Example AI Posts:

  • “324 members completed protocols this week — top protocol: High-Dose Recovery (47% adoption)”
  • “This week: 156 biomarker improvements reported, with hs-CRP showing average -32% reduction”
  • “Milestone: 1,000 active protocols now running across the Loop community”

👥 Social Features

  • User Profiles - Public profiles with protocol stacks, follower counts
  • Post Types - Text, protocol shares, progress updates, questions
  • Engagement - Likes, comments (threaded), shares, saves
  • Privacy Controls - Public, followers-only, private posts
  • Follow System - Follow users and protocol stacks

📊 Community Stats

Real-time metrics visible to all members:

  • Total active members
  • Protocol stacks published
  • Data points collected (labs, wearables, check-ins)

Architecture

GetStream Integration

import { getStreamClient, STREAM_FEED_GROUPS } from '@loop/stream' // Get user's timeline feed const client = getStreamClient() const feed = client.feed(STREAM_FEED_GROUPS.TIMELINE, userId) const activities = await feed.get({ limit: 20 })

Feed Groups:

  • timeline - User’s personalized feed
  • community - AI-generated content
  • discover - Trending public posts
  • notifications - User activity notifications

Mixed Feed Algorithm

60% AI content + 40% member posts, with goal-based prioritization:

import { getMixedFeed } from '@loop/stream' const feed = await getMixedFeed(userId, { limit: 25, userGoals: ['muscle recovery', 'metabolic health'] })

Posts matching user goals are ranked higher.

API Endpoints

Feed Endpoints

GET /api/collective/feed/timeline?limit=20&id_lt=xxx GET /api/collective/feed/discover?limit=20 GET /api/collective/feed/notifications?limit=20

Response:

{ "activities": [ { "id": "activity-123", "actor": "user:will", "verb": "post", "object": "post:456", "title": "Week 12 bloodwork results", "body": "hs-CRP went from 2.1 to 0.4...", "time": "2026-03-20T10:00:00Z" } ], "next": "activity-122" }

Trigger.dev Job: AI Content Generation

Job ID: generate-community-insights

Schedule: Daily at 9am UTC (0 9 * * *)

Steps:

  1. Fetch aggregate data from patient_graph (Supabase)
  2. Build GPT-4 prompt with aggregate stats
  3. Generate 5 community posts
  4. Privacy validation (reject posts with PII)
  5. Publish to GetStream community feed

Environment Variables:

STREAM_API_KEY=xxx STREAM_API_SECRET=xxx STREAM_APP_ID=xxx OPENAI_API_KEY=xxx SUPABASE_URL=xxx SUPABASE_SERVICE_ROLE_KEY=xxx

Run manually:

cd apps/trigger npx trigger.dev@latest dev # In Trigger.dev dashboard, trigger job: generate-community-insights

Privacy & Compliance

No PII in Community Posts

All AI-generated content is privacy-safe:

  • ❌ No names, emails, phone numbers
  • ❌ No specific biomarker values (only aggregates)
  • ❌ No identifiable health information
  • ✅ Aggregate stats only (counts, percentages, trends)
  • ✅ Anonymized data
  • ✅ Relative improvements (not absolute values)

Privacy Checks:

  • Automated PII detection (checkPrivacy())
  • PII scrubbing (scrubPII())
  • Manual review before publishing (if needed)

HIPAA Compliance

  • Community posts are public or followers-only (user choice)
  • No PHI exposed in posts
  • GetStream BAA signed (required)
  • Audit logs for all community activity

Testing

Unit Tests:

cd packages/stream pnpm test

Integration Tests:

cd apps/my-loop-health pnpm test src/app/api/collective/feed

E2E Tests:

pnpm test:e2e --spec community-feed.spec.ts

Next Steps

  • @loop/stream - GetStream integration
  • apps/my-loop-health - Circle tab UI
  • apps/trigger - AI content generation job