Back to Showcases
Social MediaStandard

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?

Typed Social EdgesGraph TraversalCross-Community ReachEdge CRUD and ProvenanceHybrid QueryBulk Edge Import

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.

10,000
Users Indexed
8
Communities
4.1ms
Friend Recommend
500 users
Network Reach (3 hops)
01

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.

4.1msRecommendation
#NameCommunitySimilarity
1Ava Scottfinance_tech0.85
2Hassan Leefoodies0.84
3Nathan Ramirezfoodies0.84
4Fatima Andersonmusic_art0.83
5Anastasia Lopezbookworms0.82
02

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.

500Users Reached (3 hops)
DepthUsers ReachedCommunitiesTime
1 hop35all 80.8ms
2 hops395all 81.7ms
3 hops500all 84.4ms
03

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.

all 8Communities Reached
CommunityReached ViaConnection
Music & Artfollow chainsCreative tech, digital media crossover
Bookwormsfollow chainsCuriosity, learning, intellectual depth
Travelersfollow chainsAdventure, exploration language
Sports & Fitnessfollow chainsCompetition, esports vocabulary
Foodiesfollow chainsCommunity-building, entrepreneurship
Fashionistasfollow chainsTrend-awareness, digital culture
Finance & Techfollow chainsStartups, innovation, technology
04

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.

Per-EdgeProvenance
OperationEdge TypeWhat It Does
put_edgeFOLLOWSAuthor a directed follow tie, with provenance
delete_edgeFOLLOWSUnfollow: one scoped removal
put_edgeBLOCKEDBlock: a typed edge, no cascade across stores
05

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.

UserActionEffectStatus
Leo Hillput_edge BLOCKEDscopedHidden from the blocked party only
Mia YoungnoneunchangedFully connected, unaffected
06

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.

18.8msHybrid Query
07

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.

3.2ms200 Recommendations
CommunityUsers FoundConnection
Foodies34Core community
Tech & Gamers32Food tech, digital content
Finance & Tech29Entrepreneurship, food business
Fashionistas26Lifestyle, aesthetics
Sports & Fitness24Nutrition, clean eating
Bookworms22Food writing, culture
Travelers20Culinary travel, street food
Music & Art13Creative presentation

What Would This Take Without SwarnDB?

A side-by-side look at the traditional approach versus SwarnDB.

CapabilityTraditional StackSwarnDB
StoragePostgres + Neo4j + vector storeOne database, one object per user
Social tiesEdges in a separate graph storeTyped FOLLOWS / FRIEND edges, same engine
Cross-community reachCustom graph algorithmsTraverse the edges you authored
Privacy / blockingSchema changes, cascading deletesTyped BLOCKED edge, scoped CRUD
Interest + graphMultiple queries, app-level joinsOne hybrid query

The Numbers

End-to-end performance from the benchmark run.

Embedded 10,000 profiles (OpenAI)

~80 sec

Loaded 10,000 profiles into SwarnDB

231 vec/sec

43.4 sec

Leo's top 20 recommendations

4.1ms

Reached 500 users, all 8 communities

3 hops

Cross-community recommendations

all 8 communities

Privacy: typed BLOCKED edge

scoped

Hybrid query (10 results)

18.8ms

Full recommendation query

3.2ms

The Code

Everything above, in a few lines of Python.

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()
)

Try it yourself

Clone the repo, spin up SwarnDB, and run this showcase in minutes.

View on GitHub