LiveLists

Deploy

In general, the infrastructure consists of three parts:


1) Self-hosted server

2) Client SDK - library for your client project

3) Server SDK - library for your server project


To use the project you must deploy self-hosted server in own infrastructure and install client and server SDKs to your projects.



Self-hosted server

The server is an application written in Go.
Application containerized in docker image, so you can run it using docker. You can also run the application by compiling the sources from the GitHub repository linked at the top of the page. To do this, Go lang must be installed on your device, and you must also specify the correct configuration file.
Also, in addition to the server, you should deploy MongoDB instance.



Run with Docker compose


Below is an example of docker compose file which runs the livelists-server and MongoDB


version: "3.6" services: mongo-livelists: image: mongo:6.0.3 restart: always entrypoint: [ "/usr/bin/mongod", "--bind_ip_all" ] volumes: - /etc/mongodbdata/:/data/db ports: - "57217:27017" livelists-server: image: nikrainev/livelists-server:latest restart: always command: livelists-server volumes: - /home/livelists/config.yaml:/pkg/config/config.yaml ports: - "17771:7771" #client port (WebSocket) - "17772:7772" #admin port (TwirpRPC)

docker-compose.yaml

This file runs MongoDB version 6.0.3 (this version well-tested for working with LiveLists), and open connection to database on 57217 port.
Also this file run LiveLists server it opens it on port 17771 and 17772. Using volumes it apply settings from external config to container. The contents of this configuration file are described below



Config


adminPort: 7772 clientPort: 7771 api_key: 'apiKey' secret_key: 'secretKey' mongo: uri: <mongoURI>

config.yaml

By default container expose two ports:
7771 (clientPort) - a web socket connection to the Client SDK is open on this port
7772 (adminPort) - a RPC service opens on this port. This service accepts the request from Server SDK.
7771 and 7772 is default ports, but you can change it by specifying other ports.

api_key and secret_key - random strings that you must specify yourself. Keep these keys securely this keys used to authorize requests from server SDK. Also



Networking


It is highly desirable (especially for WebSocket), that your connection inside TLS tunnel. You can provide a TSL connection by using a third party proxy.
Below is an example of an Nginx block, which proxies requests to server ports.


server { server_name livelists.tech; location /livelists-ws/ { proxy_pass http://localhost:17771/ws/; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Upgrade $http_upgrade; proxy_set_header X-Forwarded-Proto https; proxy_set_header Connection "upgrade"; } location /livelists-twirp/ { proxy_pass http://localhost:17772/; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; } }

default



Server SDK


To manage the service using server SDK. You must initialize the clients by passing the apiKeys and admin service host (adminPort) to them.


import { ChannelClient, ParticipantClient } from 'livelists-node-js'; class LiveListsClient { constructor() { this.channel = new ChannelClient({ apiHost: "https://livelists.tech/livelists-twirp/", apiKey: "apiKey", secretKey: "secretKey" }) this.participant = new ParticipantClient({ apiHost: "https://livelists.tech/livelists-twirp/", apiKey: "apiKey", secretKey: "secretKey" }) } public channel:ChannelClient public participant:ParticipantClient } export const LiveLists = new LiveListsClient()

LiveListsClient.ts


Client SDK


To work with the client SDK you must specify the client host (clientPort).


const { onGetConnection, ws, } = useWsConnection({ url: 'wss://livelists.tech/livelists-ws/', accessToken, }); useEffect(() => { onGetConnection(); }, []);