Merge pull request #8 from FifthWit/master

Updated backend and removed package-lock.json since its a pnpm project
This commit is contained in:
Pas 2025-12-26 23:54:14 -07:00 committed by GitHub
commit 9036ceae68
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 93 additions and 13836 deletions

13806
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -8,14 +8,71 @@ The only officially recognized hosting method is through Docker (or similar cont
For configuration, check out the [configuration reference](./configuration.mdx).
## Method 1 - Docker Deployment
## Method 1 - Cloudflare Deployment (Free + Easy)
**Prerequisites**
- A [Cloudflare](https://cloudflare.com) account
- A [GitHub](https://github.com) account
<Steps>
<Steps.Step>
Create a Cloudflare Worker for the backend In the [Cloudflare
Dashboard](https://dash.cloudflare.com/) go to the sidebar, then click
"Compute & AI" > "Workers and Pages"
</Steps.Step>
<Steps.Step>
Select "Create application" then click "Continue with GitHub"
</Steps.Step>
<Steps.Step>
If needed, link your GitHub account to your Cloudflare account.
</Steps.Step>
<Steps.Step>
Go to the backend [repository](https://github.com/p-stream/backend) click
Star, to Star it :P then Fork the project by clicking Fork, then Create
Fork.
</Steps.Step>
<Steps.Step>
In the Cloudflare dashboard select the GitHub repository you set for the
backend, it should set the build command as `npm run build` and deploy
command as `node .output/server/index.mjs`
</Steps.Step>
<Steps.Step>
Backend uses PostgreSQL as our database, so you need somewhere to host. I
personally recommend [Neon](https://neon.com/) as they have a perfectly fine
free tier. For larger deployments, it can be quite expensive, so have a
backup strategy if you get a lot of users.
</Steps.Step>
<Steps.Step>
In the Neon dashboard click create project, give it a name, then click
Connect to your Database. It should give you a line like this: ``` psql
'postgresql://neondb_owner:RANDOMSTUFFHERE@MORERANDOMSTUFF.c-2.us-east-1.aws.neon.tech/neondb?sslmode=require&channel_binding=require'
``` Copy the url including the `postgresql://` for the next step.
</Steps.Step>
<Steps.Step>
Set your Environment Variables. In the Cloudflare dashboard, go to your
worker, go to settings, then click "Configure API token and other runtime
variables" Now set your variables:
- CRYPTO_SECRET: Generate a random 32
character string and set that as the value
- DATABASE_URL: The long
postgres:// string from earlier.
- META_NAME: Whatever you want the name to be, users will see it when they sign up
- META_DESCRIPTION: The description for your instance
</Steps.Step>
<Steps.Step>Now you should be done! Have fun with your new backend, and if you would like, [Star Backend on GitHub](https://github.com/p-stream/backend)</Steps.Step>
</Steps>
## Method 2 - Docker Deployment
This method provides a straightforward setup with minimal configuration. For more extensive customization, see the [Configuration Reference](./configuration.mdx).
**Prerequisites**
- **Docker:** If you don't have Docker installed, download it from the official website: [Docker installation](https://www.docker.com/get-started)
**Setup**
**Setup**
<Steps>
<Steps.Step>
@ -67,7 +124,7 @@ This method provides a straightforward setup with minimal configuration. For mor
Your backend should be accessible on `(YourPrivateIP):80`. To share it outside your local network, you'll need to configure port forwarding or cloudflared tunnel.
## Method 2 - Railway (Easy)
## Method 3 - Railway (Easy)
Railway offers a 30-day free trial that includes a one-time $5 credit. After the trial, you receive $1 in usage credits for free each month.
@ -82,29 +139,29 @@ Railway offers a 30-day free trial that includes a one-time $5 credit. After the
to the closest one possible.
</Steps.Step>
<Steps.Step>
Click the [`Deploy on Railway`](https://railway.com/deploy/pstreambackend?referralCode=zvXFZF) button
above.
</Steps.Step>
<Steps.Step>
Click the [`Deploy on
Railway`](https://railway.com/deploy/pstreambackend?referralCode=zvXFZF)
button above.
</Steps.Step>
<Steps.Step>
Click on configure For the one that says Backend.
</Steps.Step>
<Steps.Step>Click on configure For the one that says Backend.</Steps.Step>
<Steps.Step>
Fill in the required variable META_NAME the rest are optional and can be set later on.
</Steps.Step>
<Steps.Step>
Fill in the required variable META_NAME the rest are optional and can be set
later on.
</Steps.Step>
<Steps.Step>
The `Deploy` button at the bottom of the template should be active, click on
it.
</Steps.Step>
<Steps.Step>
The `Deploy` button at the bottom of the template should be active, click on
it.
</Steps.Step>
<Steps.Step>
Once the `Backend` service has deployed, copy the URL from the `Deployments`
page. (Might take a second for it to be available after the service has
deployed)
</Steps.Step>
<Steps.Step>
Once the `Backend` service has deployed, copy the URL from the `Deployments`
page. (Might take a second for it to be available after the service has
deployed)
</Steps.Step>
<Steps.Step>
Congratulations! You have deployed the backend, you can now [set up the

View file

@ -4,25 +4,31 @@ title: 'Introduction'
# Introduction to the backend
The backend is essentially just an account server. It handles user accounts, syncing, and other account related features.
Backend is a service you can run and use that syncs user data, for example what movie you watched, your settings, and your color theme. Along with other data like collecting metrics on things like a source's success rate.
## Recommended Community Backend
## Should you selfhost?
I recommend using the [official-backend](https://server.fifthwit.net/)!
There are pros and cons to selfhosting. If you're not a technical user, selfhosting the backend may be quite the chore, and involve more hassle than it's worth. On the flipside if you are technical, it can be a quite rewarding experience.
If you host your own instance of P-Stream, it's best paired with your own backend, the latency could be better than using the community backend, you have more accurate metrics that measure what your instance's users are experience, and you control your own data!
Another reason to selfhost is reliability. The community backend gets a lot of users, with that it can have higher latency, and is the target of DDoS attacks, which can lead to it being practically unusable on the occasion it is DDoS'd.
## Metrics
The backend exposes an endpoint for [Prometheus metrics](https://prometheus.io/) which allows you to keep track of the backend more easily, it can be accessed on `/metrics`.
Ex: https://server.fifthwit.net/metrics
To view these metrics properly, you can use the [P-Stream Metrics Dash](https://dash.pstream.mov/).
To view these metrics properly, you can use the [P-Stream Metrics Dash](https://dash.pstream.mov/). Or use a more powerful tool like [Prometheus](https://prometheus.io/) and [Grafana](https://grafana.com/) to better visualize data.
<Warning>
This dash is not functioning properly right now. It does work but certain information
can be wrong or outdated. This will be fixed soon
Prometheus + Grafana typically require a VPS, which usually aren't free, so we
don't recommend you use Prometheus + Grafana unless you already have a VPS, or
solution to host them.
</Warning>
## Security
Optionally, is a security setting:
Currently we are working on integration with Cloudflare Turnstile to limit bot traffic.
- [Recaptcha support](./configuration.mdx#captcha), the server can verify Recaptcha v3 tokens on register and login.
If you have a domain with Cloudflare you can also use WAF to help secure your backend in the event it's being targeted.