The BurnGuard proxy binary runs entirely on your local machine and works without any cloud component — but the backend API and Next.js dashboard that power the usage charts and team features can also be self-hosted. You might choose this path for data privacy requirements, compliance restrictions on sending usage data to third-party services, or to run BurnGuard on a custom domain inside your organization’s infrastructure.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Verifieddanny/BurnGuard/llms.txt
Use this file to discover all available pages before exploring further.
Architecture
A fully self-hosted BurnGuard deployment consists of three independent programs:| Component | Technology | Purpose |
|---|---|---|
| Proxy | Go binary + SQLite | Runs locally, intercepts AI API calls, enforces budgets |
| Backend API | Go + PostgreSQL | Receives synced usage data, serves the dashboard API |
| Dashboard | Next.js | Web UI for analytics, budget configuration, and team access |
Prerequisites
Before you start, make sure the following tools are installed:- Go 1.23+ — required to build and run the backend API
- Node.js 20+ — required for the Next.js dashboard
- Docker and Docker Compose — used to run PostgreSQL locally
golang-migrateCLI — used to apply database migrations
Start PostgreSQL
The repository includes adocker-compose.yml that starts a PostgreSQL 16 instance with the credentials the backend expects by default.
bunguard-db listening on localhost:5432 with the database bunguard, the user bunguardadmin, and the password bunguardadminpassword. Data is persisted in the named volume db_data.
Run Database Migrations
With PostgreSQL running, apply all schema migrations:internal/migrations/ in sequence using golang-migrate. The Makefile reads the DATABASE_URL from your .envrc file (see the next section), so make sure that file exists before running this command.
To roll back all migrations:
Configure Environment Variables for the Backend
Create a.envrc file in the repository root with the following variables. If you use direnv, run direnv allow after saving the file; otherwise export the variables manually or source the file directly.
| Variable | Description |
|---|---|
DATABASE_URL | PostgreSQL connection string. Must match the credentials in docker-compose.yml. |
PORT | Port the backend API listens on. Defaults to 3001 if unset. |
GITHUB_CLIENT_ID | OAuth App client ID from github.com/settings/developers. Required for GitHub sign-in. |
GITHUB_CLIENT_SECRET | Corresponding secret for the GitHub OAuth App. |
GOOGLE_CLIENT_ID | OAuth 2.0 client ID from the Google Cloud Console. Required for Google sign-in. |
GOOGLE_CLIENT_SECRET | Corresponding secret for the Google OAuth client. |
FRONTEND_URL | Origin of the Next.js dashboard. Used for CORS and OAuth redirect validation. |
WEBAUTHN_RP_ID | The Relying Party ID for WebAuthn passkeys. Must be the hostname of the page where passkeys are registered — localhost for local development. |
Start the Backend API
http://localhost:3001. You can verify it is running by opening that URL in a browser — a 404 or JSON response from the API confirms it is alive.
Configure the Frontend
Create a.env.local file inside the web/ directory:
| Variable | Description |
|---|---|
NEXT_PUBLIC_API_URL | Full URL of your self-hosted backend API. |
NEXT_PUBLIC_APP_URL | Public URL of the Next.js dashboard itself. Used for absolute links and OAuth redirects. |
NEXT_PUBLIC_MAX_AGE | Session cookie max-age in seconds. Defaults to 604800 (7 days) if unset. |
Start the Dashboard
http://localhost:3000. On first load, sign in using GitHub OAuth, Google OAuth, or a WebAuthn passkey (Touch ID / Face ID / Windows Hello), depending on which OAuth credentials you have configured.
Configure the Proxy to Use Your Self-Hosted Backend
Open yourburnguard.yaml and point sync.url at your local backend instead of the public BurnGuard cloud:
interval you set). Generate a sync token by signing in to your self-hosted dashboard and creating one from the token management page.
Production Deployment
For production, build and run the backend using the includedDockerfile:
golang:1.26-alpine builder compiles the binary, and a minimal alpine:3.19 runtime image runs it. The entrypoint.sh script runs pending migrations automatically before starting the server, so no separate migration step is needed in a containerised deployment.
For the Next.js dashboard, run a standard npm run build && npm start or deploy to any platform that supports Node.js (Vercel, Railway, Fly.io, etc.) with the two NEXT_PUBLIC_* environment variables set to your production URLs.
Set
WEBAUTHN_RP_ID to your actual production domain (for example,
app.yourcompany.com) before users register passkeys. WebAuthn binds
credentials to the Relying Party ID at registration time — passkeys created
under localhost will not work on your production domain, and vice versa. If
you change WEBAUTHN_RP_ID after users have registered passkeys, those
credentials become invalid and users will need to re-register.GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET, GOOGLE_CLIENT_ID, and GOOGLE_CLIENT_SECRET in your production environment. Set the authorized redirect URIs to https://your-production-domain.com/api/auth/callback/github and the equivalent Google callback URL.