Skip to content

Latest commit

 

History

History
186 lines (147 loc) · 4.91 KB

File metadata and controls

186 lines (147 loc) · 4.91 KB

Shared Research Sessions Implementation Summary

✅ What Was Implemented

A complete public share route for research sessions at /researchSession/[shareId] with full social media preview support (Open Graph + Twitter Cards).

📁 Files Created

  1. /api/researchSession/[shareId].js (270 lines)

    • Vercel serverless function for server-side rendering
    • Fetches metadata from backend API
    • Generates HTML with meta tags for social scrapers
    • Redirects human users to React app
    • Handles 404 and error cases
  2. /vercel.json

    • Routes /researchSession/:shareId to the serverless function
    • Sets caching headers for optimal performance
  3. /docs/SHARED_RESEARCH_SESSIONS.md

    • Complete documentation of the feature
    • Setup instructions, testing guide, troubleshooting

📝 Files Modified

  1. /src/services/researchSessionShareService.ts

    • Added fetchSharedResearchSession() function
    • Fetches public shared sessions from backend
  2. /src/components/SearchInterface.tsx

    • Added import for fetchSharedResearchSession
    • Added useEffect to detect ?sharedSession=<shareId> parameter
    • Loads shared session data and displays in galaxy view

🔧 Environment Variables Required

Add these to Vercel:

BACKEND_BASE_URL=https://your-backend-url
NEXT_PUBLIC_FRONTEND_URL=https://pullthatupjamie.ai

🚀 How It Works

For Scrapers (X/Twitter, Slack, iMessage)

User shares link → /researchSession/abc123
         ↓
Vercel serverless function fetches metadata
         ↓
Returns HTML with Open Graph + Twitter meta tags
         ↓
Scraper displays rich preview with title, description, image

For Human Users

User clicks link → /researchSession/abc123
         ↓
HTML with meta tags loads (for scrapers)
         ↓
JavaScript redirect → /app?sharedSession=abc123
         ↓
React app loads shared session in galaxy view
         ↓
User can interact with full research session

🎨 Generated Meta Tags

  • Title: From data.title
  • Description: From data.description
  • Image: From data.previewImageUrl
  • URL: https://pullthatupjamie.ai/researchSession/:shareId
  • Twitter Card: summary_large_image

🧪 Testing

Local Development

# Terminal 1: Start backend
cd backend && npm start  # Port 4132

# Terminal 2: Start Vercel dev server
vercel dev  # Port 3000

Visit: http://localhost:3000/researchSession/test-id

Test Social Previews

📋 Backend API Requirements

Your backend must implement:

GET /api/shared-research-sessions/:shareId

Response format:

{
  "success": true,
  "data": {
    "title": "Session Title",
    "description": "Session Description", 
    "previewImageUrl": "https://cdn.example.com/image.png",
    "nodes": [
      {
        "pineconeId": "id",
        "x": 0.5, "y": 0.3, "z": 0.1,
        "color": "#ffffff",
        "metadata": {
          "quote": "...",
          "summary": "...",
          "episode": "...",
          "creator": "...",
          "hierarchyLevel": "paragraph"
        }
      }
    ]
  }
}

✅ Requirements Met

  • ✅ Public route at /researchSession/[shareId]
  • ✅ Server-rendered meta tags (not client-side)
  • ✅ Open Graph tags for social media
  • ✅ Twitter Card tags with summary_large_image
  • ✅ Works with link preview scrapers (X, Slack, iMessage)
  • ✅ Fetches from backend API
  • ✅ 404 handling for missing sessions
  • ✅ Interactive view for human users
  • ✅ Minimal, production-safe code
  • ✅ No changes to unrelated routing

🔄 Deployment Steps

  1. Commit the changes:

    git add .
    git commit -m "Add shared research sessions public route with SSR meta tags"
  2. Set Vercel environment variables:

    • Go to Vercel dashboard → Project → Settings → Environment Variables
    • Add BACKEND_BASE_URL with your production backend URL
    • Add NEXT_PUBLIC_FRONTEND_URL as https://pullthatupjamie.ai
  3. Deploy:

    git push

    Or deploy via Vercel dashboard

  4. Test:

    • Share a link: https://pullthatupjamie.ai/researchSession/test-id
    • Verify meta tags: View Page Source
    • Test social preview: Use validator tools above

🐛 Troubleshooting

Meta tags not showing?

  • View page source - meta tags should be in initial HTML
  • Check serverless function logs in Vercel
  • Verify backend API is accessible

404 errors?

  • Ensure vercel.json is committed
  • Check that /api folder exists in project root
  • Verify function file path matches route pattern

React app not loading session?

  • Check browser console for errors
  • Verify ?sharedSession query parameter
  • Check network tab for API requests

📚 Additional Resources

See /docs/SHARED_RESEARCH_SESSIONS.md for complete documentation.