# Protocol
This document defines the protocol that chat clients will use to comminicate with hosted server instances. Clients will need to not only transmit chat messages but control messages and possibly binary data like images or files. To get the most efficient data transport possible, we will be using gRPC and protocol buffers to define our protocol.
**Examples of control messages:**
* RPC commands to the server
* create channel
* get server public channel listing
* create account
* initiate image/file transfer
* key sharing for E2E encrypted channels
* share a magnet link for webtorrent based file sharing
## Envoy
Because the HTTP/2 streaming APIs are not yet fully implemented in web browsers, the [Envoy proxy](https://www.envoyproxy.io/) can be used with [gRPC web](https://github.com/grpc/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.
## Tech
* `boost` - https://www.boost.org/
* `coroutine examples` - https://github.com/luncliff/coroutine
* https://gist.github.com/MattPD/9b55db49537a90545a90447392ad3aeb
* `lib of coroutine abstractions` - https://github.com/lewissbaker/cppcoro
* mit licensed
* `c++ http server lib` - https://github.com/titi38/libnavajo
* http
* ssl
* websockets
* static & dynamic pages
* compile static pages into binary
* license: CeCILL-C FREE SOFTWARE LICENSE AGREEMENT
* some strange open source license
* `restbed` - https://github.com/Corvusoft/restbed - c++ http/websocket library for restful applications
* AGPL licensed - [wiki](https://en.wikipedia.org/wiki/Affero_General_Public_License)
* >This provision requires that the full source code be made available to any network user of the AGPL-licensed work, typically a web application.
* **`uWebsockets` - https://github.com/uNetworking/uWebSockets**
* Simple, secure & standards compliant web server for the most demanding of applications
* modern
* regular updates
* websockets & http
* Apache License 2.0 - [wiki](https://en.wikipedia.org/wiki/Apache_License)
* >The Apache License is a permissive free software license written by the Apache Software Foundation (ASF).[5] It allows users to use the software for any purpose, to distribute it, to modify it, and to distribute modified versions of the software under the terms of the license, without concern for royalties. The ASF and its projects release their software products under the Apache License. The license is also used by many non-ASF projects.
* `mongodb c++ driver` - https://github.com/mongodb/mongo-cxx-driver
* `mongodb` - https://www.mongodb.com/
* `https://webtorrent.io/faq` - web torrent
* webrtc
* https://github.com/pion/webrtc
* https://github.com/webrtc/samples
* https://www.html5rocks.com/en/tutorials/webrtc/basics/#toc-signaling
* https://webrtc-security.github.io/
* https://gist.github.com/jo/8619441 - list of js crypto libs
* https://github.com/signalapp/libsignal-protocol-c
* https://github.com/jtv/libpqxx - postgresql c++ driver
* https://github.com/rbock/sqlpp11 - A type safe embedded domain specific language for SQL queries and results in C++
* https://www.graphile.org/postgraphile/postgresql-schema-design/
* https://developers.google.com/protocol-buffers
* https://github.com/improbable-eng/grpc-web
* https://github.com/grpc/grpc
* `websocket protocol` - https://tools.ietf.org/html/rfc6455
* `coturn` - https://github.com/coturn/coturn - STUN/TURN server in c
* `turn protocol` - https://tools.ietf.org/html/rfc5766
* `ice protocol` - https://tools.ietf.org/html/rfc5245
* `web rtc status page` - https://tools.ietf.org/wg/rtcweb/draft-ietf-rtcweb-overview/
* `soci` - https://github.com/SOCI/soci - c++ database access layer
* https://github.com/grpc/grpc-web
* https://github.com/arun11299/cpp-jwt
* https://github.com/graeme-hill/crossguid
* https://www.boost.org/doc/libs/1_74_0/doc/html/signals2.html
* https://github.com/boostorg/uuid
* https://github.com/gabime/spdlog - logging lib
* https://github.com/libp2p/cpp-libp2p
* https://doc.qt.io/qt-5/qtwebengine-overview.html
## wrongthink-react-ui
* https://github.com/FaridSafi/react-native-gifted-chat - react chat ui
* https://github.com/Semantic-Org/Semantic-UI-React
* https://github.com/rexxars/react-markdown
## front end
* https://github.com/vuejs/vue
* https://github.com/vuetifyjs/vuetify
* https://github.com/Coffcer/vue-chat - vue chat example
* https://github.com/mattmezza/vue-beautiful-chat
* **https://github.com/quasarframework/quasar**
* https://github.com/facebook/react
* https://reactjs.org/docs/getting-started.html
* https://github.com/enaqx/awesome-react#react
* https://github.com/mattermost/mattermost-webapp
* https://github.com/brillout/awesome-react-components
* https://github.com/STRML/react-grid-layout
* https://github.com/palantir/blueprint
## Resources
* https://grpc.io/blog/state-of-grpc-web/
* `discussion on grpc` - https://news.ycombinator.com/item?id=9114748
* `turn protocol` - https://tools.ietf.org/html/rfc5766
* `ethereum whitepaper` - https://ethereum.org/whitepaper/
* `http/2 protocol` - https://tools.ietf.org/html/rfc7540
* https://foonathan.net/2016/07/cmake-dependency-handling/
* https://github.com/grpc/grpc-web/blob/master/net/grpc/gateway/examples/echo/envoy.yaml
* https://grpc.io/docs/languages/web/basics/
### Authentication
* https://jwt.io/
* perhaps a similar approach to jwt could be used, but with proto bufs
* https://grpc.io/docs/guides/auth/
* https://auth0.com/learn/json-web-tokens/
* https://www.signal.org/docs/
* https://security.stackexchange.com/questions/126768/which-protocols-exist-for-end-to-end-encrypted-group-chat
* https://www.ieee-security.org/TC/SP2015/papers-archived/6949a232.pdf
* https://messaginglayersecurity.rocks/
* [whats app encryption](https://scontent.whatsapp.net/v/t61.22868-34/68135620_760356657751682_6212997528851833559_n.pdf/WhatsApp-Security-Whitepaper.pdf?_nc_sid=41cc27&_nc_ohc=JlPsBK-B7v4AX-ZI_S8&_nc_ht=scontent.whatsapp.net&oh=133d5ba5670885175dae7af23135c59e&oe=5F61D613)
* https://signal.org/blog/private-groups/