From 55d8958d9767296a3875e6b6b9b57b0142654173 Mon Sep 17 00:00:00 2001 From: orcas Date: Mon, 24 Jun 2019 15:10:10 +0800 Subject: [PATCH 1/6] backend-webrtc initial logic --- .gitmodules | 3 +++ backend-webrtc | 1 + 2 files changed, 4 insertions(+) create mode 160000 backend-webrtc diff --git a/.gitmodules b/.gitmodules index ab386a2..4665e0d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -34,3 +34,6 @@ [submodule "backend-permissions"] path = backend-permissions url = git@makerforce.io:beep/backend-permissions.git +[submodule "backend-webrtc"] + path = backend-webrtc + url = git@makerforce.io:beep/backend-webrtc.git diff --git a/backend-webrtc b/backend-webrtc new file mode 160000 index 0000000..0fecc20 --- /dev/null +++ b/backend-webrtc @@ -0,0 +1 @@ +Subproject commit 0fecc209b0d1adbf71095db8d5773f5cee8d137a From 685552740d22e784a18f13b0a94715aa70c2e29d Mon Sep 17 00:00:00 2001 From: orcas Date: Mon, 24 Jun 2019 22:49:18 +0800 Subject: [PATCH 2/6] Fixed mistake not copying backend-protobuf/go in Dockerfile --- backend-bite | 2 +- backend-publish | 2 +- backend-store | 2 +- backend-subscribe | 2 +- backend-transcription | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend-bite b/backend-bite index ec30535..f847fe3 160000 --- a/backend-bite +++ b/backend-bite @@ -1 +1 @@ -Subproject commit ec305353875029477f9d19d24bb829f4b1c0b9de +Subproject commit f847fe3402a2d0e5c1de50464a285cf7c91f8476 diff --git a/backend-publish b/backend-publish index d105441..42e1b65 160000 --- a/backend-publish +++ b/backend-publish @@ -1 +1 @@ -Subproject commit d105441d41d01ba590c9ce4c26dfb4a763ca5125 +Subproject commit 42e1b651d46f8e7cc2b084a8d84e312751e8c267 diff --git a/backend-store b/backend-store index 01a6b67..ec70263 160000 --- a/backend-store +++ b/backend-store @@ -1 +1 @@ -Subproject commit 01a6b678abfc5b42edb42abb120cd38ddc6f0754 +Subproject commit ec7026385b65e7a9cd97fe8930a9252f9be21fb6 diff --git a/backend-subscribe b/backend-subscribe index 5efeab4..40da1b0 160000 --- a/backend-subscribe +++ b/backend-subscribe @@ -1 +1 @@ -Subproject commit 5efeab4699d824722e14d7900c6b9d38675c9b93 +Subproject commit 40da1b00bc771840446b887979bd0c69b483fc1f diff --git a/backend-transcription b/backend-transcription index b5b09fc..680259c 160000 --- a/backend-transcription +++ b/backend-transcription @@ -1 +1 @@ -Subproject commit b5b09fc8150d87b2953eeb758ff073462dc50aec +Subproject commit 680259c08740273830d40e7e1a74d3d3247353f4 From 7df967fbec39f215eaa9517cd5f21d04cdf38e17 Mon Sep 17 00:00:00 2001 From: orcas Date: Mon, 24 Jun 2019 22:53:51 +0800 Subject: [PATCH 3/6] Service and router entry for backend-webrtc --- docker-compose.yml | 12 +++++++++++- traefik.toml | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index f6d66c5..b8d84bf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,6 +12,8 @@ services: - subscribe - transcription - auth + - pictures + - webrtc ports: - "80:80" - "443:443" @@ -98,6 +100,15 @@ services: - redisnet - traefiknet + webrtc: + build: ./backend-webrtc + tty: true + restart: unless-stopped + environment: + - LISTEN=:80 + networks: + - traefiknet + login: build: ./backend-login tty: true @@ -143,7 +154,6 @@ services: restart: unless-stopped depends_on: - minio - - traefik environment: - LISTEN=:80 - MINIO_ENDPOINT=minio:9000 diff --git a/traefik.toml b/traefik.toml index 4a74ddb..67ba62e 100644 --- a/traefik.toml +++ b/traefik.toml @@ -163,6 +163,23 @@ entrypoints = ["http", "https"] [frontends.pictures.routes.one] rule = "PathPrefixStrip: /pictures/" +# webrtc +[backends.webrtc] + [backends.webrtc.servers.one] + url = "http://webrtc" + [frontends.webrtc.headers.customresponseheaders] + Access-Control-Allow-Origin = "*" + Access-Control-Allow-Headers = "Content-Type, Authorization, X-User-Claim" + Access-Control-Allow-Credentials = "true" + Access-Control-Allow-Methods = "GET, HEAD, POST, PUT, PATCH, DELETE" + [frontends.webrtc.routes.one] + rule = "PathPrefixStrip: /webrtc/" + +[frontends.webrtc] +backend = "webrtc" +entrypoints = ["http", "https"] + + # login [backends.login] [backends.login.servers.one] From d3e11fee949e857c729007c8e40d6db8801e4dd3 Mon Sep 17 00:00:00 2001 From: orcas Date: Thu, 27 Jun 2019 06:56:13 +0800 Subject: [PATCH 4/6] backend-webrtc push Bite and Store to NATs --- backend-webrtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend-webrtc b/backend-webrtc index 0fecc20..de78442 160000 --- a/backend-webrtc +++ b/backend-webrtc @@ -1 +1 @@ -Subproject commit 0fecc209b0d1adbf71095db8d5773f5cee8d137a +Subproject commit de78442f6a71151094ea4d7fe4338c2cfe692858 From 3aa41b6361cc4125ff1661a473ec0a4c1a356df2 Mon Sep 17 00:00:00 2001 From: orcas Date: Fri, 28 Jun 2019 23:59:26 +0800 Subject: [PATCH 5/6] Integrated backend-transcription into revised bite pipeline --- backend-transcription | 2 +- backend-webrtc | 2 +- docker-compose.yml | 7 ++++--- traefik.toml | 16 ---------------- 4 files changed, 6 insertions(+), 21 deletions(-) diff --git a/backend-transcription b/backend-transcription index 680259c..9e8ae9b 160000 --- a/backend-transcription +++ b/backend-transcription @@ -1 +1 @@ -Subproject commit 680259c08740273830d40e7e1a74d3d3247353f4 +Subproject commit 9e8ae9b73ed1d3dda62022d2294a07017606863d diff --git a/backend-webrtc b/backend-webrtc index de78442..f7d9197 160000 --- a/backend-webrtc +++ b/backend-webrtc @@ -1 +1 @@ -Subproject commit de78442f6a71151094ea4d7fe4338c2cfe692858 +Subproject commit f7d9197940119f964d21583d8077c6fec0e1a0d3 diff --git a/docker-compose.yml b/docker-compose.yml index b8d84bf..ffaa976 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,6 @@ services: - bite - publish - subscribe - - transcription - auth - pictures - webrtc @@ -104,10 +103,14 @@ services: build: ./backend-webrtc tty: true restart: unless-stopped + depends_on: + - nats environment: - LISTEN=:80 + - NATS=nats://nats:4222 networks: - traefiknet + - natsnet login: build: ./backend-login @@ -242,12 +245,10 @@ services: depends_on: - nats environment: - - LISTEN=:80 - NATS=nats://nats:4222 - API_KEY=AIzaSyDxSXDefzw9gXCQaVzOCYlRn_vcC9Da9Q0 networks: - natsnet - - traefiknet networks: authnet: diff --git a/traefik.toml b/traefik.toml index 67ba62e..32642c1 100644 --- a/traefik.toml +++ b/traefik.toml @@ -131,22 +131,6 @@ entrypoints = ["http", "https"] [frontends.subscribe.routes.one] rule = "PathPrefixStrip: /subscribe/" -# transcription -[backends.transcription] - [backends.transcription.servers.one] - url = "http://transcription" - -[frontends.transcription] -backend = "transcription" -entrypoints = ["http", "https"] - [frontends.transcription.headers.customresponseheaders] - Access-Control-Allow-Origin = "*" - Access-Control-Allow-Headers = "Content-Type, Authorization, X-User-Claim" - Access-Control-Allow-Credentials = "true" - Access-Control-Allow-Methods = "GET, HEAD, POST, PUT, PATCH, DELETE" - [frontends.transcription.routes.one] - rule = "PathPrefixStrip: /transcription/" - # pictures [backends.pictures] [backends.pictures.servers.one] From 3b9716f30ebeab00d2e425522a31e89c64e670b2 Mon Sep 17 00:00:00 2001 From: orcas Date: Sun, 30 Jun 2019 05:05:44 +0800 Subject: [PATCH 6/6] Deprecated backend-bite, publish, signal and subscribe --- .gitmodules | 12 ------- README.md | 57 +++++++++++++++++-------------- backend-bite | 1 - backend-publish | 1 - backend-signal | 1 - backend-subscribe | 1 - docker-compose.yml | 58 ++----------------------------- traefik.toml | 85 ++++++++++------------------------------------ 8 files changed, 53 insertions(+), 163 deletions(-) delete mode 160000 backend-bite delete mode 160000 backend-publish delete mode 160000 backend-signal delete mode 160000 backend-subscribe diff --git a/.gitmodules b/.gitmodules index 4665e0d..84b2421 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,21 +1,9 @@ -[submodule "backend-bite"] - path = backend-bite - url = git@makerforce.io:beep/backend-bite.git [submodule "backend-core"] path = backend-core url = git@makerforce.io:beep/backend-core.git -[submodule "backend-publish"] - path = backend-publish - url = git@makerforce.io:beep/backend-publish.git -[submodule "backend-signal"] - path = backend-signal - url = git@makerforce.io:beep/backend-signal.git [submodule "backend-store"] path = backend-store url = git@makerforce.io:beep/backend-store.git -[submodule "backend-subscribe"] - path = backend-subscribe - url = git@makerforce.io:beep/backend-subscribe.git [submodule "backend-transcription"] path = backend-transcription url = git@makerforce.io:beep/backend-transcription.git diff --git a/README.md b/README.md index 8002a90..5608872 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ The microservices of Beep rely on a few background services, listed below. All o | `postgres` | [https://www.postgresql.org/] | | `redis` | [https://redis.io/] | | `nats` | [https://nats.io/] | +| `minio` | [https://min.io]| ## Services @@ -52,45 +53,51 @@ URL: `/core` `core` relies on a running `postgres` instance. Is insecure if not behind `traefik` calling `auth`. +### Heartbeat + +URL: `/heartbeat` + +`heartbeat` handles "last seen" timings for users. A user pings the server periodically via a specific endpoint, which then caches the time of the ping while also updating subscribed clients. Clients subscribe through an EventSource endpoint. On first subscribe, the last cached time of the user in question is pushed to the EventSource stream. + +`heartbeat` relies on a running `redis` instance. Is insecure if not behind `traefik` calling `auth`. + +### Pictures + +URL: `/pictures` + +`pictures` is a simple file upload server whose intended function is to just be a place to park user and group profile pictures. + +`pictures` relies on a running `minio` instance. Is insecure if not behind `traefik` calling `auth`. + +### Permissions + +`permissions` is an internal system meant to check a user's permission to access something. Currently uses a `user-scope` system, i.e. user-conversation. Since most things in the backend are related to conversations, the working basis of the permissions model is that if a user is in a conversation, they are pretty much good to go. Caches permissions in redis in a misguided attempt at reducing latency. + +`permissions` relies on a running `redis` instance. + ### Bite pipeline -Audio data in Beep is stored in discrete packets called "bites". The Bite pipeline takes in bites and processes them, doing things like storage and transcription to text. `publish` receives the bites, publishing them to `nats`, from which the processing services receive bite events. Output is then published again to `nats`, received by `subscribe` which pushes them as Server Sent Events. +Audio data in Beep is stored in discrete packets called "bites". The Bite pipeline takes in bites and processes them, doing things like storage and transcription to text. Currently, in an downright terrible implementation, bites are just discrete 1400 byte chunks separated with absolutely no regard whatsoever to their content. -#### `publish` +#### `webrtc` -URL: `/publish` +URL: `/webrtc` -`publish` accepts a POST request, containing a bite, and publishes it to NATs, to be received by services such as `bite` or `transcription`. +`webrtc` is a WebRTC Selective Forwarding Unit (SFU) router, keeping track of which conversation a user is in and routing based on that. At the same time, it also diverts the bites to the bite pipeline and issues a store request to `store` at the same time. -`publish` relies on a running `nats` instance. Is insecure if not behind `traefik` calling `auth`. - -#### `subscribe` - -URL: `/subscribe` - -`subscribe` sits on the other end of the bite pipeline, waiting for responses returned by services along it. Each request pushed to the pipeline stores the user/client ID of the requester, and the client can subscribe to `subscribe` to receive the response. - -`subscribe` relies on a running `nats` instance. Is insecure if not behind `traefik` calling `auth`. +`webrtc` relies on a running `nats` instance. Is insecure if not behind `traefik` calling `auth`. #### `store` -`store` is a wrapper around [badger](https://github.com/dgraph-io/badger). Receives data through `nats`, generating keys based on a label supplied with the data. Also supports retrieval of specific data based on key, and scanning a range of keys based on timestamp. +URL: `/bite` - -`bite` stores raw audio data via `store`. Basically just acts as a forwarder to `store`, adding labels to the data and accepting HTTP requests to retrieve the data. - -`bite` relies on a running `nats` instance. Is insecure if not behind `traefik` calling `auth`. +`store` relies on a running `nats` instance. Is insecure if not behind `traefik` calling `auth`. #### `transcription` -URL: `/transcription` - -`transcription` takes the raw audio data, packages it and then sends it to the [Google Cloud Speech-to-Text](https://cloud.google.com/speech-to-text/). Sends the transcripted result to `store` to be stored. Handles HTTP requests to retrieve transcriptions too. +`transcription` takes the raw audio data, packages it and then sends it to the [Google Cloud Speech-to-Text](https://cloud.google.com/speech-to-text/). Sends the transcripted result to `store` to be stored. `transcription` relies on a running `nats` instance. Is insecure if not behind `traefik` calling `auth`. diff --git a/backend-bite b/backend-bite deleted file mode 160000 index f847fe3..0000000 --- a/backend-bite +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f847fe3402a2d0e5c1de50464a285cf7c91f8476 diff --git a/backend-publish b/backend-publish deleted file mode 160000 index 42e1b65..0000000 --- a/backend-publish +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 42e1b651d46f8e7cc2b084a8d84e312751e8c267 diff --git a/backend-signal b/backend-signal deleted file mode 160000 index a5540df..0000000 --- a/backend-signal +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a5540dff2283b4bc7e847962403d61f37a177816 diff --git a/backend-subscribe b/backend-subscribe deleted file mode 160000 index 40da1b0..0000000 --- a/backend-subscribe +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 40da1b00bc771840446b887979bd0c69b483fc1f diff --git a/docker-compose.yml b/docker-compose.yml index ffaa976..f95f737 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,14 +5,11 @@ services: command: --configfile=/traefik.toml depends_on: - core - - signal - heartbeat - - bite - - publish - - subscribe - auth - pictures - webrtc + - store ports: - "80:80" - "443:443" @@ -77,15 +74,6 @@ services: - pgnet - traefiknet - signal: - build: ./backend-signal - tty: false - restart: unless-stopped - environment: - - PORT=80 - networks: - - traefiknet - heartbeat: build: ./backend-heartbeat tty: true @@ -99,19 +87,6 @@ services: - redisnet - traefiknet - webrtc: - build: ./backend-webrtc - tty: true - restart: unless-stopped - depends_on: - - nats - environment: - - LISTEN=:80 - - NATS=nats://nats:4222 - networks: - - traefiknet - - natsnet - login: build: ./backend-login tty: true @@ -186,8 +161,8 @@ services: - permissionsnet # Pipeline - bite: - build: ./backend-bite + webrtc: + build: ./backend-webrtc tty: true restart: unless-stopped depends_on: @@ -196,22 +171,8 @@ services: - LISTEN=:80 - NATS=nats://nats:4222 networks: - - natsnet - traefiknet - - publish: - build: ./backend-publish - tty: true - restart: unless-stopped - depends_on: - - nats - environment: - - LISTEN=:80 - - NATS=nats://nats:4222 - - SECRET=secret - networks: - natsnet - - traefiknet store: build: ./backend-store @@ -225,19 +186,6 @@ services: networks: - natsnet - subscribe: - build: ./backend-subscribe - tty: true - restart: unless-stopped - depends_on: - - nats - environment: - - LISTEN=:80 - - NATS=nats://nats:4222 - networks: - - natsnet - - traefiknet - transcription: build: ./backend-transcription tty: true diff --git a/traefik.toml b/traefik.toml index 32642c1..fcd105f 100644 --- a/traefik.toml +++ b/traefik.toml @@ -51,22 +51,6 @@ entrypoints = ["http", "https"] [frontends.core.routes.one] rule = "PathPrefixStrip: /core/" -# Signal -[backends.signal] - [backends.signal.servers.one] - url = "http://signal" - -[frontends.signal] -backend = "signal" -entrypoints = ["http", "https"] - [frontends.signal.headers.customresponseheaders] - Access-Control-Allow-Origin = "*" - Access-Control-Allow-Headers = "Content-Type, Authorization, X-User-Claim" - Access-Control-Allow-Credentials = "true" - Access-Control-Allow-Methods = "GET, HEAD, POST, PUT, PATCH, DELETE" - [frontends.signal.routes.one] - rule = "PathPrefixStrip: /signal/" - # Heartbeat [backends.heartbeat] [backends.heartbeat.servers.one] @@ -83,54 +67,6 @@ entrypoints = ["http", "https"] [frontends.heartbeat.routes.one] rule = "PathPrefixStrip: /heartbeat/" -# Bite -[backends.bite] - [backends.bite.servers.one] - url = "http://bite" - -[frontends.bite] -backend = "bite" -entrypoints = ["http", "https"] - [frontends.bite.headers.customresponseheaders] - Access-Control-Allow-Origin = "*" - Access-Control-Allow-Headers = "Content-Type, Authorization, X-User-Claim" - Access-Control-Allow-Credentials = "true" - Access-Control-Allow-Methods = "GET, HEAD, POST, PUT, PATCH, DELETE" - [frontends.bite.routes.one] - rule = "PathPrefixStrip: /bite/" - -# Publish -[backends.publish] - [backends.publish.servers.one] - url = "http://publish" - -[frontends.publish] -backend = "publish" -entrypoints = ["http", "https"] - [frontends.publish.headers.customresponseheaders] - Access-Control-Allow-Origin = "*" - Access-Control-Allow-Headers = "Content-Type, Authorization, X-User-Claim" - Access-Control-Allow-Credentials = "true" - Access-Control-Allow-Methods = "GET, HEAD, POST, PUT, PATCH, DELETE" - [frontends.publish.routes.one] - rule = "PathPrefixStrip: /publish/" - -# Subscribe -[backends.subscribe] - [backends.subscribe.servers.one] - url = "http://subscribe" - -[frontends.subscribe] -backend = "subscribe" -entrypoints = ["http", "https"] - [frontends.subscribe.headers.customresponseheaders] - Access-Control-Allow-Origin = "*" - Access-Control-Allow-Headers = "Content-Type, Authorization, X-User-Claim" - Access-Control-Allow-Credentials = "true" - Access-Control-Allow-Methods = "GET, HEAD, POST, PUT, PATCH, DELETE" - [frontends.subscribe.routes.one] - rule = "PathPrefixStrip: /subscribe/" - # pictures [backends.pictures] [backends.pictures.servers.one] @@ -151,6 +87,10 @@ entrypoints = ["http", "https"] [backends.webrtc] [backends.webrtc.servers.one] url = "http://webrtc" + +[frontends.webrtc] +backend = "webrtc" +entrypoints = ["http", "https"] [frontends.webrtc.headers.customresponseheaders] Access-Control-Allow-Origin = "*" Access-Control-Allow-Headers = "Content-Type, Authorization, X-User-Claim" @@ -159,10 +99,21 @@ entrypoints = ["http", "https"] [frontends.webrtc.routes.one] rule = "PathPrefixStrip: /webrtc/" -[frontends.webrtc] -backend = "webrtc" +# store +[backends.store] + [backends.store.servers.one] + url = "http://store" + +[frontends.store] +backend = "store" entrypoints = ["http", "https"] - + [frontends.store.headers.customresponseheaders] + Access-Control-Allow-Origin = "*" + Access-Control-Allow-Headers = "Content-Type, Authorization, X-User-Claim" + Access-Control-Allow-Credentials = "true" + Access-Control-Allow-Methods = "GET, HEAD, POST, PUT, PATCH, DELETE" + [frontends.store.routes.one] + rule = "PathPrefixStrip: /store/" # login [backends.login]