The Debuta backend is an Express.js HTTP server with Socket.io mounted on the same Node.jsDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/desarrolladorandres2026-gif/Native-tailwind/llms.txt
Use this file to discover all available pages before exploring further.
http.Server instance. It connects to MongoDB Atlas via Mongoose, offloads all photo storage to Cloudinary, and sends transactional emails (password resets) through Nodemailer over Gmail SMTP. A static admin panel is also served directly from the same process at the /admin path.
Prerequisites
Before running the server, make sure the following are in place:Node.js 18+
The server targets the Node.js 18 LTS runtime or newer. Check your version with
node -v.MongoDB Atlas (or local)
You need a MongoDB connection string. MongoDB Atlas free tier works fine for local development.
Cloudinary Account
A free Cloudinary account provides the
CLOUDINARY_CLOUD_NAME, CLOUDINARY_API_KEY, and CLOUDINARY_API_SECRET values.Gmail App Password
A Gmail address with a 16-character app password (not your regular Gmail password) is required for Nodemailer to send emails.
Installation
Install dependencies
package.json, including Express, Socket.io, Mongoose, Cloudinary, Multer, Nodemailer, bcryptjs, jsonwebtoken, google-auth-library, and nodemon.Create your environment file
Copy the provided example and fill in your own values:See the Configuration page for a full description of every variable.
npm Scripts
| Script | Command | Description |
|---|---|---|
npm run dev | nodemon server.js | Starts the server with nodemon for automatic restarts on file changes. Runs auto-whitelist.js first via the predev hook. |
npm start | node server.js | Production start. Runs auto-whitelist.js first via the prestart hook before launching the server. |
npm run whitelist | node scripts/auto-whitelist.js | Adds the machine’s current public IP to the MongoDB Atlas IP access list. Useful when your IP changes. |
Both
npm run dev and npm start automatically run scripts/auto-whitelist.js before the server starts via npm’s predev and prestart lifecycle hooks. If the Atlas Admin API keys (ATLAS_PUBLIC_KEY, ATLAS_PRIVATE_KEY, ATLAS_PROJECT_ID) are not set in .env, the whitelist script exits silently without error so the server still starts.How the Server Starts
server.js is the entry point. It loads the environment with dotenv, creates a Node.js http.Server from the Express app, initialises Socket.io on that server, then connects to MongoDB with a linear-backoff retry loop (up to 5 attempts: 3 s, 6 s, 9 s, 12 s, 15 s). The HTTP server begins listening only after the MongoDB connection is established.
Directory Structure
API Routes
app.js mounts the following route groups under /api:
| Prefix | Module | Purpose |
|---|---|---|
/api | auth.routes | Login, registration, GET /api/me |
/api/users | user.routes | Profile reads and updates |
/api/matches | match.routes | Swipe decisions and match retrieval |
/api/chat | chat.routes | Chat history |
/api/settings | settings.routes | Discovery filter preferences |
/api/likes | likes.routes | Who liked me |
/api/report | report.routes | Report a user |
/api/facial | facial.routes | Facial recognition |
/api/posts | post.routes | User wall posts |
/api/admin | admin.routes | Admin-only management endpoints |
/api/asociado | asociado.routes | Restaurant partner endpoints |
/api/auth | social.routes | Google and Facebook OAuth |
/api/password | password.routes | Password reset flow |
/api/soporte | soporte.routes | Support tickets |
Admin Panel
The static admin panel (a separate frontend build) is served from theadmin/ directory at the root of the repository. Express maps it to the /admin path:
Health Check
A lightweight health check endpoint is available without authentication:CORS Behaviour
CORS handling differs by environment:development— all origins are allowed (cors()with no restrictions).production— only origins listed inALLOWED_ORIGINS(comma-separated) are permitted. Requests from unlisted origins receive a CORS error. Socket.io applies the same policy.