Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/fredy-rizo/gestor-backend/llms.txt

Use this file to discover all available pages before exploring further.

Gestor Deportivo reads all runtime configuration from a single .env file. This page documents every supported variable, explains where the file must be placed, and provides step-by-step guides for generating the credentials required by Gmail and Google Cloud Storage.

.env File Location

Place your .env file in the root of the project — the same directory that contains package.jsonnot inside the src/ folder. The dotenv package is initialised by src/config.js at startup and resolves paths relative to the working directory from which the Node process was launched.
gestor-backend/       ← project root
├── .env              ← ✅ correct location
├── package.json
└── src/
    ├── config.js
    └── index.js
Never commit your .env file to version control. Add .env to your .gitignore immediately after creating it. Exposing SECRET, database credentials, or Google OAuth secrets can lead to account takeover and data loss.

Environment Variables

Server

PORT
number
The port on which the Express server listens. Defaults to 3000 when the variable is absent or empty, as defined in src/index.js.
PORT=3000

Authentication

SECRET
string
required
The secret used to sign and verify JSON Web Tokens. Choose a long, random string (at least 32 characters). All tokens signed with this value are invalidated if it changes, which forces all logged-in users to re-authenticate.
SECRET=a8f3kq92mxLp0vRnBz6TwYdHeJsCuOiQ
Generate a strong secret from your terminal:
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"

Database

MONGODB_URL
string
required
The full MongoDB connection string used by Mongoose to connect to your database. Supports both local instances and hosted services such as MongoDB Atlas.
# Local instance
MONGODB_URL=mongodb://localhost:27017/gestor-deportivo

# MongoDB Atlas (cloud)
MONGODB_URL=mongodb+srv://<user>:<password>@cluster0.example.mongodb.net/gestor-deportivo?retryWrites=true&w=majority

Email (Nodemailer)

Gestor Deportivo sends transactional emails for account verification and password recovery using Nodemailer with a Gmail transport. Both variables must be set for email delivery to work.
USER_EMAIL
string
The Gmail address from which verification and recovery emails are sent.
USER_EMAIL=noreply@yourdomain.com
PASS_EMAIL
string
A Gmail App Password — a 16-character application-specific password generated from your Google Account settings. This is not your personal Gmail login password.
PASS_EMAIL=abcd efgh ijkl mnop
See Gmail App Password Setup below for step-by-step instructions.

Google Cloud Storage

Team logos and player photos are uploaded to a Google Cloud Storage bucket. All four variables below must be populated for image uploads to succeed.
NAMEGOOGLECLOUD
string
The name of the Google Cloud Storage bucket where uploaded images are stored.
NAMEGOOGLECLOUD=gestor-deportivo-media
CLIENT_ID
string
The OAuth 2.0 Client ID issued by Google Cloud Console for your project.
CLIENT_ID=123456789012-abcdefghijklmnopqrstuvwxyz123456.apps.googleusercontent.com
CLIENT_SECRET
string
The OAuth 2.0 Client Secret paired with CLIENT_ID.
CLIENT_SECRET=GOCSPX-AbCdEfGhIjKlMnOpQrStUv
CLIENT_URL
string
The URL of your frontend application. Used as the redirect URI in the Google OAuth 2.0 flow so that tokens are returned to the correct origin after authentication.
# Local development
CLIENT_URL=http://localhost:5173

# Production
CLIENT_URL=https://app.yourdomain.com

Gmail App Password Setup

Google requires 2-Step Verification to be enabled before you can create an App Password. Follow these steps:
1

Enable 2-Step Verification

Go to myaccount.google.com/security and enable 2-Step Verification on the Gmail account you intend to use for sending emails.
2

Open App Passwords

In the same Security page, search for App Passwords (you may need to scroll down or use the search bar). Click on it.
3

Create a new App Password

Select Mail as the app and Other (Custom name) as the device. Enter a name like Gestor Deportivo, then click Generate.
4

Copy the generated password

Google will display a 16-character password in four groups of four letters (e.g., abcd efgh ijkl mnop). Copy it immediately — it will not be shown again.
5

Set PASS_EMAIL in your .env

Paste the generated password as the value of PASS_EMAIL. You can include or omit the spaces — Nodemailer handles both formats.
PASS_EMAIL=abcdefghijklmnop
If you see an Invalid login or Username and Password not accepted error at startup, double-check that 2-Step Verification is active and that you are using the App Password — not your regular Gmail password.

Google Cloud Storage Setup

1

Create a Google Cloud project

Visit console.cloud.google.com, create a new project (or select an existing one), and note the Project ID.
2

Enable the Cloud Storage API

In the Google Cloud Console, navigate to APIs & Services → Library, search for Cloud Storage, and click Enable.
3

Create a storage bucket

Go to Cloud Storage → Buckets and click Create. Give your bucket a globally unique name — this value becomes NAMEGOOGLECLOUD. Choose a region close to your server for lowest latency.
4

Create a service account and download credentials

Navigate to IAM & Admin → Service Accounts, create a new service account with the Storage Object Admin role, then generate a JSON key. Download and secure this file — it grants write access to your bucket.
5

Create OAuth 2.0 credentials

Go to APIs & Services → Credentials → Create Credentials → OAuth 2.0 Client ID. Add your CLIENT_URL as an authorised redirect URI. Copy the generated Client ID and Client Secret into your .env.
For local development you can use the Google Cloud Storage emulator to avoid incurring costs during testing.

Complete .env Template

Copy this template to the root of your project, fill in every value, and save as .env.
# ─── Server ────────────────────────────────────────────────────────────────────
PORT=3000

# ─── Authentication ────────────────────────────────────────────────────────────
# Generate with: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
SECRET=replace_with_a_long_random_string

# ─── Database ──────────────────────────────────────────────────────────────────
MONGODB_URL=mongodb://localhost:27017/gestor-deportivo

# ─── Email (Nodemailer / Gmail) ────────────────────────────────────────────────
USER_EMAIL=noreply@yourdomain.com
PASS_EMAIL=your_gmail_app_password

# ─── Google Cloud Storage ──────────────────────────────────────────────────────
NAMEGOOGLECLOUD=your-gcs-bucket-name
CLIENT_ID=your_google_oauth_client_id
CLIENT_SECRET=your_google_oauth_client_secret
CLIENT_URL=http://localhost:5173
Add .env to your .gitignore before your first commit:
echo ".env" >> .gitignore
Rotating a leaked SECRET immediately invalidates all active sessions. Rotating leaked Google credentials requires revoking and re-issuing keys in the Google Cloud Console.

Build docs developers (and LLMs) love