Separate NestJS backend for deployment at https://api.chefuinc.com.
cd backend
npm install
npm run devThe API listens on PORT or 4000.
Shared app defaults live in src/modules/apps/app-registry.ts.
Add new frontend apps there once, including local and production origins.
Next/React frontends should send x-chefu-app when creating a session:
x-chefu-app: academyx-chefu-app: adminx-chefu-app: flowx-chefu-app: muzalox-chefu-app: quantum
Flow's existing x-flow-session header still works and still enforces the
Flow sender allowlist.
x-chefu-app: music is accepted as a legacy alias for Muzalo.
CheFu API also acts as the CheFu Account authorization server. It supports the OAuth 2.0 Authorization Code flow with PKCE and OIDC discovery:
GET /.well-known/openid-configurationGET /.well-known/oauth-authorization-serverGET /oauth/authorizePOST /oauth/tokenGET /oauth/userinfoGET /oauth/jwks
Registered OAuth clients live in src/modules/apps/app-registry.ts. Public
browser clients must use code_challenge_method=S256.
This backend is organized as a shared CheFu platform plus product modules:
- Platform modules: app registry, Firebase Admin, auth, and health.
- Shared service modules: admin, AI, billing, email, and notifications.
- Product modules: Academy SDK, Academy courses, Flow, and future apps.
See docs/backend-architecture.md for the module pattern and the checklist for
adding a new CheFu app.
Set these on the backend host:
FRONTEND_ORIGIN=https://chefuinc.comAUTH_COOKIE_DOMAIN=.chefuinc.comAUTH_SESSION_SECRET=<long random secret>CHEFU_ACCOUNT_URL=https://chefuinc.comOAUTH_ISSUER=https://api.chefuinc.comOAUTH_PRIVATE_KEY=<RSA private key PEM with \n escapes>OAUTH_KEY_ID=<stable signing key id>- Firebase Admin credentials using either
FIREBASE_SERVICE_ACCOUNTJSON orFIREBASE_PROJECT_ID,FIREBASE_CLIENT_EMAIL,FIREBASE_PRIVATE_KEY FIREBASE_API_KEYfor SDK email/password login compatibilityGEMINI_API_KEYWHATSAPP_PHONE_NUMBER_IDWHATSAPP_SYSTEM_USER_TOKENRESEND_API_KEYfor security notification emailsFLOW_ACCESS_SECRET=<long random secret shared with the Flow frontend>FLOW_SENDERS="CheFu Inc <hello@chefuinc.com>;Flow Mail <mail@chefuinc.com>;Support <support@chefuinc.com>;Security <security@chefuinc.com>;Muzalo <muzalo@chefuinc.com>;CheFu Academy <academy@chefuinc.com>;CheFu Quantum <quantum@chefuinc.com>"SIGNIN_ALERT_TEMPLATE_IDif using a saved Resend template for sign-in alertsPASSWORD_CHANGED_TEMPLATE_IDif using a saved Resend template for password-change alerts
On the frontend host, set:
NEXT_PUBLIC_API_BASE_URL=https://api.chefuinc.com
GET /healthPOST /auth/sessionGET /oauth/authorizePOST /oauth/tokenGET /oauth/userinfoGET /oauth/jwksPOST /auth/loginPOST /auth/registerPOST /auth/refreshPOST /api/auth/loginPOST /api/auth/registerPOST /api/auth/refreshPOST /api/auth/verifyGET /api/coursesGET /api/courses/:courseIdPOST /api/courses/listGET /api/keys/listPOST /api/keys/createPOST /api/keys/revokePOST /api/keys/report-leakGET /auth/meDELETE /auth/sessionPOST /ai/generatePOST /admin/delete-userPOST /admin/send-otpPOST /email/password-changedGET /flow/access/sessionPOST /flow/access/loginPOST /flow/access/activateDELETE /flow/access/sessionGET /flow/admin/access-keysadmin onlyPOST /flow/admin/access-keysadmin onlyPOST /flow/admin/access-keys/:keyId/revokeadmin only