Skip to content

blackmesadev/dashboard

Repository files navigation

dashboard

the web dashboard for black mesa at https://blackmesa.dhopcs.org/dashboard. built with Preact and Vite as a single-page application (SPA) with client-side routing.

run locally

install dependencies:

pnpm i

start the dev server:

pnpm run dev

this runs Vite at http://localhost:4173 with hot reload.

build for production

pnpm run build

outputs static files to dist/. served with nginx in production + docs - see nginx.conf for config details.

env vars (.env)

Variable Required Default Description
VITE_API_BASE_URL Yes N/A Complete API base URL without trailing slash. For subdomain deployment: https://api.blackmesa.bot. For path-based: https://blackmesa.dhopcs.org/api.
VITE_DISCORD_CLIENT_ID Yes N/A Discord OAuth2 client ID for login link.
VITE_BASE_PATH No / Base path for deployment (e.g. /dashboard/).

architecture

the dashboard is a single-page application (SPA) built with Preact and preact-router. it communicates with the bm-api service for all data operations (guild config, infractions, logging settings) via REST API calls. the API service in turn uses bm-lib for database access, caching, and Discord API interactions, the same as the bot service. this allows us to reuse all the core logic and data models in bm-lib without duplicating code or creating separate admin APIs in the bot.

routing

the dashboard uses client-side routing with preact-router as a true SPA:

  • / → redirects to selected guild or /guilds
  • /login → login page
  • /guilds → guild selector
  • /oauth/discord → OAuth callback
  • /:guildId → guild overview
  • /:guildId/config/:tab? → config editor (general, permissions, modules, etc.)
  • /:guildId/infractions → infractions list
  • /:guildId/logging → logging config
  • /:guildId/automod → automod editor

guild IDs are Discord snowflakes (17-20 digits). routes work both with and without guild ID prefixes for backward compatibility.

production

in prod, the dashboard is built and served as static files by nginx, the config and Dockerfile here is used in prod.

you can bring up the container yourself by doing

docker build -t black-mesa-dashboard . && \
docker run -d --name black-mesa-dashboard -p 8080:80 black-mesa-dashboard

About

black mesa dashboard

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages