ophiuchus2 / wrongthink

self hosted discord clone
GNU Affero General Public License v3.0
4 stars 0 forks source link

Wrongthink

Meant to be a real time chat application, with features similar to discord (a clone basically). It's a self hosted web application with the back end implementation in c++ with support for different clients. The wrongthink protocol is defined & implemented using gRPC.

Matrix room: #wrongthink:matrix.org

Project files

Repositories

Architecture (work in progress)

img

Envoy

Because the HTTP/2 streaming APIs are not yet fully implemented in web browsers, the Envoy proxy can be used with gRPC web to allow web browsers to communicate with gRPC servers. This is required when using the wrongthink web UI. In this setup, Envoy is deployed along side the wrongthink server, and proxies messages sent via gRPC-web (javascript) to the gRPC server. See https://grpc.io/docs/platforms/web/ & https://github.com/grpc/grpc-web for details. Once the HTTP/2 streaming apis are fully implemented in web browsers, Envoy will be eliminated from the server deployment. For details on building Envoy, see https://www.envoyproxy.io/docs/envoy/latest/start/building.

Building

Third party libraries

Prerequisites

Most of the dependencies are included in the build, they are located in the third_party directory. Postgresql needs to be installed separately. The postgresql libpq library is used by SOCI for database access, but this should be included by default in the Postgresql installation. You may need to tweak the include directories in the CMakeLists.txt file depending on where the libpq header files are installed on your system:

# include directories
target_include_directories(wrongthink PUBLIC
                           include
                           ${CMAKE_CURRENT_BINARY_DIR}
                           ${CMAKE_CURRENT_BINARY_DIR}/soci/include
                           /usr/local/include/
                           /usr/include/postgresql
                           )

Postgres can either be manually set up locally, or automatically using docker

Ubuntu dependencies

sudo apt install git build-essential cmake libpq-dev libsqlite3-0 libsqlite3-dev libboost-all-dev binutils

Local Setup

Once postgresql is installed, the following needs to be done manually prior to running the wrongthink server:

  1. Create a database user named wrongthink with password test
    1. The database username/password will come from a configuration file in the future
  2. Create a new database named wrongthink that's owned by the wrongthink user

Using Docker

Install docker and docker-compose. The docker package is docker.io on debian based systems due to a naming conflict but the compose package should be docker-compose.

From the project root the following commands can then be used to control the database container:

Unix

  1. clone the repository

git clone https://github.com/ophiuchus2/wrongthink.git --recurse-submodules

  1. create cmake build directory
cd wrongthink
mkdir -p cmake/build
  1. run cmake & build
cd cmake/build
cmake ../..
make
  1. the build should complete successfully & the server + test binaries are now located in cmake/build

You should see the following files produced during the build:

  1. execute the server in one terminal and the client in another:

Server output

./wrongthink
wrongthink version: 0.1
Server listening on 0.0.0.0:50051

Client output

note: the client has not been updated for some time and is now depricated

./test_client
got channel: channel 1
got channel: channel 2
got channel: channel 3

The client creates 3 channels on the server, then retrieves them & prints their names to the console.

Running tests

Simply execute the tests binary after a successful build. The tests use these default DB connection settings:

WrongthinkUtils::setupPostgres("wrongthink", "test", "testdb");

Planned Features