Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Minogar28/DIRECTORIO_UDC/llms.txt

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

Deploying Directorio UDC involves two steps: building the React frontend into an optimised static bundle, then serving that bundle — together with the Express API — from a single Node.js process. This keeps the infrastructure simple: one server, one port, no separate static-file CDN required for a basic deployment.

Build the Frontend

From the FRONTEND directory, run the build script:
cd FRONTEND
npm run build
This command executes tsc -b && vite build:
  1. tsc -b — runs a full TypeScript type-check across the project. The build aborts with a non-zero exit code if there are any type errors, so type safety is enforced before a single byte reaches the server.
  2. vite build — bundles, tree-shakes, and minifies the application, outputting the result to FRONTEND/dist/.
Before deploying, verify the production bundle locally with the Vite preview server:
npm run preview
This serves the contents of FRONTEND/dist/ on a local port so you can confirm the production build works correctly before pushing to a server.

Serving the Static Bundle

The Express backend can serve the FRONTEND/dist/ directory using express.static, combining the API and the frontend into a single Node.js process. The example below shows how to structure your BACKEND/index.js entry point. The catch-all route at the bottom uses the Express 5 wildcard syntax (/{*path}) and ensures that client-side navigation always receives index.html rather than a 404:
const express = require('express')
const cors = require('cors')
const path = require('path')

const app = express()
const PORT = process.env.PORT || 3000

app.use(cors())
app.use(express.json())

// Serve the built React app
app.use(express.static(path.join(__dirname, '../FRONTEND/dist')))

// API routes go here
// app.get('/api/...', handler)

// Fallback: serve index.html for all non-API routes (SPA routing)
// Note: Express 5 requires the named wildcard syntax {*path}
app.get('/{*path}', (req, res) => {
  res.sendFile(path.join(__dirname, '../FRONTEND/dist', 'index.html'))
})

app.listen(PORT, () => {
  console.log(`Server running on port ${PORT}`)
})
With this setup, every request to a path that does not match a static file or an API route is handled by the fallback, making deep links and browser refreshes work correctly for the single-page application.

Starting the Backend

The backend has no start npm script. Start the server directly with Node.js:
cd BACKEND && node index.js
To override the port:
PORT=4000 node index.js

Platform Deployment Options

Railway

Deploy Node.js apps with a simple railway up command. Railway detects the Node.js runtime automatically, injects environment variables from its dashboard, and provisions a public URL with TLS included.

Render

Free tier Node.js hosting with automatic deploys from GitHub. Connect your repository, set the build command to cd FRONTEND && npm run build, and the start command to node BACKEND/index.js.

Fly.io

Deploy containers globally with a generous free tier. Write a minimal Dockerfile, run fly launch, and Fly distributes your app across multiple regions with automatic failover.

VPS / Linux

Self-host on any Linux server with PM2 for process management. Full control over the environment, ideal for university infrastructure or on-premises requirements.

Process Management

In production, use PM2 to keep the Node.js process alive across crashes and server reboots:
npm install -g pm2
pm2 start index.js --name directorio-udc
pm2 save
pm2 startup
  • pm2 start — launches the process and registers it with PM2.
  • pm2 save — persists the current process list to disk.
  • pm2 startup — generates and prints an OS-specific command to register PM2 as a system service, so processes restart automatically after a reboot.
Monitor the running application with pm2 logs directorio-udc and pm2 monit.
Set NODE_ENV=production when running in production. Express 5 disables verbose development error messages in this mode and enables a number of internal performance optimisations. Most PaaS platforms set this variable automatically; on a VPS, add it to your PM2 ecosystem file or your shell profile.
Set the cors() origin in production to your actual frontend domain rather than relying on the permissive open default. For example: app.use(cors({ origin: 'https://directorio.udc.edu' })). This prevents unintended cross-origin access to your API from third-party sites.

Build docs developers (and LLMs) love