Skip to main content
This guide walks you through deploying the TMT Platform backend to Firebase Cloud Functions and making your first API call.

Prerequisites

Before you begin, make sure you have the following installed and configured:
  • Node.js 22 — required by the engines field in package.json
  • Firebase CLI — install with npm install -g firebase-tools
  • Google Cloud project with Firebase enabled and billing active (required for Cloud Functions)
  • A PostgreSQL instance on Cloud SQL (required for financial reconciliation and reporting functions)
1

Clone the repository and install dependencies

Clone the TMT Platform source and install all Node.js dependencies.
npm install
This installs all required packages, including firebase-admin, firebase-functions, pg, stripe, seatsio, axios, and the @google-cloud/cloud-sql-connector.
2

Authenticate with Firebase

Log in to your Firebase account and link the project.
firebase login
When prompted, select your Google Cloud project from the list. This sets the active Firebase project for all CLI commands.
3

Configure environment secrets

The platform reads sensitive credentials at runtime through Firebase configuration or environment variables. Set the required values before deploying.
firebase functions:secrets:set SEATSIO_DEV_KEY
firebase functions:secrets:set SEATSIO_PROD_KEY
The config/config.js file initializes firebase-admin and exposes the Firestore db, auth, storage, and messaging instances used throughout the platform. Third-party credentials are referenced from this file and should be injected via Firebase Secrets — not hardcoded.
4

Configure the Cloud SQL connection

The config/dbpostgres.js helper connects to PostgreSQL using the @google-cloud/cloud-sql-connector. Update the connection details to match your Cloud SQL instance.
config/dbpostgres.js
const clientOpts = await connector.getOptions({
  instanceConnectionName: 'your-project:region:instance-name',
  ipType: 'PUBLIC',
});
const pool = new Pool({
  ...clientOpts,
  user: 'your-db-user',
  password: 'your-db-password',
  database: 'your-db-name',
  max: 5,
});
Do not commit database credentials to source control. Use Firebase Secrets or environment variables to inject these values at runtime.
5

Deploy the functions

Deploy all Cloud Functions to your Firebase project.
firebase deploy --only functions
After deployment completes, the CLI prints the HTTPS endpoint URL for each function. It follows this pattern:
https://<region>-<project-id>.cloudfunctions.net/<function-name>
6

Make your first API call

The exchange_rates function fetches the current USD and EUR exchange rates from the BCV (Banco Central de Venezuela) and writes them to Firestore. It requires no request body.
curl -X POST \
  https://<region>-<project-id>.cloudfunctions.net/exchange_rates
The function scrapes the BCV website, parses the USD and EUR rates, and writes two records to Firestore:
  • data/exchange_rates — current rates document
  • data/exchange_rates/history/{id} — historical entry with a timestamp
A successful response looks like:
{ "result": "Actualizado . Ingresado " }
7

Call a function that requires a request body

Most TMT Platform functions follow a consistent { data: { ... } } request body structure. For example, to set exchange rates manually:
curl -X POST \
  https://<region>-<project-id>.cloudfunctions.net/exchange_rates_manual \
  -H "Content-Type: application/json" \
  -d '{"params": {"usd": 36.50, "eur": 39.20}}'
For user-facing functions (such as create_client, validate_user_type, and all order/payment functions), wrap your payload in a data key:
{
  "data": {
    "email": "[email protected]",
    "password": "securepassword",
    "name": "Jane Doe"
  }
}

Run functions locally

Use the Firebase Emulator Suite to develop and test functions without deploying.
firebase emulators:start --only functions
The emulator starts a local HTTPS server. Function endpoints are available at http://localhost:5001/<project-id>/<region>/<function-name>.

Next steps

Architecture

Understand how Firebase, Firestore, PostgreSQL, and third-party services fit together.

User management

Create and manage clients, collaborators, and staff accounts.

Events & Tickets

Generate tickets, manage access control, and run ticket offices.

Payments

Accept payments via Stripe, Banco Mercantil, and BCV.

Build docs developers (and LLMs) love