Replying to Avatar david

Brainstorm currently uses #neo4j to track a graph with NostrUser nodes and follows, mutes, and reports as relationship types. This schema will gradually become more complex (add NostrRelay nodes, NostrEvent nodes, various other relationship types), and in its final form it will be a continuously-updating, personalized nostr knowledge graph that your WoT helps you to manage. Native graph databases with sophisticated query languages like cypher are designed for exactly this sort of thing.

I recently joined nostr:npub1healthsx3swcgtknff7zwpg8aj2q7h49zecul5rz490f6z2zp59qnfvp8p and we are putting the finishing touches on plans for a WoT Hackathon. We’re looking to support anything that’s open source that advances nostr towards a healthy ecosystem of personalized trust metrics that are calculated by service providers (which you can do yourself, or pay a third party) and then made available to clients. Graph database nostr relays will be very useful for this, and we’d love to see multiple implementations. So if you’re interested in contributing to one, consider doing it as part of the WoTathon. We’ll be thinking of how we can facilitate individuals with common interests finding each other to form teams for projects like this.

nostr:npub10mtatsat7ph6rsq0w8u8npt8d86x4jfr2nqjnvld2439q6f8ugqq0x27hf is also building a neo4j nostr relay and you should follow his work.

nostr:npub1mgvwnpsqgrem7jfcwm7pdvdfz2h95mm04r23t8pau2uzxwsdnpgs0gpdjc has used neo4j for DVMDash — Dustin are you still working with neo4j?

nostr:npub1057d3g2zw9w4ns8fq43yka3per9s2z9zmp4ryncgqqvv6e42tjrqnrxgd7 has worked with GUN, another graph database, and has expressed interest in making a GUN nostr relay.

Anyone else working on or interested in using graph databases within nostr?

#wotathon

So I ended up dropping Neo4j because DVMs should move to encrypted setups with NIP17 or NIP-EE, and I was using Neo4j for a global event debugger for DVM flows (which isn’t possible if everything’s encrypted).

But you can check out the representation I made and the code to insert and query Nostr data, could be helpful if you’re deciding how to structure Nostr data into graphs.

Reply to this note

Please Login to reply.

Discussion

The main challenge as I see it is to ingest a high volume of events in real time. I’d love to see a general purpose nostr graph db relay, although I don’t think it will ever be as performant as non-graph relays for routine relay functionality.

Did you ever have any difficulties with real time data ingestion? Could you process them one at a time or did you need to batch them together at regular intervals? Or perhaps there was never a high enough volume of DVMs for this to be an issue?

Dude. Yes. Had to batch them basically. I was running on the low end of hardware, maybe just 1gb of ram, which is stupid expensive if you use the aura hosted version. Probably only worth it if you host Neo4j yourself on better hardware. I ended up doing a hybrid Postgres + Neo4j setup, so that I only needed to use Neo4j for queries that could benefit from the graph structure

What do you think of a hybrid solution? Last weekend I researched a few graphs to use. I settled on Cozo + sqlite. I think it solves the overhead you described. There's no need for batching. I vibed this once I picked what I thought was the optimal solution.

https://github.com/CommonSensePaine/Cozo-Relay

Cool. How big of a social graph have you achieved with it? I sync with wss://WoT.grapevine.network whenever I spin up a new brainstorm instance. It keeps track of kinds 0, 3, 1984 and 10000 just for this purpose. Should yield ~ 250k pubkeys connected via ~ 24 million follows.

Looks like what you’ve vibe coded is pretty comprehensive. All you’d have to add is NIP-85 support and you’d have a fully fledged Personalized Trust Metric Service Provider! Excellent entry for the WoTathon!🔥

I see that CozoDB supports PageRank, but looks like it only supports global, not personalized. Neo4j, memgraph and ArangoDB are the open source graph dbs that I know of that support personalized PR. Have you looked at ArangoDB? That’s one I have not looked into.

I'll have to try out a real world test this weekend and report back. I have a lot of Nostr catch up to do. So far the relay works fine but I have a bug in the sync to sort out. When is the deadline for the hackathon? I'm more interested in listening to presentation than submitting.

Our first community call will be Nov 20. Probably aim to have teams and projects lined up by mid January and run through until April.

btw I like the idea of a hybrid solution. Brainstorm is essentially a hybrid, with strfry and neo4j on a single server.