Skip to content

Engage DEV API

1. Application Overview

The Engage DEV API provides backend services for the Surefy Engage web application.

Property Value
Application Engage API
Environment DEV
API Domain https://engagedevapi.surefy.co
Container Name engage-api
Container Port 5000
Host Port 5000
Framework Node.js / Express 5.2.1
Database PostgreSQL
Monitoring Prometheus, Grafana, Loki, Blackbox Exporter

2. API Access

Base URL:

https://engagedevapi.surefy.co

The API is exposed through Nginx reverse proxy and forwarded to the backend container on port 5000.

3. Application Architecture

flowchart TD
    U["User / Client"] --> W["Engage Web"]
    W --> N["Nginx Reverse Proxy"]
    N --> API["Engage API"]
    API --> DB["PostgreSQL"]
    API --> R["Redis"]
    API --> AUTH["Devauth Authentication"]

This is a logical architecture overview. Verify the actual runtime connections before treating every dependency as confirmed.

4. Backend Container

Property Value
Container engage-api
Host Port 5000
Container Port 5000
Image Registry AWS ECR
Image Repository surefy
Service Engage Backend DEV

Check container status

sudo docker ps --filter name=engage-api

View application logs

sudo docker logs --tail 100 engage-api

Follow live logs

sudo docker logs -f engage-api

Check backend port

curl -i http://127.0.0.1:5000/

A 404 response from the root path does not necessarily mean the backend is down.

5. Health Check

Current Status

The following endpoints were tested on the DEV API:

Endpoint Current HTTP Status
/health 404
/healthz 404
/api/health 404
/ 404

The Express application responded with Cannot GET /health when tested directly on port 5000.

Conclusion: A dedicated health endpoint has not yet been confirmed or implemented.

Implement the following endpoint in the Express application:

GET https://engagedevapi.surefy.co/health

Expected HTTP status:

200 OK

Expected response:

{
  "status": "ok",
  "service": "engage-api",
  "environment": "DEV"
}

The endpoint should return HTTP 200 when the API process is healthy.

Do not mark this endpoint as operational until the backend change has been deployed and tested.

6. Prometheus Monitoring

After implementing and verifying /health, add the following target to the Blackbox Exporter configuration:

- https://engagedevapi.surefy.co/health

API Availability

probe_success{instance="https://engagedevapi.surefy.co/health"}

Expected values:

  • 1 — Health endpoint responds successfully.
  • 0 — Health check failed.

API Response Time

probe_duration_seconds{instance="https://engagedevapi.surefy.co/health"}

HTTP Status Code

probe_http_status_code{instance="https://engagedevapi.surefy.co/health"}

SSL Certificate Expiry

(
  probe_ssl_earliest_cert_expiry{
    instance="https://engagedevapi.surefy.co/health"
  } - time()
) / 86400

7. Loki Application Logs

View Engage API Logs

{container="engage-api"}

Application Errors

{container="engage-api"}
|~ "(?i)error|exception|failed|timeout"

PostgreSQL Connection Errors

{container="engage-api"}
|~ "(?i)postgres|postgresql|database|knex|ETIMEDOUT|ECONNREFUSED"

Redis Connection Errors

{container="engage-api"}
|~ "(?i)redis|ETIMEDOUT|ECONNREFUSED"

8. Troubleshooting

Issue Troubleshooting
API domain unavailable Check DNS, TLS and Nginx
HTTP 404 Verify the requested API route
HTTP 502 Check Nginx upstream and container status
API connection failure Check port 5000 and Docker container
PostgreSQL connection failure Check database connectivity and application logs
Redis connection failure Check Redis connectivity and application logs
Health endpoint unavailable Verify /health implementation and deployment

Useful commands

Check container:

sudo docker ps --filter name=engage-api

Check container logs:

sudo docker logs --tail 100 engage-api

Check local API port:

curl -i http://127.0.0.1:5000/health

Check public API:

curl -i https://engagedevapi.surefy.co/health

10. Operational Notes

  • This document describes the DEV environment.
  • The API runs in the engage-api Docker container.
  • The backend listens on port 5000.
  • A dedicated health endpoint is planned, not yet verified.
  • Update the monitoring configuration after the health endpoint is deployed.
  • Never store database passwords, API keys, tokens or other secrets in documentation.