MongoDB observability dashboard with:
- Live cluster status/metrics/logs
- Runtime MongoDB URI connection from the frontend
- Anomaly detection (slow queries, auth bursts, query spikes)
- Grounded AI chat powered by Google AI Studio Gemini Flash
apps/
api/ # Express backend
web/ # Next.js dashboard
packages/
shared/ # Shared zod schemas/types
- Install
npm install- Env files
copy apps\api\.env.example apps\api\.env
copy apps\web\.env.local.example apps\web\.env.localapps/api/.env important fields:
API_PORT=4000
GEMINI_API_KEY=your_google_ai_studio_key
GEMINI_MODEL=gemini-3-flashMongoDB can still be configured from env (MONGODB_URI, MONGODB_DB, etc.), but now you can also set URI directly from the dashboard UI.
- Start apps
npm run dev- API:
http://localhost:4000 - Web:
http://localhost:3000
From dashboard:
- Open
Dashboard - Paste Mongo URI in MongoDB Connection
- Set DB name
- Click Connect
This calls:
POST /connectionto apply URI without restarting APIGET /connectionfor current runtime connection stateDELETE /connectionto switch back to simulation mode
The assistant endpoint is:
POST /ai/chat
Behavior:
- Uses Google AI Studio API key (
GEMINI_API_KEY) - Tries Gemini Flash models with fallback (
gemini-3-flash,gemini-3.0-flash,gemini-2.5-flash, etc.) - Includes recent metrics/logs/anomalies + short chat history
- Returns structured response: answer, evidence, suggested actions
GET /statusGET /metrics?windowMinutes=60GET /logs?limit=100GET /anomalies?activeOnly=false&limit=50GET /mongo/inventory?collectionLimit=10GET /ai/context?windowMinutes=30POST /ai/chatPOST /testing/scenario
In dashboard, use the Generate test events buttons:
- Slow Query Spike
- Auth Failure Burst
- Query Volume Spike
This injects synthetic metrics/logs and should trigger anomalies in the Alerts tab.
curl -X POST http://localhost:4000/testing/scenario ^
-H "Content-Type: application/json" ^
-d "{\"scenario\":\"slow_query_spike\",\"intensity\":3}"Other scenario values:
auth_failure_burstquery_volume_spikemixed
- Runtime URI is held in API process memory; restarting API resets runtime connection state.
- Dashboard local storage keeps your last typed URI/DB for convenience on the same browser.
- If Gemini key/model is invalid, chat returns actionable error guidance instead of failing silently.
This repo now includes two deployment workflows:
- Web (GitHub Pages):
.github/workflows/deploy-pages.yml - API (Render):
.github/workflows/deploy-api-render.yml
- In Render, create a new service from this repo using
render.yaml. - Set required env vars in Render:
GEMINI_API_KEYMONGODB_URI(or direct connector env vars)CORS_ALLOWED_ORIGINS= your Pages origin (example:https://<your-user>.github.io)
- In Render service settings, copy the Deploy Hook URL.
- In GitHub repo secrets, add:
RENDER_DEPLOY_HOOK_URL= Render deploy hook URL
On every push to main that changes API/shared code, GitHub Actions builds API and triggers Render deploy.
- In GitHub repo Settings → Pages, set source to GitHub Actions.
- In GitHub repo Settings → Secrets and variables → Actions → Variables, add:
NEXT_PUBLIC_API_BASE_URL= your deployed API URL (example:https://mongoguard-api.onrender.com)
On every push to main that changes web/shared code, the web app is built as static export and deployed to Pages.
- Web calls API through
NEXT_PUBLIC_API_BASE_URL. - API allows browser requests from
CORS_ALLOWED_ORIGINS. - Make sure both point to each other correctly:
NEXT_PUBLIC_API_BASE_URL→ deployed API URLCORS_ALLOWED_ORIGINS→ deployed Pages origin