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
- Timeline - Personalized feed (60% AI content + 40% member posts)
- Discover - Trending protocols, stacks, and insights
- 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 feedcommunity- AI-generated contentdiscover- Trending public postsnotifications- 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=20Response:
{
"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:
- Fetch aggregate data from patient_graph (Supabase)
- Build GPT-4 prompt with aggregate stats
- Generate 5 community posts
- Privacy validation (reject posts with PII)
- 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=xxxRun manually:
cd apps/trigger
npx trigger.dev@latest dev
# In Trigger.dev dashboard, trigger job: generate-community-insightsPrivacy & 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 testIntegration Tests:
cd apps/my-loop-health
pnpm test src/app/api/collective/feedE2E Tests:
pnpm test:e2e --spec community-feed.spec.tsNext Steps
- Circle Tab User Guide - How to use Circle tab
- GetStream Setup - Configure GetStream integration
- AI Content Generation - Customize AI post generation
- Community Moderation - Moderate community content
Related Packages
@loop/stream- GetStream integrationapps/my-loop-health- Circle tab UIapps/trigger- AI content generation job