Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/DUVAN100/saludya-api/llms.txt

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

This setup guide describes the intended implementation architecture for SaludYa API. The project is currently under development.

Prerequisites

The planned implementation will require the following:
  • Node.js (v16 or higher)
  • PostgreSQL (v13 or higher)
  • npm or yarn package manager
  • Git for version control
We recommend using Node.js v18 LTS for optimal performance and security.

Planned Installation

1

Clone the repository

When available, clone the SaludYa API repository:
git clone https://github.com/DUVAN100/saludya-api.git
cd saludya-api
2

Install dependencies

Install all required Node.js packages:
npm install
This will install Express, TypeORM, authentication libraries, and other dependencies defined in package.json.
3

Configure environment variables

Create a .env file in the root directory by copying the example file:
cp .env.example .env
Update the .env file with your configuration:
# Server Configuration
PORT=3000
NODE_ENV=development

# Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=saludya_user
DB_PASSWORD=your_secure_password
DB_NAME=saludya_db

# JWT Authentication
JWT_SECRET=your_jwt_secret_key_minimum_32_characters
JWT_EXPIRES_IN=24h

# Rate Limiting
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX_REQUESTS=100

# CORS Configuration
ALLOWED_ORIGINS=http://localhost:3000,https://yourdomain.com
Never commit your .env file to version control. Keep your JWT_SECRET secure and use a strong, randomly generated string in production.
4

Set up the database

Create a PostgreSQL database for SaludYa:
# Connect to PostgreSQL
psql -U postgres

# Create database and user
CREATE DATABASE saludya_db;
CREATE USER saludya_user WITH ENCRYPTED PASSWORD 'your_secure_password';
GRANT ALL PRIVILEGES ON DATABASE saludya_db TO saludya_user;
Run database migrations to create the required tables:
npm run migration:run
You can optionally seed the database with sample data for testing:
npm run seed
5

Start the server

Start the development server:
npm run dev
The API will be available at http://localhost:3000. You should see:
🚀 Server running on port 3000
📊 Database connected successfully

Database Schema

SaludYa API uses the following main database tables:
TableDescription
usersUser accounts (patients, doctors, admins)
patientsPatient profiles and medical information
doctorsDoctor profiles and specializations
appointmentsMedical appointment records
schedulesDoctor availability and working hours
medical_recordsPatient medical history

Production Deployment

Environment Configuration

For production deployments, update your environment variables:
NODE_ENV=production
PORT=8080

# Use production database credentials
DB_HOST=your-production-db.example.com
DB_SSL=true

# Strong JWT secret (min 64 characters)
JWT_SECRET=use_a_cryptographically_secure_random_string_here

# Stricter rate limits for production
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX_REQUESTS=60
Always enable SSL/TLS for database connections in production and use environment-specific secrets management (AWS Secrets Manager, HashiCorp Vault, etc.).

Build and Run

1

Build the application

npm run build
2

Run migrations

NODE_ENV=production npm run migration:run
3

Start production server

npm start
Or use a process manager like PM2:
pm2 start dist/server.js --name saludya-api
pm2 save
pm2 startup

Docker Deployment

SaludYa API includes a Dockerfile for containerized deployments:
# Build the Docker image
docker build -t saludya-api:latest .

# Run with docker-compose
docker-compose up -d
The docker-compose.yml includes the API server, PostgreSQL database, and Redis for caching.

Health Checks

Verify your deployment is healthy:
curl http://localhost:3000/health
Expected response:
{
  "status": "healthy",
  "timestamp": "2026-03-06T10:30:00.000Z",
  "database": "connected",
  "uptime": 3600
}

Common Issues

Problem: Cannot connect to PostgreSQL database.Solutions:
  • Verify PostgreSQL is running: pg_isready
  • Check database credentials in .env
  • Ensure the database exists: psql -l
  • Check firewall settings and network connectivity
Problem: Error: listen EADDRINUSE: address already in use :::3000Solutions:
  • Change the PORT in your .env file
  • Stop the process using port 3000: lsof -ti:3000 | xargs kill
Problem: Database migrations fail to run.Solutions:
  • Ensure database is empty or at the correct version
  • Check migration files for syntax errors
  • Reset database: npm run migration:revert then npm run migration:run

Next Steps

Making Requests

Learn how to make API requests with pagination and filtering

Authentication

Set up authentication for secure API access

API Reference

Explore all available endpoints

Rate Limits

Understand rate limiting and best practices

Build docs developers (and LLMs) love