urBackend is a monorepo for a MongoDB-native BaaS.
Main apps:
apps/dashboard-api: admin/project management API for the dashboard (Node.js/Express)apps/public-api: public project API for data, auth, storage (Node.js/Express)apps/web-dashboard: React/Vite dashboard (Tailwind v4, Geist minimal dark/light theme)apps/consumer: Consumer Worker for background jobs, exports, and webhooks (BullMQ)apps/python-service: Python AI Microservice (FastAPI/Groq, Pydantic, schema generation & query builder)packages/common: shared models, validation, middleware, encryption, DB/model utilities, queues
SDKs:
sdks/urbackend-sdk: Core TypeScript/JavaScript SDK (Framework-agnostic)sdks/urbackend-react: React SDK (UrProvider,useUrContext, UI components)sdks/urbackend-python: Official Python SDK (Requests-based)sdks/urbackend-cli: Official CLI to Manage urbackend projects
Workspace scripts are defined in package.json.
- Frontend Landing:
https://urbackend.in/ - Dashboard App:
https://app.urbackend.in/ - Dashboard API (Internal/Admin):
https://platform-api.urbackend.in/ - Public API (SDK & User Auth):
https://api.urbackend.in/
-
Do not treat
userslike a normal collection.- Public access to
/api/data/users*is blocked. - User auth flows must go through
/api/userAuth/*. - Dashboard admin user management uses dedicated admin routes.
- Public access to
-
Preserve the current RLS model.
- Supported modes are
public-readandprivate. owner-write-onlyis legacy and must be treated aspublic-read.- Read filtering is enforced in
public-api. - Write ownership is enforced in
authorizeWriteOperation.
- Supported modes are
-
Social auth flow rules.
- Provider callback URLs are backend-generated and read-only in the dashboard.
- Users only configure
enabled,clientId, andclientSecret. - Post-login redirect comes from
project.siteUrl, not provider-specific redirect fields. - Successful provider auth redirects to
<siteUrl>/auth/callback.
-
Secrets and BYOK keys must stay encrypted at rest and in transit.
- Secrets stored at rest in MongoDB must use AES-256-GCM via
packages/common/src/utils/encryption.js. - Keys sent to the internal Python AI service are transit-encrypted using
encryptForTransit.
- Secrets stored at rest in MongoDB must use AES-256-GCM via
-
Hierarchical BYOK (Bring Your Own Key) Resolution for AI:
- 1st Priority: Project-level Groq Key (
project.byok.groqKey) - 2nd Priority: Developer-level Groq Key (
developer.byok.groqKey) - Fallback: Platform shared pool (subject to atomic Redis Lua quota limits and plan enforcement)
- Developer BYOK endpoint is
PUT /api/user/me/byok(with aliasPUT /api/auth/me/byok). Project BYOK isPUT /api/projects/:projectId/byok.
- 1st Priority: Project-level Groq Key (
-
The
usersschema contract is still required for auth.emailrequiredStringpasswordrequiredString- Social-auth-created users still get a generated hashed password to satisfy this contract.
-
Theme & UI Density Guidelines (Web Dashboard):
- Use CSS design tokens from
index.css(var(--color-bg-main),var(--color-bg-card),var(--color-bg-input),var(--color-text-main),var(--color-text-muted),var(--color-border)). - Never hardcode dark colors (
#111,#fff,#ededed, or rawrgba(0,0,0,...)) in component inline styles or classes to avoid breaking Light Mode. - Maintain high information density: compact table rows (32px height), tight paddings (0.65rem–0.85rem), and 0 outer margins on primary workspaces.
- Use CSS design tokens from
Implemented providers:
- GitHub
Key files:
- Project.js
- project.controller.js
- userAuth.controller.js
- Auth.jsx
- AuthCallback.jsx
- ProjectSettings.jsx
Behavior:
- Start route requires
x-api-keyand enabled auth. - Callback route uses Redis-backed
state, reloads project config from DB, exchanges code, resolves/creates the user, issues urBackend tokens, then redirects to frontend. - Existing users are linked by verified email when possible.
- Social auth details are not shown inline on the main Auth page.
- Main Auth page shows a compact Social Auth section.
- Provider configuration is opened via a modal.
- Provider selection happens inside the modal, one provider at a time.
Site URLis configured in Project Settings and reused by social auth.
- Refresh session:
project:auth:refresh:session:{tokenId} - OAuth state:
project:auth:oauth:state:{state}(10min TTL) - Social Refresh Exchange:
project:social-auth:refresh-exchange:{rtCode}(Uses atomicGETDELfor concurrency safety) - Mail count:
project:mail:count:{projectId}:{YYYY-MM}(TTL = end of month) - AI Iteration session:
ai:session:{sessionId}(TTL = 1 hour) - AI Monthly Quota:
ai:usage:{devId}:{YYYY-MM} - Cache invalidation pub/sub:
project:cache:invalidate - Do NOT change these patterns — existing sessions will break
All endpoints return: { success: bool, data: {}, message: "" }
Use AppError class for errors — never raw throw, never expose MongoDB errors to client.
PUBLIC_AUTH_ACCESS_TOKEN_TTL(default: 15m)PUBLIC_AUTH_REFRESH_TOKEN_TTL_SECONDS(default: 604800)FRONTEND_URL— used for OAuth callback redirect & CORSPYTHON_SERVICE_URL— URL for Python AI microservice (e.g.http://localhost:8000)INTERNAL_SERVICE_SECRET— secret key for transit encryption / internal service auth- Check
.env.examplefor full list
Update all of:
- shared model in
packages/common - validation in
packages/common/src/utils/input.validation.js - dashboard-api read/update sanitization
- dashboard UI consumers
Check:
apps/public-api/src/controllers/userAuth.controller.jsapps/public-api/src/routes/userAuth.jsapps/public-api/src/utils/refreshToken.js- social auth tests
- refresh token tests
Check:
- schema validation in
packages/common - model compilation in
packages/common/src/utils/injectModel.js - dashboard create collection UI
- dashboard-api collection creation/index creation flow
Check:
apps/python-service/app/main.pyand servicesapps/dashboard-api/src/controllers/ai.controller.jsapps/web-dashboard/src/components/CollectionCreatorAgent.jsxapps/web-dashboard/src/components/Database/AiQueryBar.jsx
Check:
mailtemplatescollection data (global templates are DB-only, not code-seeded)- import source file
tools/db-import/global-mail-templates.json - dashboard mail templates UI/preview in
apps/web-dashboard/src/pages/ProjectSettings.jsx - template resolution path in
apps/public-api/src/controllers/mail.controller.js
Run all dev servers:
npm run devRun public API tests:
cd apps/public-api
npx jest --testPathPatterns=src/ --runInBandRun dashboard API tests:
cd apps/dashboard-api
npx jest --testPathPatterns=src/ --runInBandRun web dashboard lint:
cd apps/web-dashboard
npm run lintRun web dashboard build:
cd apps/web-dashboard
npm run buildRun python service tests:
cd apps/python-service
pytestRun SDK tests:
# JS Core SDK
npm run test --workspace=@urbackend/sdk
# React SDK (Vitest)
npm run test --workspace=@urbackend/react
# Python SDK (pytest)
cd sdks/urbackend-python
pytestBefore shipping auth, RLS, or schema changes:
- run
apps/public-apitests - run
apps/dashboard-apitests - run
apps/python-servicetests - run
@urbackend/sdktests - run
@urbackend/reacttests - run
apps/web-dashboardlint - run
apps/web-dashboardbuild when frontend changed
For Jest in this repo, --runInBand is often safer in constrained Windows environments.
apps/web-dashboard currently builds successfully but Vite warns about large chunks. This is not a release blocker by itself.
- Prefer preserving existing behavior over “cleanup” changes in auth and RLS.
- Do not reintroduce editable provider callback URLs.
- Do not make social auth depend on dashboard login cookies; it belongs to project public auth.
- When touching docs, update both repo docs and in-dashboard docs if the user-facing flow changes.