···1-# xcvr-backend
2-a backend service that allows the dynamic creation of lrc servers. see it live at [xcvr.chat](http://xcvr.chat/)
0034-this is just the backend, for a frontend, consider using [xcvr](https://github.com/rachel-mp4/xcvr/)
00056## how to run
7-```{bash}
8-$ cd server
9-$ go run ./cmd
000000000000000000010```
1112-## how to deploy
13-1. install nginx
14-2. copy xcvr.conf to /etc/nginx/conf.d/ (change the server_name directive to your domain name)
15-3. copy static files to /var/www/xcvr/ (if using xcvr for your frontend, then copy the contents of the dist directory generated by `npm run build` to the /var/www/xcvr/)
16-4. start nginx
17-5. run xcvr-backend
0000000001819-## endpoints
20-GET http://localhost:8080/xrpc/getChannels - gets a list of all active channels
0002122-POST http://localhost:8080/xrpc/initChannel - accepts json containing metadata about a channel and creates it
0000000000002324-## servers
25-servers are served on ephemeral ports at ws://localhost:PORT/ws
2627-in production, their ports are exposed as ws://xcvr.chat/PORT/ws, which gets proxied to ws://127.0.0.1:PORT/ws0
···1+# rvcx
2+this is the backend for the xcvr appview. it uses lrcd to host the lrc servers,
3+postgres to cache the atproto data, atproto-oauth-golang as an oauth client,
4+and probably some other things i am forgetting!
56+## principles
7+the xcvr atproto ecosystem has backend appviews which are simultaneously
8+atproto actors who write signet records to their repos in order to have
9+bidirectional confidence that off-protocol communication occured
1011## how to run
12+i don't really test this in development since i added oauth, this likely will
13+change in the future
14+15+in production, you must create a .env file that contains the following
16+environment variables, setting secrets as appropriate
17+18+```
19+POSTGRES_USER=xcvr
20+POSTGRES_PASSWORD=secret
21+POSTGRES_DB=xcvrdb
22+POSTGRES_PORT=15432
23+MY_NAME=xcvr
24+MY_IDENTITY=xcvr.org
25+MY_SECRET=secret
26+MY_METADATA_PATH=/meta/client-metadata.json
27+MY_TOS_PATH=/meta/tos
28+MY_POLICY_PATH=/meta/policy
29+MY_LOGO_PATH=/public/xcvr.svg
30+MY_OAUTH_CALLBACK=/oauth/callback
31+MY_JWKS_PATH=/oauth/jwks.json
32+SESSION_KEY=secret
33+LRCD_SECRET=secret
34```
3536+the first four of course have to do with your postgres instance, i think the
37+postgres port is just 15432 because i was having conflicts on mac, i don't
38+think what you set it to is very important. they are also used in the migration
39+scripts. migratedown and migrateup require you to install golang migrate, and
40+psql requires you to install psql. MY_NAME, MY_IDENTITY, MY_METADATA_PATH,
41+MY_TOS_PATH, MY_POLICY_PATH, MY_LOGO_PATH, MY_OAUTH_CALLBACK and MY_JWKS_PATH
42+are used for oauth, MY_IDENTITY is the hostname, but also the atproto handle of
43+the backend's repo. the MY_SECRET is variable is thus the backend's app
44+password. in order to be an oauth client, you need a jwks that you serve at
45+MY_JWKS_PATH, but of course you need to generate this using haileyok's
46+atproto-oauth-golang, and then save jwks.json in the top level rvcx directory
47+as jwks.json. SESSION_KEY and LRCD_SECRET are two more keys that you need to
48+generate in addition to POSTGRES_PASSWORD. SESSION_KEY encrypts the oauth
49+session data, and LRCD_SECRET is used to generate nonces that prevent anyone
50+from submitting other people's unauthenticated messages.
5152+once you have your .env file, you then need to run `sudo docker-compose up -d`
53+and then `sudo ./migrateup` if it is your first time running the server. if you
54+need to reset the database, you can do `sudo docker-compose down --volumes`, of
55+course, be careful with this, rvcx does not currently have a way to backfill
56+the database!!! these commands are run in the main rcvx directory.
5758+then, you need to `cd server`, and then you can `go run ./cmd` to start the
59+backend.
60+61+i also have included my nginx configuration. after installing nginx, you need
62+to put that in the conf.d folder, if you're on ubuntu. i think that nginx
63+differs a bit depending on your distro, you can probably figure it out, i might
64+be able to help troubleshoot but it'd probably the blind leading the blind
65+there haha
66+67+of course, this is just the backend, so alongside nginx, you should build the
68+frontend and copy the files to the appropriate location. the frontend uses
69+sveltekit and i just have it generate a static site bc i don't really care atp,
70+setup is already contrived enough
7172+as with xcvr (frontend) i think this is under mit but i don't know enough
73+apropos licensing at this moment in history to fully commit in that direction.
7475+as for contributions, same thing i said in that other readme, i'd love help &
76+you should let me know in advance so we don't make each other's lives hell :3
+8-8
server/cmd/main.go
···5 "errors"
6 "net/http"
7 "os"
00000008 "time"
9- "xcvr-backend/internal/atplistener"
10- "xcvr-backend/internal/atputils"
11- "xcvr-backend/internal/db"
12- "xcvr-backend/internal/handler"
13- "xcvr-backend/internal/log"
14- "xcvr-backend/internal/model"
15- "xcvr-backend/internal/oauth"
1617 "github.com/joho/godotenv"
18)
···2223 gdeerr := godotenv.Load("../.env")
24 if gdeerr != nil {
25- logger.Println("i think you should make a .env file in the xcvr-backend directory !\n\nExample contents:\n-------------------------------------------------------------------\nPOSTGRES_USER=xcvr\nPOSTGRES_PASSWORD=secret\nPOSTGRES_DB=xcvrdb\nPOSTGRES_PORT=15432\n-------------------------------------------------------------------\n\nGood luck !\n\n")
26 panic(gdeerr)
27 }
28 store, err := db.Init()
···5 "errors"
6 "net/http"
7 "os"
8+ "rvcx/internal/atplistener"
9+ "rvcx/internal/atputils"
10+ "rvcx/internal/db"
11+ "rvcx/internal/handler"
12+ "rvcx/internal/log"
13+ "rvcx/internal/model"
14+ "rvcx/internal/oauth"
15 "time"
00000001617 "github.com/joho/godotenv"
18)
···2223 gdeerr := godotenv.Load("../.env")
24 if gdeerr != nil {
25+ logger.Println("i think you should make a .env file in the rvcx directory !\n\nExample contents:\n-------------------------------------------------------------------\nPOSTGRES_USER=xcvr\nPOSTGRES_PASSWORD=secret\nPOSTGRES_DB=xcvrdb\nPOSTGRES_PORT=15432\n-------------------------------------------------------------------\n\nGood luck !\n\n")
26 panic(gdeerr)
27 }
28 store, err := db.Init()