Skip to main content
This guide walks you through cloning the Factus Challenge repository, wiring up your environment variables, and verifying that the backend can communicate with the Factus API — all the way to opening the frontend in your browser and issuing your first invoice.

Prerequisites

Before you begin, make sure you have the following ready:
  • Node.js 22+ — the backend uses --env-file (native .env loading) and ES modules, both of which require Node.js 22
  • PostgreSQL — a local instance or a managed service (the project was tested on Azure Database for PostgreSQL)
  • A Factus API account — sign up at factus.com.co and obtain your client_id, client_secret, email, and password for the sandbox (api-sandbox.factus.com.co) or production environment
Factus provides a free sandbox environment at https://api-sandbox.factus.com.co. Use it during development so you never touch real billing data.

Steps

1

Clone the repository

Clone the project from GitHub and move into the root directory:
The repository contains two top-level directories:
  • bc-v1/ — the Node.js/Express backend
  • fr-v1/ — the static HTML/JS frontend
2

Install backend dependencies

Navigate into the backend directory and install all npm packages:
This installs the five runtime dependencies declared in package.json:
3

Create the .env file

Create a .env file inside bc-v1/. The server loads it automatically via Node’s --env-file flag when you run npm run dev.
Never commit your .env file to version control. Add bc-v1/.env to your .gitignore before your first commit.
Variable reference:
4

Start the backend server

From inside bc-v1/, run:
This executes node --env-file .env --watch ./src/main.js. On startup, the server:
  1. Fetches an OAuth 2.0 token immediately by calling POST /oauth/token on the Factus API, storing the resulting access_token and refresh_token in process.env
  2. Starts Express on port 4500 (or the value of PORT)
  3. Schedules a token refresh every 55 minutes (3,300,000 ms) via setInterval
You should see output similar to:
The server auto-refreshes the OAuth access token every 55 minutes in the background. You do not need to restart the process to keep the token valid — this is handled entirely by bc-v1/src/auth/token.js.
5

Configure the frontend

The frontend reads its backend URL from a single JSON file. Open fr-v1/resources/assets/config.json and verify (or update) the url field to point at your running backend:
If your backend is deployed remotely (e.g., on Koyeb), replace http://localhost:4500 with your deployment URL:
6

Open the frontend in a browser

The frontend is fully static — no build step required. Simply open the entry point in your browser:
The page loads Bootstrap 5.3.3 (Vapor dark theme) and Tabulator 6.3 from self-hosted files in fr-v1/resources/utils/ and immediately starts making requests to the backend URL defined in config.json.

Verify the Backend Is Working

Once the server is running, confirm it can reach the Factus API by listing invoices. Send a GET request to the /factura endpoint:
A successful response looks like this (the data array contains invoices returned by the Factus API):
If you receive a 500 or a token-related error, double-check that url_api, client_id, client_secret, email, and password are all set correctly in your .env file.