Self-hosting bhasha-js

The whole BhashaJS stack — backend API, management dashboard, MongoDB — is open source and ships with a docker-compose.yml. You can run it on any server with Docker installed.

What you'll need

  • A VPS with Docker + Docker Compose installed (any cheap droplet: Hetzner, DigitalOcean, Linode work).
  • A domain name pointing at the server's IP.
  • A Google Gemini API key (for AI translation features). Get one free here.

1. Clone the repo

git clone https://github.com/santoshpant613/bhashajs.git
cd bhashajs

2. Configure environment

cp .env.example .env
nano .env

Fill in the required values:

  • JWT_SECRET — generate with openssl rand -hex 32
  • GEMINI_API_KEY — your Gemini API key
  • MONGO_ROOT_PASSWORD — strong random password (used by the bundled MongoDB)
  • CORS_ORIGIN — comma-separated list of frontend origins, e.g. https://bhashajs.com,https://app.bhashajs.com

3. Deploy

chmod +x deploy.sh
./deploy.sh you@email.com

This sets up Caddy + Let's Encrypt for HTTPS, brings up the stack, and runs the database migration. Takes about 60 seconds.

4. Verify

  • https://your-domain.com/api/health returns {"success": true}
  • https://your-domain.com shows the dashboard. Register an account.

5. Point the SDK at your URL

<I18nProvider
  projectKey="bjs_..."
  apiUrl="https://your-domain.com/api"
  defaultLang="en">
  <App />
</I18nProvider>

What's running

  • Backend API (Express + MongoDB) — at :5000 behind nginx
  • Dashboard (React + Vite SPA) — static files served by nginx
  • MongoDB 7 — local container with persistent volume
  • nginx — TLS termination, reverse proxy

Backups

The MongoDB volume is mounted at ./mongo_data. Back it up with tar or mongodump:

docker compose exec mongo mongodump --archive=/data/db/backup.archive
docker cp bhashajs-mongo-1:/data/db/backup.archive ./backups/

Updates

git pull
docker compose down
docker compose up --build -d