Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sgiath/nostr-private-server
Nostr private relay implementation
https://github.com/sgiath/nostr-private-server
elixir elixir-phoenix nostr websockets
Last synced: about 2 months ago
JSON representation
Nostr private relay implementation
- Host: GitHub
- URL: https://github.com/sgiath/nostr-private-server
- Owner: Sgiath
- License: other
- Created: 2023-01-04T12:11:04.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-10T23:19:20.000Z (10 months ago)
- Last Synced: 2024-03-11T00:26:58.931Z (10 months ago)
- Topics: elixir, elixir-phoenix, nostr, websockets
- Language: Elixir
- Homepage: https://sgiath.dev/nostr
- Size: 126 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Nostr
Nostr client intended to be run on server for just one user
## How to run
1. Create your `.env` file
```bash
cp template.env .env
```2. Paste your private key to the `.env` file
3. Export the `.env` - the easies way is to install [direnv](https://direnv.net/) which will do it
automatically for you (you need to
[enable](https://direnv.net/man/direnv.toml.1.html#codeloaddotenvcode) exporting `.env` files)
4. Install deps `mix deps.get`
5. Start Phoenix server `mix phx.server`
6. Go to## Supervision tree
### Client
Client is `GenServer` which upon startup spawns two `DynamicSupervisor`s:
- `Connections` which supervises all active WebSocket connections
- `Subscriptions` which supervises all active Nostr subscriptionsEach subscription is executed inside in one or more connections.
Each relay connection is sending received messages to corresponding subscription process which is
handling de-duplication and sending it to handler process.Each relay connection is identified by the URL and is concerned only with sending and receiving
messages through WebSocket.Subscription process is handling encoding/decoding.
```mermaid
flowchart TD
cli[Client]
conn[Connections]
subs[Subscriptions]cli --> conn
cli --> subsconn --> relay1
conn --> relay2
conn --> relay3subs --> sub1
subs --> sub2sub1 -.-> relay1
sub1 -.-> relay2
sub1 -.-> relay3
sub2 -.-> relay3
```