Shareable Search Links: Viral Loop Infrastructure
Parent Epic: #166
Depends on: #169 (Search Results), #173 (Anonymous Sessions)
The Viral Mechanic
Every search result should be shareable. When someone finds something useful, they should be able to share it with a teammate, and that teammate should see the exact same results without needing an account.
This is how developer tools go viral. Loom did it with video links. Calendly did it with booking links. We do it with search links.
URL Structure
Short, memorable, shareable:
Expands to:
codeintel.dev/search?repo=flask&q=authentication+middleware&results=847-858,1203-1210
The short link stores:
- Repository reference
- Search query
- Specific result positions (optional, for "share this result")
Share Flow
Share Entire Search
- User runs a search
- Clicks "Share" button in header
- Short link is generated and copied to clipboard
- Toast: "Link copied. Anyone can view these results."
Share Specific Result
- User hovers over a result
- Click share icon on that result
- Short link includes that specific result highlighted
- Recipient lands with that result scrolled into view and highlighted
Database Schema
CREATE TABLE shared_searches (
id VARCHAR(12) PRIMARY KEY, -- Short ID (abc123)
repo_id VARCHAR(100) NOT NULL,
query TEXT NOT NULL,
result_context JSONB, -- Optional: specific results to highlight
created_at TIMESTAMP DEFAULT NOW(),
created_by UUID, -- NULL for anonymous users
view_count INT DEFAULT 0,
expires_at TIMESTAMP -- Optional expiration
);
API Endpoints
Create Share Link
POST /api/v2/share
{
"repo_id": "flask",
"query": "authentication middleware",
"highlight_results": [
{ "file": "src/flask/app.py", "lines": [847, 858] }
]
}
Response:
{
"short_id": "abc123",
"url": "https://codeintel.dev/s/abc123",
"expires_at": null
}
Resolve Share Link
GET /api/v2/share/abc123
Response:
{
"repo_id": "flask",
"query": "authentication middleware",
"highlight_results": [...],
"created_at": "2026-01-06T...",
"view_count": 42
}
Landing Experience for Shared Links
When someone clicks a shared link:
- Page loads with the search already executed
- Results visible immediately (no signup)
- Highlighted result is scrolled into view
- Subtle banner: "Shared by a CodeIntel user. Try your own search."
- Full functionality available (Explain, Copy, etc.)
Share UI Components
Header Share Button
[Share Search] <- Always visible when results exist
Per-Result Share
[Explain] [Copy] [Share] [GitHub]
^
Copied Toast
┌─────────────────────────────────┐
│ Link copied to clipboard │
│ codeintel.dev/s/abc123 │
└─────────────────────────────────┘
Share Modal (Optional Enhancement)
┌─────────────────────────────────────────┐
│ Share this search │
│ │
│ [codeintel.dev/s/abc123 ] [Copy] │
│ │
│ [Twitter] [Slack] [Email] │
│ │
│ Anyone with this link can view │
│ the search results. │
└─────────────────────────────────────────┘
Social Sharing
Pre-formatted messages for each platform:
Twitter/X:
Found this useful code pattern in Flask: [search query]
[link]
Slack:
[link]
^ Check out this code I found - [search query] in [repo]
Analytics
Track:
- Share link created (with repo, query length)
- Share link clicked (with referrer)
- Share link converted (viewer signs up)
This tells us which queries are most share-worthy and helps optimize the viral loop.
Implementation Tasks
Acceptance Criteria
Rate Limiting
Anonymous users: 20 share links per hour
Authenticated users: Unlimited
This prevents abuse while allowing legitimate sharing.
Shareable Search Links: Viral Loop Infrastructure
Parent Epic: #166
Depends on: #169 (Search Results), #173 (Anonymous Sessions)
The Viral Mechanic
Every search result should be shareable. When someone finds something useful, they should be able to share it with a teammate, and that teammate should see the exact same results without needing an account.
This is how developer tools go viral. Loom did it with video links. Calendly did it with booking links. We do it with search links.
URL Structure
Short, memorable, shareable:
Expands to:
The short link stores:
Share Flow
Share Entire Search
Share Specific Result
Database Schema
API Endpoints
Create Share Link
Resolve Share Link
Landing Experience for Shared Links
When someone clicks a shared link:
Share UI Components
Header Share Button
Per-Result Share
Copied Toast
Share Modal (Optional Enhancement)
Social Sharing
Pre-formatted messages for each platform:
Twitter/X:
Slack:
Analytics
Track:
This tells us which queries are most share-worthy and helps optimize the viral loop.
Implementation Tasks
POST /api/v2/shareendpointGET /api/v2/share/:idendpointcomponents/search/ShareButton.tsxcomponents/ui/ShareModal.tsx(optional)/s/[id]page routeAcceptance Criteria
Rate Limiting
Anonymous users: 20 share links per hour
Authenticated users: Unlimited
This prevents abuse while allowing legitimate sharing.