The BP Timer is a web panel for Blue Protocol: Star Resonance, designed to quickly view mob uptimes and track them in real-time. It is complemented by data from winj's DPS Meter, which provides in-game data. The project is built with SvelteKit and PocketBase, and deployed to Cloudflare.
Bun, Docker, and Docker Compose. Make sure Docker is running before getting started.
Clone this repository then run the following commands:
git clone https://github.com/woheedev/bptimer.git bp-timer
cd bp-timerFork this repo instead if you plan on submitting changes!
-
Install dependencies:
bun install
-
Set up environment variables:
cp ./apps/web/.env.example ./apps/web/.env
Fill in the required values in
./apps/web/.env:PB_ADMIN_EMAILandPB_ADMIN_PASSWORDfor the initial Pocketbase admin accountPUBLIC_POCKETBASE_BASE_URL=http://localhost:8090PB_OAUTH2_DISCORD_CLIENT_IDandPB_OAUTH2_DISCORD_CLIENT_SECRETfor the Discord OAuth login which are obtained by creating an application in the Discord Developer Portal under the OAuth2 section- Optionally, there are extra optional settings that can be applied automatically. Otherwise you can set them via pocketbase admin panel.
-
Set Discord redirect URL:
- Go to Discord Developer Portal > OAuth2
- Add
http://localhost:8090/api/oauth2-redirectto redirect URL
-
Start the development server and backend
bun run dev
-
Create an account by logging in via Discord on the local web app, and start building
This project includes GitHub Actions workflows for automated testing and deployment:
When you create a pull request, the CI workflow will:
- Install dependencies with
bun install --frozen-lockfile(with caching) - Format code with
bun run format - Lint code with
bun run lint - Run type checking with
bun run check - Run tests with
bun run test - Build the project with
bun run build
When code is pushed to the main branch, the deploy workflow will:
- Run all the same checks as the PR workflow
- Deploy the web app to Cloudflare using
wrangler deploy
To use the deployment workflow, you'll need to add the following to your GitHub repository settings:
-
Cloudflare API Token (Secret):
- Go to Secrets and variables > Actions > Secrets
- Add
CLOUDFLARE_API_TOKENwith your token from Cloudflare dashboard
-
PocketBase URL (Variable):
- Go to Secrets and variables > Actions > Variables
- Add
PUBLIC_POCKETBASE_BASE_URLwith your production URL (e.g.,https://db.bptimer.com)
Things to consider for production deployments:
- Add SMTP server settings for sending verification and reset password emails
- Remember to edit the email templates from the PocketBase admin settings after deploying
- Integrate OAuth2 providers
- For Discord OAuth, update the redirect URI in your Discord app settings to point to your production domain (e.g.,
https://db.bptimer.com/api/oauth2-redirect)
- For Discord OAuth, update the redirect URI in your Discord app settings to point to your production domain (e.g.,
It is straightforward to host PocketBase on any VPS. This template comes configured for easy deployment of PocketBase on Fly.io.
-
Install flyctl – the open-source Fly.io CLI
-
Create an account with
fly auth signupor log in withfly auth login -
Create a new app
fly apps create --generate-name
-
Add the generated app name to
apps/pocketbase/fly.toml(line 1) -
Choose the region closest to you (or your users) and add the corresponding region ID as the
primary_regioninapps/pocketbase/fly.toml(line 2) -
Create a new volume, using the same region as the one you chose in step 5 (size can easily be extended anytime)
fly volumes create pb_data --size=1 # Creates a volume with 1GB of storage -
Deploy the Pocketbase server, and run this command again anytime you want to update the deployment after making changes locally
bun run deploy
-
Go to the production PocketBase admin settings page at
https://APP_NAME.fly.dev/_to create an admin account for the production backend -
Create
./apps/web/.env.productionwith your production PocketBase URL:
PUBLIC_POCKETBASE_BASE_URL=https://db.bptimer.com
The pre-configured VM is the cheapest available on Fly.io (shared-cpu-1x with 256MB of memory), scale the backend vertically as your app grows.
Alternative: Add cloudflared tunnel to docker-compose and deploy. Point tunnel to http://pocketbase:8090
Many cloud platforms provide generous free tiers for deploying web apps built with popular frameworks like SvelteKit. Cloudflare, Vercel, and Netlify are just a few examples of platforms that integrate directly with GitHub repositories and provide seamless CI/CD.
When setting up your first deployment on any of these platforms, remember to:
- Replace
@sveltejs/adapter-autowith the appropriate adapter inapps/web/svelte.config.js - Specify
apps/webas the root of the web app - Add environment variables from
./apps/web/.envto the deployment
apps/pocketbase: Dockerized PocketBase backendapps/web: SvelteKit apppackages/eslint-config-custom:eslintconfigurations
This template has some additional tools already setup for you:
- TypeScript for static type checking
- ESLint for code linting
- Prettier for code formatting
Project structure initially based on this template and has been upgraded to the latest Svelte & PocketBase code.