backend for xcvr appview
1# rvcx 2this is the backend for the xcvr appview. it uses lrcd to host the lrc servers, 3postgres to cache the atproto data, atproto-oauth-golang as an oauth client, 4and probably some other things i am forgetting! 5 6## principles 7the xcvr atproto ecosystem has backend appviews which are simultaneously 8atproto actors who write signet records to their repos in order to have 9bidirectional confidence that off-protocol communication occured 10 11## how to run 12i don't really test this in development since i added oauth, this likely will 13change in the future 14 15in production, you must create a .env file that contains the following 16environment variables, setting secrets as appropriate 17 18``` 19POSTGRES_USER=xcvr 20POSTGRES_PASSWORD=secret 21POSTGRES_DB=xcvrdb 22POSTGRES_PORT=15432 23MY_NAME=xcvr 24MY_IDENTITY=xcvr.org 25MY_SECRET=secret 26MY_METADATA_PATH=/meta/client-metadata.json 27MY_TOS_PATH=/meta/tos 28MY_POLICY_PATH=/meta/policy 29MY_LOGO_PATH=/public/xcvr.svg 30MY_OAUTH_CALLBACK=/oauth/callback 31MY_JWKS_PATH=/oauth/jwks.json 32SESSION_KEY=secret 33LRCD_SECRET=secret 34``` 35 36the first four of course have to do with your postgres instance, i think the 37postgres port is just 15432 because i was having conflicts on mac, i don't 38think what you set it to is very important. they are also used in the migration 39scripts. migratedown and migrateup require you to install golang migrate, and 40psql requires you to install psql. MY_NAME, MY_IDENTITY, MY_METADATA_PATH, 41MY_TOS_PATH, MY_POLICY_PATH, MY_LOGO_PATH, MY_OAUTH_CALLBACK and MY_JWKS_PATH 42are used for oauth, MY_IDENTITY is the hostname, but also the atproto handle of 43the backend's repo. the MY_SECRET is variable is thus the backend's app 44password. in order to be an oauth client, you need a jwks that you serve at 45MY_JWKS_PATH, but of course you need to generate this using haileyok's 46atproto-oauth-golang, and then save jwks.json in the top level rvcx directory 47as jwks.json. SESSION_KEY and LRCD_SECRET are two more keys that you need to 48generate in addition to POSTGRES_PASSWORD. SESSION_KEY encrypts the oauth 49session data, and LRCD_SECRET is used to generate nonces that prevent anyone 50from submitting other people's unauthenticated messages. 51 52once you have your .env file, you then need to run `sudo docker-compose up -d` 53and then `sudo ./migrateup` if it is your first time running the server. if you 54need to reset the database, you can do `sudo docker-compose down --volumes`, of 55course, be careful with this, rvcx does not currently have a way to backfill 56the database!!! these commands are run in the main rcvx directory. 57 58then, you need to `cd server`, and then you can `go run ./cmd` to start the 59backend. 60 61i also have included my nginx configuration. after installing nginx, you need 62to put that in the conf.d folder, if you're on ubuntu. i think that nginx 63differs a bit depending on your distro, you can probably figure it out, i might 64be able to help troubleshoot but it'd probably the blind leading the blind 65there haha 66 67of course, this is just the backend, so alongside nginx, you should build the 68frontend and copy the files to the appropriate location. the frontend uses 69sveltekit and i just have it generate a static site bc i don't really care atp, 70setup is already contrived enough 71 72as with xcvr (frontend) i think this is under mit but i don't know enough 73apropos licensing at this moment in history to fully commit in that direction. 74 75as for contributions, same thing i said in that other readme, i'd love help & 76you should let me know in advance so we don't make each other's lives hell :3 77 78beep_