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-timer
Fork 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_EMAIL and PB_ADMIN_PASSWORD for the initial Pocketbase admin accountPB_ADMIN_PASSWORD must be at least 8 characters long.PUBLIC_POCKETBASE_BASE_URL=http://localhost:8090PB_OAUTH2_DISCORD_CLIENT_ID and PB_OAUTH2_DISCORD_CLIENT_SECRET for the Discord OAuth login which are obtained by creating an application in the Discord Developer Portal under the OAuth2 sectionSet Discord redirect URL:
http://localhost:8090/api/oauth2-redirect to redirect URLStart 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:
bun install --frozen-lockfile (with caching)bun run formatbun run lintbun run checkbun run testbun run buildWhen code is pushed to the main branch, the deploy workflow will:
wrangler deployTo use the deployment workflow, you'll need to add the following to your GitHub repository settings:
Cloudflare API Token (Secret):
CLOUDFLARE_API_TOKEN with your token from Cloudflare dashboardPocketBase URL (Variable):
PUBLIC_POCKETBASE_BASE_URL with your production URL (e.g., https://db.bptimer.com)Things to consider for production deployments:
https://db.bptimer.com/api/oauth2-redirect)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 signup or log in with fly 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_region in apps/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.production with 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:
@sveltejs/adapter-auto with the appropriate adapter in apps/web/svelte.config.jsapps/web as the root of the web app./apps/web/.env to the deploymentapps/pocketbase: Dockerized PocketBase backendapps/web: SvelteKit apppackages/eslint-config-custom: eslint configurationsThis template has some additional tools already setup for you:
Project structure initially based on this template and has been upgraded to the latest Svelte & PocketBase code.