Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Ground Zero: Implement polyproto-chat #95

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,30 @@ on:
env:
CARGO_TERM_COLOR: always

# Auto-abort duplicate jobs (e.g. job being triggered again on push to open PR)
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
linux:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.13"
- name: Install pre-commit
run: |
python -m pip install --upgrade pip
pip install pre-commit
- name: Run pre-commit
run: pre-commit run --all-files

build-linux:
runs-on: ubuntu-latest
steps:
- uses: ikalnytskyi/action-setup-postgres@v6
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "crates/sonata"]
path = crates/sonata
url = https://github.com/polyphony-chat/sonata.git
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
repos:
- repo: https://github.com/sqlfluff/sqlfluff
rev: 27ef5db7053dfd00c93e1c5283e38780d7f6e0c5
hooks:
- id: sqlfluff-lint
args: [--dialect, "postgres", -e, "LT05"]
- id: sqlfluff-fix
args: [--dialect, "postgres", -e, "LT05"]
16 changes: 15 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
{
"rust-analyzer.cargo.features": "all"
"rust-analyzer.cargo.features": "all",
"sqltools.connections": [
{
"previewLimit": 50,
"server": "localhost",
"port": 5432,
"driver": "PostgreSQL",
"database": "symfonia",
"username": "symfonia",
"password": "symfonia",
"name": "localdb"
}
],
"sqlfluff.dialect": "postgres",
"sqlfluff.excludeRules": ["LT05"]
}
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ tokio-tungstenite = { version = "0.26.2", features = [
"rustls-tls-webpki-roots",
"url",
] }
sqlx = "0.8.5"
sqlx = "0.8.6"
sqlx-pg-uint = { version = "0.10.1", features = ["serde"] }
36 changes: 14 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,20 @@

## About

This is a WIP implementation of a Spacebar compatible Server in Rust!
This is a WIP implementation of a polyproto-chat compatible Server in Rust.

!!! info

This server is still in early development and thus not yet usable.



This repository contains:
A partial implementation of:

- [HTTP API Server](/src/api)
- [HTTP CDN Server](/src/cdn)
- [WebSocket Gateway Server](/src/gateway)
- [Database Models](/src/database)
- [HTTP API Server](/src/crates/symfonia-api)
- [WebSocket Gateway Server](/src/crates/symfonia-gateway)
- [Database Models](/src/crates/util/migrations)

## Local Development/Test Environment

Expand All @@ -35,6 +40,8 @@ Whether you are using Docker or not, you will need to have the following install
- [git](https://git-scm.com/downloads)
- [`sqlx-cli`](https://crates.io/crates/sqlx-cli)

You will also have to run `git submodule update` after cloning the repository.

If your development environment is hosted on a Windows machine, please additionally make sure that
you have a bash shell available to execute pre-commit hooks. This can be done by installing
[Git Bash](https://git-scm.com/downloads) or
Expand All @@ -57,12 +64,8 @@ DATABASE_PASSWORD=[Your Postgres password]
DATABASE_NAME=[Your Postgres database name]
API_BIND=[ip:port to bind the HTTP API server to. Defaults to 0.0.0.0:3001 if not set]
GATEWAY_BIND=[ip:port to bind the Gateway server to. Defaults to 0.0.0.0:3003 if not set]
# For rauthy:
COOKIE_MODE=danger-insecure
```

4. Install and host an instance of [rauthy](https://github.com/sebadob/rauthy). Documentation on how
to do this can be found [here](https://sebadob.github.io/rauthy/intro.html).
5. Install the sqlx CLI with `cargo install sqlx-cli`
6. Run `cargo sqlx migrate run` from within the project directory to run the migrations
7. Run the project with `cargo run`.
Expand All @@ -71,19 +74,8 @@ COOKIE_MODE=danger-insecure

1. Copy the `compose-example.env` file to `.env` in the root of the compose project and fill in the values
to your liking.
2. Create a `rauthy.cfg` in the root of the compose project and fill in the
values according to [the rauthy documentation. A reference config is included on that page](https://sebadob.github.io/rauthy/config/config.html#reference-config).

!!! tip

rauthy also supports PostgreSQL as a database backend, but comes with [Hiqlite](https://github.com/sebadob/hiqlite)
as a default database backend.fe

3. Adjust ports in `docker-compose.yml` if needed.
4. Run `docker compose up --build`.

If you haven't edited the corresponding `rauthy.cfg` settings, the default user for rauthy is `admin@localhost.de`.
The password will be generated at first launch and you can discover it using `docker compose logs`.
2. Adjust ports in `docker-compose.yml` if needed.
3. Run `docker compose up --build`.

Code changes will require you to restart the container with `docker compose up --build`. If you want
to reset to a fully clean state, run `docker compose down -v`.
Expand Down
1 change: 1 addition & 0 deletions crates/sonata
Submodule sonata added at 042533
14 changes: 7 additions & 7 deletions crates/symfonia-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2024"
[dependencies]
base64 = "0.22.1"
bigdecimal = "0.4.8"
bitflags = { version = "2.9.0", features = ["serde"] }
bitflags = { version = "2.9.1", features = ["serde"] }
chrono = { version = "0.4.41", features = ["serde"] }
futures = "0.3.31"
hostname = "0.4.1"
Expand All @@ -23,11 +23,11 @@ log4rs = { version = "1.3.0", features = [
] }
num-bigint = "0.4.6"
num-traits = "0.2.19"
openssl = "0.10.72"
poem = "3.1.9"
openssl = "0.10.73"
poem = "3.1.11"
rand = "0.8.5"
regex = "1.11.1"
reqwest = { version = "0.12.15", default-features = false, features = [
reqwest = { version = "0.12.20", default-features = false, features = [
"http2",
"macos-system-configuration",
"charset",
Expand All @@ -43,7 +43,7 @@ sqlx = { workspace = true, features = [
"any",
] }
thiserror = "1.0.69"
tokio = { version = "1.44.2", features = ["full"] }
tokio = { version = "1.45.1", features = ["full"] }
sentry = { version = "0.34.0", default-features = false, features = [
"backtrace",
"contexts",
Expand All @@ -63,9 +63,9 @@ tokio-tungstenite = { version = "0.23.1", features = [
"tokio-rustls",
] }
pubserve = { version = "1.1.0", features = ["async", "send"] }
parking_lot = { version = "0.12.3", features = ["deadlock_detection"] }
parking_lot = { version = "0.12.4", features = ["deadlock_detection"] }
sqlx-pg-uint = { workspace = true }
toml = "0.8.22"
toml = "0.8.23"
argon2 = "0.5.3"

[profile.release]
Expand Down
14 changes: 7 additions & 7 deletions crates/symfonia-gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2024"
[dependencies]
base64 = "0.22.1"
bigdecimal = "0.4.8"
bitflags = { version = "2.9.0", features = ["serde"] }
bitflags = { version = "2.9.1", features = ["serde"] }
chrono = { version = "0.4.41", features = ["serde"] }
futures = "0.3.31"
jsonwebtoken = "9.3.1"
Expand All @@ -22,11 +22,11 @@ log4rs = { version = "1.3.0", features = [
] }
num-bigint = "0.4.6"
num-traits = "0.2.19"
openssl = "0.10.72"
poem = "3.1.9"
openssl = "0.10.73"
poem = "3.1.11"
rand = "0.8.5"
regex = "1.11.1"
reqwest = { version = "0.12.15", default-features = false, features = [
reqwest = { version = "0.12.20", default-features = false, features = [
"http2",
"macos-system-configuration",
"charset",
Expand All @@ -42,16 +42,16 @@ sqlx = { workspace = true, features = [
"any",
] }
thiserror = "1.0.69"
tokio = { version = "1.44.2", features = ["full"] }
tokio = { version = "1.45.1", features = ["full"] }
chorus = { workspace = true }
util = { path = "../util", version = "0" }
serde_path_to_error = "0.1.17"
percent-encoding = "2.3.1"
hex = "0.4.3"
tokio-tungstenite = { workspace = true }
pubserve = { version = "1.1.0", features = ["async", "send"] }
parking_lot = { version = "0.12.3", features = ["deadlock_detection"] }
toml = "0.8.22"
parking_lot = { version = "0.12.4", features = ["deadlock_detection"] }
toml = "0.8.23"
argon2 = "0.5.3"

[profile.release]
Expand Down
6 changes: 3 additions & 3 deletions crates/symfonia/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ edition = "2024"
license = "MPL-2.0"

[dependencies]
clap = { version = "4.5.37", features = ["derive"] }
clap = { version = "4.5.40", features = ["derive"] }
lazy_static = "1.5.0"
log = "0.4.27"
log4rs = "1.3.0"
serde = { version = "1.0.219", features = ["derive"] }
tokio = { version = "1.44.2", features = ["macros", "rt-multi-thread"] }
toml = "0.8.22"
tokio = { version = "1.45.1", features = ["macros", "rt-multi-thread"] }
toml = "0.8.23"
util = { version = "0.1.0", path = "../util" }
sqlx = { workspace = true }
symfonia-api = { version = "0.1.0", path = "../symfonia-api" }
Expand Down
12 changes: 6 additions & 6 deletions crates/util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ jsonwebtoken = "9.3.1"
log = "0.4.27"
log4rs = "1.3.0"
num-traits = "0.2.19"
parking_lot = "0.12.3"
poem = { version = "3.1.9", optional = true }
parking_lot = "0.12.4"
poem = { version = "3.1.11", optional = true }
pubserve = "1.1.0"
rand = "0.8.5"
reqwest = "0.12.15"
reqwest = "0.12.20"
secrecy = "0.10.3"
serde = "1.0.219"
serde_json = "1.0.140"
serde_path_to_error = "0.1.17"
serde_with = "3.12.0"
serde_with = "3.13.0"
sqlx = { workspace = true }
sqlx-pg-uint = { workspace = true }
thiserror = "2.0.12"
tokio = { version = "1.44.2", features = ["net", "rt-multi-thread", "sync"] }
tokio = { version = "1.45.1", features = ["net", "rt-multi-thread", "sync"] }
tokio-tungstenite = { workspace = true }
toml = "0.8.22"
toml = "0.8.23"
zeroize = { version = "1.8.1", features = ["derive"] }

[dev-dependencies]
Expand Down
Loading
Loading