Social Network Friend Discovery
10,000 users, 8 communities, typed follow edges plus interest ranking
What if your interest matching and your social graph lived in one database, with no sync job between them?
Leo Hill
24, Austin. Competitive gamer and indie dev. Into gaming, streaming, esports, tech startups, and coding.
A hybrid query surfaced his top 20 recommendations in 4.1ms; 75% are reached through follow chains into other communities. His #1 recommendation is from finance_tech, connected by a real follow path and overlapping bios on startups and innovation.
People You May Know
We asked SwarnDB one question: who should Leo see? A hybrid query seeded by interest, walked Leo's FOLLOWS edges, and ranked the frontier by meaning, returning 20 recommendations in 4.1ms. Only 25% are fellow tech_gamers; the rest are reached through follow chains into finance_tech, foodies, music_art, and bookworms. Leo's top recommendation is from finance_tech, connected by a real follow path and overlapping bios on tech, startups, and innovation.
Key insight:Leo's top recommendation isn't a fellow gamer; it's a finance person connected by a real follow path who writes about the same things.
| # | Name | Community | Similarity |
|---|---|---|---|
| 1 | Ava Scott | finance_tech | 0.85 |
| 2 | Hassan Lee | foodies | 0.84 |
| 3 | Nathan Ramirez | foodies | 0.84 |
| 4 | Fatima Anderson | music_art | 0.83 |
| 5 | Anastasia Lopez | bookworms | 0.82 |
How the Network Grows
Starting from Leo, we walked the FOLLOWS edges outward, one hop at a time. One person. Three hops. The reachable network, traversed instantly over the edges he authored.
Key insight:From ONE person, 3 hops over the FOLLOWS edges reached 500 users across all 8 communities.
| Depth | Users Reached | Communities | Time |
|---|---|---|---|
| 1 hop | 35 | all 8 | 0.8ms |
| 2 hops | 395 | all 8 | 1.7ms |
| 3 hops | 500 | all 8 | 4.4ms |
Cross-Community Reach
Leo is a tech_gamer writing about gaming, startups, and indie development. Walking his FOLLOWS edges through intermediate users reaches people in every other community, and ranking the frontier by interest keeps the relevant ones. Each cross-community recommendation is explainable: a concrete chain of follow edges connects it.
Key insight:Cross-community recommendations follow real follow chains, then rank by interest. Every one is explainable.
| Community | Reached Via | Connection |
|---|---|---|
| Music & Art | follow chains | Creative tech, digital media crossover |
| Bookworms | follow chains | Curiosity, learning, intellectual depth |
| Travelers | follow chains | Adventure, exploration language |
| Sports & Fitness | follow chains | Competition, esports vocabulary |
| Foodies | follow chains | Community-building, entrepreneurship |
| Fashionistas | follow chains | Trend-awareness, digital culture |
| Finance & Tech | follow chains | Startups, innovation, technology |
Edge CRUD and Provenance
Social ties are typed edges you create, update, and delete. Every edge carries provenance, so you always know when and why a follow or friend tie was authored. Verify or reject edges and keep full audit history. No second store to keep in sync.
Key insight:A follow tie is something you author and can audit, not a similarity score. Every edge carries provenance.
| Operation | Edge Type | What It Does |
|---|---|---|
| put_edge | FOLLOWS | Author a directed follow tie, with provenance |
| delete_edge | FOLLOWS | Unfollow: one scoped removal |
| put_edge | BLOCKED | Block: a typed edge, no cascade across stores |
Privacy: Blocking Is Edge CRUD
Blocking is a typed BLOCKED edge authored with put_edge; unfollowing deletes the FOLLOWS edge. Each is one scoped operation on one store, with provenance and audit history. Nothing cascades across systems because there is only one system. Everyone else's ties stay intact.
Key insight:Blocking and unfollowing are ordinary edge CRUD with provenance. One scoped change, one audit trail.
| User | Action | Effect | Status |
|---|---|---|---|
| Leo Hill | put_edge BLOCKED | scoped | Hidden from the blocked party only |
| Mia Young | none | unchanged | Fully connected, unaffected |
Interest + Graph: One Query
A two-store setup requires separate calls: match by interest in the vector store, then fetch follow ties from the graph store, then join in app code. SwarnDB does it in one composable query: seed by interest, traverse the FOLLOWS edges, rank the frontier by meaning. 10 results in 18.8ms. No sync, no join.
Full Recommendation Query
Starting from a different user (Chen Larsen, a foodie), one hybrid query built a complete 'People You May Know' feed: seed by interest, traverse the FOLLOWS edges, rank the frontier by meaning. 200 recommendations across all 8 communities in 3.2ms, every one reachable through a concrete follow chain.
| Community | Users Found | Connection |
|---|---|---|
| Foodies | 34 | Core community |
| Tech & Gamers | 32 | Food tech, digital content |
| Finance & Tech | 29 | Entrepreneurship, food business |
| Fashionistas | 26 | Lifestyle, aesthetics |
| Sports & Fitness | 24 | Nutrition, clean eating |
| Bookworms | 22 | Food writing, culture |
| Travelers | 20 | Culinary travel, street food |
| Music & Art | 13 | Creative presentation |
What Would This Take Without SwarnDB?
A side-by-side look at the traditional approach versus SwarnDB.
| Capability | Traditional Stack | SwarnDB |
|---|---|---|
| Storage | Postgres + Neo4j + vector store | One database, one object per user |
| Social ties | Edges in a separate graph store | Typed FOLLOWS / FRIEND edges, same engine |
| Cross-community reach | Custom graph algorithms | Traverse the edges you authored |
| Privacy / blocking | Schema changes, cascading deletes | Typed BLOCKED edge, scoped CRUD |
| Interest + graph | Multiple queries, app-level joins | One hybrid query |
The Numbers
End-to-end performance from the benchmark run.
Embedded 10,000 profiles (OpenAI)
Loaded 10,000 profiles into SwarnDB
231 vec/sec
Leo's top 20 recommendations
Reached 500 users, all 8 communities
Cross-community recommendations
Privacy: typed BLOCKED edge
Hybrid query (10 results)
Full recommendation query
The Code
Everything above, in a few lines of Python.
from openai import OpenAI
from swarndb import SwarnDBClient
# Embed the profile text for interest matching
text = "gaming, streaming, esports, tech startups, coding. " \
"Competitive gamer and indie dev."
embedding = openai.embeddings.create(
model="text-embedding-3-small", input=text
).data[0].embedding
# The insert id is Leo's graph node id. Vector and node are one object.
leo = client.vectors.insert("social_network",
vector=embedding, metadata={"name": "Leo Hill", "city": "Austin"}
)
# A follow is a typed edge you author, with provenance.
client.graph.put_edge("social_network", source=leo, target=ava,
edge_type="FOLLOWS", provenance={"source": "app-follow"})
# People you may know: scope by structure, rank by meaning (18.8ms)
results = (
client.graph.query("social_network")
.vector_similar(leo_embedding, k=20)
.traverse("FOLLOWS", direction="outgoing")
.vector_rank(leo_embedding, k=10)
.return_nodes()
)