Skip to main content

A minimal self-hosted peer-to-peer chat application.

Project description

peerChat

A minimal self-hosted peer-to-peer chat application written in python (Flask+Socket.IO-backend) and TypeScript (React-frontend).

It is

  • platform-independent,
  • easy to setup and use,

and features for example

  • message queues (auto-resend if peers are offline)

See the demo-gallery for some impressions.

Install

peerChat can be installed using pip by entering

pip install peerChat

It is recommended to use a virtual environment

python3 -m venv venv
source venv/bin/activate

Run

Start the peerChat-application with

peerChat

By default, the web-UI is available on port http://localhost:27182. If you are done, stop by hitting Ctrl+C.

When the UI is first opened, some configuration has to be performed. Follow the dialog shown in the UI to set a key (or password) that will be used to authenticate with the server. Note that this key will be stored unencrypted in your file system (peerChat is intended to be run locally so usually that key will never leave the local machine).

After this technical setup is complete, your profile can be customized by selecting Settings in the context menu at the top of the sidebar. Here, most importantly, you should set your public network address to ensure your peers can respond to your messages.

Update

Run

pip install --upgrade peerChat

to get the latest version.

Running as a systemd-service

The peerChat-app can be run as a systemd-service (linux) that automatically starts with the system. After cloning this repository, simply run

make service

for a default configuration (install/working directory is given by ~/.local/share/peerChat and the service-file is written to ~/.config/systemd/user/peerChat.service). Check the service's status with

systemctl --user status peerChat.service

Disable or stop the service by entering

systemctl --user <disable|stop> peerChat.service

Building from source

The provided Makefile provides targets for building from source. Run

  • make build to build the python package bundled with the static client (react)
    • the distribution-files can be found in backend/dist
    • the build version can be set with make build VERSION="1.0.0.post5+a6cd1d01"
    • the client build can be skipped with make build SKIP_CLIENT="yes"
  • make clean to remove build artifacts

A build requires npm as well as the venv-module of python3 to be successful.

Authorization-concept

Since the service is intended for self-hosting, it only supports a single user per running instance of peerChat. In order to identify a user, a (automatically generated or user-defined) key is used. The backend-API allows to configure this key only once.

To reset that key, the corresponding key-file .peerChat.auth can be deleted. After deleting, the service needs to be restarted for changes to take effect.

Environment configuration

The following environment variables can be set to configure peerChat:

  • PORT [DEFAULT 27182] peerChat port
  • WORKING_DIRECTORY [DEFAULT ".peerChat"] working directory of the application; default is the subdirectory .peerChat in the current working directory
  • SECRET_KEY [DEFAULT null] override the otherwise automatically generated secret key
  • USER_PEER_URL [DEFAULT null] can be used to set the public peer-url; can also be set via the UI
  • MODE [DEFAULT prod] execution mode; one of "prod" or "dev"

Extended options for configuration can be accessed via the AppConfig-class used by the underlying flask-webserver which is passed in to the app-factory.

Public API

The public part of the peerChat-API can be used to

  • fetch information on a given peer,
  • post messages, and
  • notify of changes.

Please refer to the OpenAPI v3-document openapi.yaml for details.

Running in dev-mode

The development setup requires both python3 and the node package manager npm to be installed. Contrary to the pure python production server, back- and frontend are run separately in the development context.

To run the backend server, enter

cd backend
python3 -m venv venv
source venv/bin/activate
pip install .
pip install -r dev-requirements.txt
MODE=dev flask run

Based on pre-defined scripts, the frontend development server can be started with

cd frontend
npm install
npm start

The client can then be accessed via the node-development server at http://localhost:3000.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

peerchat-0.1.1.tar.gz (172.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

peerchat-0.1.1-py3-none-any.whl (172.2 kB view details)

Uploaded Python 3

File details

Details for the file peerchat-0.1.1.tar.gz.

File metadata

  • Download URL: peerchat-0.1.1.tar.gz
  • Upload date:
  • Size: 172.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for peerchat-0.1.1.tar.gz
Algorithm Hash digest
SHA256 935600aeeea7dcbf191ce5aed81123300b603e799042e0e2a5386ab0456c3847
MD5 f0868b9f7c71083ffcab9ca5a66c2095
BLAKE2b-256 2f526d560ff256133419747cb93d0b1fc13b361a222cbfd1f353a1cd76b7bbe2

See more details on using hashes here.

File details

Details for the file peerchat-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: peerchat-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 172.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for peerchat-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f0749cf02e4878c8f7b823f938bd7aaffe8ab8d0014700b01bfe1fb55b5dbddc
MD5 14c8b43b73b5557199f39873944945d1
BLAKE2b-256 6c624d57cd5f457200944185e1bdf540d2c6abed59d11ab0ec8fac2984e8caa7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page