Skip to content

twenty-eighty/pareto-client

Repository files navigation

The Pareto Project

An open source publishing ecosystem for uncensorable citizen journalism, powered by Nostr, Lightning and eCash. See more on pareto.space.

This repository contains the Pareto client, a Nostr client for reading and publishing uncensorable long-form content.

Backend and Frontend of the Pareto Nostr client

This is a monorepo with both Elixir/Phoenix backend and Elm frontend.

The backend delivers for certain routes HTML metadata for nostr articles, communities, and profiles:

  • /a/naddr1qvzqq... - metadata for long-form article
  • /c/ncomm1qvzqq... - metadata for Nostr community
  • /e/nevent1q... - metadata for Nostr article
  • /u/[email protected] - metadata for Nostr profile
  • /u/[email protected]/identifier - metadata for Nostr article
  • /p/nprofile1qyt8w... - metadata for Nostr profile

Additionally a static landing page is delivered for the home route.

There's an API available that redirects to the image of OpenGraph metadata: /api/opengraph/image??url=... This is being used for thumbnails of Odysee videos

This API call proxies OEMBED calls in order to avoid CORS issues (Twitter/X): /api/oembed

Another API endpoint helps embed Rumble videos in articles: /api/rumble/embed

NIP-05 validation JSON is served on this route: /.well-known/nostr.json?user=\<user\>

LNURL Pay JSON data is served on this route: /.well-known/lnurlp/\<user\>

Nostr Technical Information

Detailed Nostr information about this app, like supported NIPs and Kinds, can be found here.

Backend configuration

These environment variables need to be set

  • PHX_HOST: The domain where the server is accessed from external (e. g. pareto.space)
  • PORT: The port where the server accepts connections (e. g. 4000)
  • SECRET_KEY_BASE: The secret key generated by mix phx.gen.secret.
  • POSTHOG_API_KEY: The API key of a PostHog server
  • POSTHOG_HOST: Host name of a PostHog server (e. g. https://eu.i.posthog.com)

Adding Nostr users

Additional users with NIP-05 <user>@pareto.space can be added at

nostr_backend/lib/nostr_backend_web/controllers/nostr_controller.ex

Updating the landing page

This shell script downloads and modifies the landing page as needed:

nostr_backend/update_landing_page.sh

Frontend debugging

To enable debugging, write the following command in the browser console:

localStorage.setItem('debug', 'ndk*,pareto-client*');

To disable debugging, type

localStorage.removeItem('debug');

Make sure you display all log levels in the console in order to see debug messages.

Development setup

For development purposes you don't need Docker. The Docker setup is mainly intended for deployment.

  1. Setup the latest versions of Elm, Elixir and Erlang (OTP). One of the best options is asdf
  2. Install Elm Land (https://elm.land/): npm install -g elm-land@latest
  3. When using VSCodium, install Elm, Elm Land, and Elixir plugins
  4. Open the frontend and backend separately (frontend and nostr_backend directories)

Frontend

Change to the frontend directory for the following commands.

  1. run ./build.sh (only needed once to generate the code for translations and Tailwind CSS modules)
  2. run ./run.sh in the frontend directory.

In case you get a build error make sure that the following line is present in the file ~/.tool-versions: elm 0.19.1

After changes to the English language file lang/lang-en\_US.json you need to generate the related Elm code with ./gentranslations.sh.

On http://localhost:1234/read you'll find the Pareto client, served by a development server.

You'll notice a small rect bottom/right of the screen that allows to open the Elm debugger.

Backend

Change to the nostr_backend directory for the following commands.

  1. run mix deps.get to load externally referenced modules.
  2. The backend can be started locally with ./run.sh. This includes building of the frontend.

To run the backend without building the frontend execute ./dev.sh.

If you want to test single functions use iex -S mix

About

Nostr client of the Pareto project for publishing long-form content on Nostr

Topics

Resources

License

Stars

Watchers

Forks

Contributors 5