Build & Run Guide

Complete guide for setting up and running the UBI Strapi Provider Middleware.

Prerequisites: Complete Prerequisites first.

Build and Deploy Steps

A. Running Locally without Docker

Clone Repository

# Clone the Repository
git clone https://github.com/PSMRI/ubi-strapi-provider-mw.git
cd ubi-strapi-provider-mw

# Check out the main branch
git checkout main

Install Dependencies

# Install dependencies
npm install

Optional - Set up Git hooks

Setup External Services

Strapi CMS (Required)

This application requires a running Strapi CMS instance for benefits catalog management.

  1. Clone: https://github.com/PSMRI/ubi-strapi-provider

  2. Follow its setup instructions

  3. Start Strapi (typically runs on port 1337)

  4. Note your STRAPI_URL and obtain STRAPI_TOKEN

Database Setup

Choose one of the following options:

Option A: Docker Container

Option B: Local PostgreSQL Create database manually after installing PostgreSQL locally.

Create / Update .env

Copy .env.sample to .env and update with your values:

Initialize Database

Running in Dev Mode

The backend will be available at: 👉 http://localhost:7000

Access Points:

  • Application: http://localhost:7000

  • API Documentation: http://localhost:7000/documentation

  • Health Check: http://localhost:7000

Running in Production Mode

B. Running with Docker

Create / Update .env

Copy .env.sample to .env and update with your values:

For all available environment variables, see Environment Variables.

Example docker-compose.yml

Create a docker-compose.yml file in your project root:

Run with Docker Compose

More about docker-compose

The docker-compose.yml provisions the following services:

  • PostgreSQL (port 5432)

  • UBI Provider API (port 7000)

Verify Services

  • Application: http://localhost:7000

  • API Documentation: http://localhost:7000/documentation

  • Database: localhost:5432

View Logs

Database Operations (Development)

These commands are for ongoing development work:

For more Prisma commands, see the official Prisma documentation.

Requirements & Troubleshooting

System Requirements

  • Node.js 20+ environment

  • PostgreSQL 14+ database

  • Strapi CMS instance

  • HTTPS for production

Common Issues

Setup Issues

  • Database migration failed: Verify PostgreSQL is running and DATABASE_URL is correct

  • Strapi connection errors: Ensure Strapi CMS is running before starting this application

  • Environment configuration: Check all required variables are set in .env file

Runtime Issues

  • Port conflicts: Change PORT environment variable or stop conflicting services

  • Application crashes on startup: Check environment variables in Environment Variables

  • Database connection errors: Ensure PostgreSQL is running and accessible

  • File upload failures: Check storage permissions (local) or AWS credentials (S3)

Health Check

Last updated