Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/danielsl4/TFG_DAM_2526/llms.txt

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

The FutsalManager backend is a Node.js/Express REST API that connects to PostgreSQL for persistent storage, Redis for caching, and Cloudinary for image uploads. This guide covers what you need to get the API running in production.

Prerequisites

Before deploying, make sure you have the following available:
  • Node.js 18+ — the runtime for the API server
  • PostgreSQL — the primary database (any hosted provider works: Supabase, Railway, Neon, etc.)
  • Redis — used for caching match data and standings (Upstash, Redis Cloud, or self-hosted)
  • A Cloudinary account for handling team and player image uploads

Environment variables

Create a .env file in the backend root (or configure these as environment variables in your hosting platform).

Database

The backend connects to PostgreSQL via a single connection string:
VariableDescription
DATABASE_URLFull PostgreSQL connection string, e.g. postgresql://user:pass@host:5432/dbname
The connection pool is configured with SSL enabled (rejectUnauthorized: false), which is compatible with most managed PostgreSQL providers. If you’re using a self-hosted instance without SSL, you’ll need to adjust db.js accordingly.

Authentication

VariableDescription
JWT_SECRETSecret key used to sign and verify JSON Web Tokens. Use a long, random string.

Redis

VariableDescription
REDIS_URLFull Redis connection URL, e.g. redis://default:password@host:6379

Cloudinary

VariableDescription
CLOUDINARY_CLOUD_NAMEYour Cloudinary cloud name
CLOUDINARY_API_KEYCloudinary API key
CLOUDINARY_API_SECRETCloudinary API secret

Server

VariableDefaultDescription
PORT3000Port the Express server listens on
A complete .env looks like this:
.env
DATABASE_URL=postgresql://user:password@localhost:5432/futsalmanager
JWT_SECRET=your-long-random-secret-here
REDIS_URL=redis://default:password@localhost:6379
CLOUDINARY_CLOUD_NAME=your-cloud-name
CLOUDINARY_API_KEY=123456789012345
CLOUDINARY_API_SECRET=your-api-secret
PORT=3000

Deployment

1

Install dependencies

Run this from the backend/ directory:
npm install
2

Configure environment variables

Copy the example above into a .env file in the backend root, or set the variables directly in your hosting platform’s dashboard.
3

Initialize the database

Run the initialization script once to create all tables and ENUM types:
node init_db.js
Only run init_db.js once on a fresh database. It uses CREATE TABLE IF NOT EXISTS, so it is safe to re-run, but it does not run migrations — handle schema changes separately.
4

Start the server

npm start
This runs node index.js. The server will log the port it’s listening on.

Production tips

Use PM2 to keep the process running and restart it automatically on crashes:
npm install -g pm2
pm2 start index.js --name futsalmanager-api
pm2 save
pm2 startup
Set NODE_ENV=production in your environment to ensure libraries like Express apply production-safe defaults:
.env
NODE_ENV=production
The API sets permissive CORS headers (Access-Control-Allow-Origin: *) by default. For production, consider restricting this to your frontend’s domain by editing the CORS middleware in index.js.

Build docs developers (and LLMs) love