DVMDash aims to be a monitoring and debugging tool for DVM activity on Nostr. Data Vending Machines (nip-90) offload computationally expensive tasks from relays and clients in a decentralized, free-market manner. They are especially useful for AI tools, algorithmic processing of user’s feeds, and many other use cases.
A version of the website is running here:
These instructions aren't complete but hopefully are helpful for those with some experience with Django, mongo db, and neo4j. Feel free to open an issue if you have any problems running this locally. We will write better instructions after we refactor the backend architecture.
- Clone the repo and create a virtual env (tested with Python3.12 but other versions may work)
git clone https://github.com/dtdannen/dvmdash.git
cd dvmdash
python3.12 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
pip install -e . # this is so the general/ folder is available to the django app
- Get a neo4j and mongo db running
-
Neo4j is used to store the graph of DVM events
- You can use hosted instances or local instances.
- Neo4j offers a free hosted solution for testing, which has enough capacity to test out the system. See https://neo4j.com/product/auradb/?ref=neo4j-home-hero
- If you are running neo4j locally,
- See https://neo4j.com/docs/operations-manual/current/installation/
- Once you have the tar file, you can run it with
./neo4j start
- Or
~/bin/neo4j-community-5.20.0/bin/neo4j start
- Or
- Then check it's running in the web browser at
http://localhost:7474/
-
Mongo DB should be straightforward
- Often, running mongodb locally looks like:
./mongod --dbpath ~/mongodb/data/db
- Often, running mongodb locally looks like:
- Populate the .env file with the connection parameters for your databases
- You can copy the .env.example file to .env and fill in the connection parameters for your databases.
-
Run the background scripts to start collecting DVM related events from relays. If you don't do this step, the django web app will not have any data or metrics to show. Run each one of them in their own terminal window. If running these on a server, consider
screen
or run them as a cron job. -
Run the Django web app
# ensure virtualenv is activated (i.e. source venv/bin/activate)
# ensure you're at the project root
python dvmdash/manage.py runserver
It may take a few seconds to connect to both neo4j and mongo databases. Once it's running, you can view the web app at http://localhost:8000/
- After you've added a new library to the package.json file and made any changes to webpack.config.js, you can run
npm run build
to update the javascript files in the static/ directory in the monitor/static/ directory. - Then run
python dvmdash/manage.py collectstatic
to update the static files in the main staticfiles/ directory, which is where static files are served when running locally.
-
Run a MongoDB locally
- for example, run mongo locally:
./mongod --dbpath ~/mongodb/data/db
- for example, run mongo locally:
-
Run Neo4j
- See https://neo4j.com/docs/operations-manual/current/installation/
- Once you have the tar file, you can run it with
./neo4j start
- Or
~/bin/neo4j-community-5.20.0/bin/neo4j start
- Or
- Then check it's running in the web browser at
http://localhost:7474/
-
(Optional) Run a local DVM
-
(Optional) Run a local relay, such as bucket
- this is helpful to test local dvms with the playground page, testing sending and receiving DVM events.
- Download the APOC library JAR file that matches your Neo4j version from the APOC releases page on GitHub: https://github.com/neo4j/apoc/releases
- Copy the APOC JAR file to the plugins directory of your Neo4j installation. For example, if you're using Neo4j 4.x, the path would be neo4j-home/plugins/.
- Open the neo4j.conf configuration file located in the conf directory of your Neo4j installation.
- Uncomment or add the following line to the neo4j.conf file to enable the APOC library:
dbms.security.procedures.unrestricted=apoc.*
The graph structure of events is stored in a Neo4j database.
- Entity:
- These have an npub, and contain all users and DVMs
- Event:
- These are Nostr events signed by Entities
- Invoice:
- Data that contains information for a payment. Events refer to these
- Payment Receipt:
- Data showing a receipt of purchase, such as a zap receipt.
Note that these are the primitive relationships. There will be other, inferred relationships later based on the primitive ones.
- MAKES_EVENT: # Used any time an entity makes an event
- Entity -> Event
- FEEDBACK_FOR: # Used to connect a DVM feedback event to the original request
- Event -> Event
- RESULT_FOR: # Used to connect a DVM result event to the original request
- Event -> Event
- HAS_INVOICE: # Used to connect a feedback event to an invoice
- Event -> Invoice
- HAS_RECEIPT: # Used to connect an invoice to a payment receipt
- Invoice -> Payment Receipt
- PAYMENT_FROM: # Used to connect a payment receipt to the entity that paid
- Payment Receipt -> Entity
- PAYMENT_TO: # Used to connect a payment receipt to the entity that received the payment
- Payment Receipt -> Entity
These are the relays where we watch for DVM events.
- wss://nostr-pub.wellorder.net
- wss://relay.damus.io
- wss://nos.lol
- wss://relay.primal.net
- wss://offchain.pub
- wss://nostr.mom
- wss://relay.nostr.bg
- wss://nostr.oxtr.dev
- wss://relay.nostr.bg
- wss://nostr-relay.nokotaro.com
- wss://relay.nostr.wirednet.jp