Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/RubenDarioGuerreroNeira/Ecosistema-IA-Colombia/llms.txt

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

Salud IA Bot is a NestJS application that reads health data exclusively from a pre-seeded SQLite database (data/salud-ia-bot.db). Because XML is never parsed at runtime, the production process is straightforward: build the TypeScript source, supply environment variables, ensure the database file is present, and start the compiled output. This page walks through every step.

Prerequisites

Before deploying, confirm the following are in place:
  • Node.js 20+ and npm installed on the target host
  • A pre-seeded data/salud-ia-bot.db file (see Data Seeding)
  • A Telegram bot token obtained from @BotFather
  • An OpenRouter API key from openrouter.ai
  • (Optional) A persistent disk or volume mount if deploying to a platform-as-a-service provider

Build Process

The build script in package.json delegates to the NestJS CLI:
npm run build
Under the hood this runs nest build, which compiles all TypeScript sources under src/ into the dist/ directory using the configuration defined in tsconfig.json (target: ES2022, outDir: ./dist). The NestJS CLI option deleteOutDir: true in nest-cli.json ensures any previous build artefacts are removed before each compile. Once the build succeeds, start the server with either of these commands:
# Using the npm script alias
npm run start:prod

# Or invoking the compiled entry-point directly
node dist/main
Both are equivalent — start:prod is defined in package.json as node dist/main.

Environment Variables

All required and optional configuration is read from environment variables at startup. In local development these are loaded from a .env file; in production, set them directly in your hosting platform’s dashboard or secrets manager.
VariableRequiredDefaultDescription
TELEGRAM_BOT_TOKEN✅ Yes-Token issued by @BotFather for your Telegram bot
OPENROUTER_API_KEY✅ Yes-API key for OpenRouter (routes requests to LLaMA 3.1)
OPENROUTER_MODELNometa-llama/Meta-Llama-3.1-70B-InstructOverride the LLM model slug
PORTNo3000HTTP port exposed by the NestJS server
TELEGRAM_PROXY_URLNo-HTTP/SOCKS proxy URL for restricted networks
TELEGRAM_API_TIMEOUTNo-Request timeout (ms) for Telegram API calls
Never commit your TELEGRAM_BOT_TOKEN or OPENROUTER_API_KEY to source control. Use environment secrets or a secrets manager in production.

Deploying to Render

Render is the recommended platform-as-a-service for Salud IA Bot because it supports persistent disks, which are required to preserve the SQLite database file across deployments.
1

Create a new Web Service

Log in to render.com and click New -> Web Service.
2

Connect your GitHub repository

Authorize Render to access your GitHub account and select the Ecosistema-IA-Colombia repository.
3

Configure build and start commands

Set the Build Command to:
npm install && npm run build
Set the Start Command to:
npm run start:prod
4

Add environment variables

In the Render dashboard, navigate to Environment and add all required variables: TELEGRAM_BOT_TOKEN, OPENROUTER_API_KEY, and any optional overrides.
5

Mount a persistent disk

Under Disks, add a new disk and mount it at the project root so that the data/ directory — and therefore data/salud-ia-bot.db — persists across deploys and restarts. Without this, the database file is lost whenever the service restarts.
6

Upload or seed the database

Before the first deploy completes, transfer your locally seeded data/salud-ia-bot.db to the mounted disk via Render’s shell or by using a pre-deploy script. The application will not start correctly without this file present.
7

Deploy

Trigger a deploy. Render will run the build command, then start the server with node dist/main. Monitor the logs to confirm the NestJS bootstrap message and Telegram bot registration succeed.

Deploying to Railway

Railway can also host Salud IA Bot. The steps mirror Render:
  1. Create a new project and link your repository.
  2. Set the same build (npm install && npm run build) and start (npm run start:prod) commands in the service settings.
  3. Add environment variables under Variables.
  4. Use a Volume attached to the service at the path containing data/ to persist the SQLite file.

Self-Hosted Node.js Server

For a VPS or dedicated server running Ubuntu/Debian:
# 1. Clone the repository
git clone https://github.com/RubenDarioGuerreroNeira/Ecosistema-IA-Colombia.git salud-ia-bot
cd salud-ia-bot

# 2. Install dependencies
npm install

# 3. Build
npm run build

# 4. Copy the pre-seeded database into place
mkdir -p data
cp /path/to/your/salud-ia-bot.db data/

# 5. Export environment variables
export TELEGRAM_BOT_TOKEN=your_token
export OPENROUTER_API_KEY=your_key

# 6. Start
npm run start:prod
Use a process manager such as PM2 to keep the process alive across reboots:
pm2 start dist/main.js --name salud-ia-bot
pm2 save
pm2 startup

Health Check

The NestJS application exposes an HTTP server on PORT (default 3000). A GET / request returns 200 OK from the root AppController. Use this endpoint for uptime monitoring and platform health checks.
curl http://localhost:3000/

Memory Considerations

The application uses better-sqlite3 (version ^12.11.1), a synchronous, high-performance SQLite binding for Node.js. Because XML is parsed only during the one-time seed step — never at runtime — the production process has a very small startup footprint. Expected resident memory usage is approximately 150-300 MB depending on total dataset size and the number of concurrent requests being served.
Do NOT run synchronize: true in the TypeORM production configuration. The schema is managed exclusively by the seed scripts (scripts/import-data.ts, scripts/seed-antioquia.ts, scripts/seed-vaccination.ts). Enabling synchronize in production could silently drop or alter your data tables, causing permanent data loss. The production database module already enforces synchronize: false.

Build docs developers (and LLMs) love