Deploying a Node.js App with PostgreSQL on Seenode

This post was sponsored by Seenode. Some links are partner links: if you sign up through them, we may earn a commission.

I have 506 articles on dev.to. The API will tell me that one of them has 27,817 views. It will not tell me how many it had last Tuesday.

That gap is what this post is about. A while ago I built devto_devdash, a terminal dashboard that shows my most liked, viewed and commented posts. It was fun, but it had two problems: it only ran on my laptop, and it had no memory. Every refresh was a fresh look at the present, and the past was thrown away.

So I rebuilt it as a small web app, devto-pulse, with Node.js, Express and PostgreSQL. Every few hours it takes a snapshot of every article's stats, Postgres keeps all of them, and the dashboard turns those snapshots into "what's trending this week" and growth charts.

Then I deployed it on Seenode, a platform that runs Node.js, Python, Go and Elixir apps from Git or Docker images, with managed PostgreSQL and MySQL next to them. This post covers the whole thing: the data model, the code that matters, the deploy step by step, what it costs, and what I liked about the platform.

App Overview: A dev.to Stats Tracker

Two pieces on the hosting side:

Piece What it does Runs as on Seenode
Web Express dashboard and JSON API, plus a sync loop every 3 hours Web service
Database Articles, snapshots, and a log of every sync run Managed PostgreSQL

The app can also run the sync as a separate background worker (npm run worker), which is the cleaner design once traffic matters: a web request never waits on a third-party API, and a deploy of the web service never interrupts a sync. For a personal dashboard, one service with INPROCESS_SYNC=true is enough, so that's what I deployed.

Database Schema for Stats History

The obvious design is a single articles table with views, reactions and comments columns, updated on every sync. That is exactly what dev.to already gives you, and it's why you can't answer "what grew this week".

Instead, articles holds the things that rarely change, and every sync appends one row per article to article_snapshots:

CREATE TABLE sync_runs (
  id             BIGSERIAL PRIMARY KEY,
  started_at     TIMESTAMPTZ NOT NULL DEFAULT now(),
  finished_at    TIMESTAMPTZ,
  status         TEXT NOT NULL DEFAULT 'running',  -- running | ok | error
  articles_count INT,
  error          TEXT
);

CREATE TABLE articles (
  id           BIGINT PRIMARY KEY,               -- dev.to article id
  title        TEXT NOT NULL,
  url          TEXT NOT NULL,
  published_at TIMESTAMPTZ,
  tags         TEXT[] NOT NULL DEFAULT '{}',
  updated_at   TIMESTAMPTZ NOT NULL DEFAULT now()
);

CREATE TABLE article_snapshots (
  id          BIGSERIAL PRIMARY KEY,
  sync_run_id BIGINT NOT NULL REFERENCES sync_runs(id) ON DELETE CASCADE,
  article_id  BIGINT NOT NULL REFERENCES articles(id) ON DELETE CASCADE,
  taken_at    TIMESTAMPTZ NOT NULL DEFAULT now(),
  views       INT NOT NULL,
  reactions   INT NOT NULL,
  comments    INT NOT NULL
);

CREATE INDEX article_snapshots_article_taken_idx
  ON article_snapshots (article_id, taken_at DESC);

Two decisions worth calling out:

  • sync_runs is a first-class table. Every sync, successful or not, leaves a row with its status and error. The dashboard gets a "last synced" line for free, and on a hosting platform it doubles as a cheap reliability log: if the sync silently stopped on Thursday, the gap is right there.
  • Snapshots point at a run, not just a timestamp. "The current state" becomes "every snapshot from the latest successful run", which is one indexed lookup instead of a scan over the whole history.

Is it a lot of rows? For 506 articles synced every 3 hours, it's about 4,000 rows a day, roughly 1.5 million a year, each a handful of integers. The 1 GB database plan has years of headroom.

Fetching Stats from the dev.to API

The Go version of this tool taught me that dev.to answers bursts with 429 Too Many Requests. The Node port keeps the same fix: retry with a growing delay plus random jitter, so concurrent callers don't retry in lockstep. Trimmed slightly:

async function fetchPage(apiKey, page) {
  const url = `https://dev.to/api/articles/me?per_page=100&page=${page}`;
  let lastErr;

  for (let attempt = 1; attempt <= 8; attempt++) {
    if (attempt > 1) await sleep((attempt - 1) * 700 + Math.random() * 500);

    const res = await fetch(url, {
      headers: { 'api-key': apiKey, Accept: 'application/vnd.forem.api-v1+json' },
      signal: AbortSignal.timeout(15_000),
    });

    if (res.status === 429) { lastErr = new Error('rate limited'); continue; }
    if (!res.ok) throw new Error(`dev.to API returned ${res.status}`);
    return res.json();
  }
  throw new Error(`giving up after 8 attempts: ${lastErr?.message}`);
}

Only 429 and network errors are retried. A 401 means the API key is wrong, and retrying it eight times just delays the bad news.

Each sync then writes every article and every snapshot in one transaction. If the API call fails halfway or the database connection drops mid-write, the run is marked error and no half-written snapshot set is left behind to make one article look like it lost 2,000 views.

Querying Weekly Growth with PostgreSQL

"Trending" is the reason Postgres is here. For each article, take the first and last snapshot inside the window and subtract:

WITH win AS (
  SELECT s.* FROM article_snapshots s
  JOIN sync_runs r ON r.id = s.sync_run_id
  WHERE r.status = 'ok' AND s.taken_at >= now() - make_interval(days => $1)
),
first AS (SELECT DISTINCT ON (article_id) * FROM win ORDER BY article_id, taken_at ASC),
last  AS (SELECT DISTINCT ON (article_id) * FROM win ORDER BY article_id, taken_at DESC)
SELECT a.title, a.url,
       l.views,
       l.views - f.views         AS views_gained,
       l.reactions - f.reactions AS reactions_gained
FROM last l
JOIN first f USING (article_id)
JOIN articles a ON a.id = l.article_id
ORDER BY views_gained DESC
LIMIT 10;

DISTINCT ON is one of my favorite PostgreSQL-only features: "give me one row per article_id, and make it the one that sorts first". It replaces a window function and a subquery with a single line.

Running the App Locally

Before involving any platform, get it working on your machine. You need Node.js 20+, Docker, and a dev.to API key from dev.to/settings/extensions. From the project folder:

docker run -d --name devto-pulse-pg \
  -e POSTGRES_USER=pulse -e POSTGRES_PASSWORD=pulse -e POSTGRES_DB=pulse \
  -p 127.0.0.1:55434:5432 postgres:16-alpine

cp .env.example .env        # set DEVTO_API_KEY
npm install
npm run dev:migrate
npm run dev:sync            # [sync] run 1: 506 published articles
npm run dev                 # http://localhost:3000

The first local sync pulled 506 published articles in about three and a half seconds: six paginated requests of up to 100 articles each.

Deploying on Seenode

Seenode's sidebar lists everything you can run: Static site, Web, Worker, Private Service, Database and Agent. New accounts get a 7-day free trial with no credit card, and once it's active every create button reads "Start 7 day free trial".

Step 1: Create the PostgreSQL Database

Start with the database, because its connection string is the first thing the web service needs.

Database → Create asks for three things: a name, the engine and a version. MySQL 8.4 is preselected; switch it to PostgreSQL. Two versions were offered when I tested: 18.6 and 16.15. I picked 18.6.

The database was Live about five seconds after I clicked create. The default Basic plan gives you 1 GB of storage and 20 connections in eu-central (Frankfurt).

The Connection tab shows the details in three formats (Parameters, Flag for psql, and URI), plus a Reset password button. Two things worth knowing:

  • Copy the password when it's shown. For security, Seenode shows a new password once, right after a reset. The URI view uses a <password> placeholder, so swap the real password in before pasting the URI into your app.
  • Connections are encrypted with TLS 1.3. The certificate is signed by a per-project CA, so in Node you connect with ssl: { rejectUnauthorized: false }:
const useSsl = process.env.PGSSL === 'true';

export const pool = new pg.Pool({
  connectionString: process.env.DATABASE_URL,
  ssl: useSsl ? { rejectUnauthorized: false } : undefined,
  connectionTimeoutMillis: 10_000,
});

Seenode's URI doesn't include an sslmode parameter, which is good: in node-postgres, SSL settings in the connection string override the ssl option. devto-pulse strips sslmode from the URL when PGSSL=true anyway, in case you paste a URI from somewhere else.

Backups are on by default: a daily backup at a fixed time, the last 7 kept, and up to 3 manual "Backup now" snapshots a day on the Basic plan.

Step 2: Create the Web Service from GitHub

Web → Create asks for the source first: a Git repository (GitHub or GitLab) or a Docker image from Docker Hub, GHCR, GitLab or a custom registry. devto-pulse deploys straight from Git with no Dockerfile.

Seenode read the repository and filled in the branch (main), the latest commit (you can pin a specific commit or tag instead of always deploying the branch head) and Node 24 as the runtime.

Public repositories work straight away. For a private one, use Configure Repositories on GitHub in the repo picker to install Seenode's GitHub app and give it access to just that repo.

The build settings take plain shell commands that run from the repository root:

Setting Value Why
Build command npm ci Installs exactly what's in package-lock.json. There's nothing to compile.
Start command npm start Runs node src/server.js.
Root directory (empty) The app lives at the repo root.
Port 80 The default. The form says the app must listen on 0.0.0.0 on this port.

Then the environment variables. Each one has a Secret checkbox, and there's an Import from .env link if you'd rather paste a file:

Variable Value Secret
PORT 80
NODE_ENV production
PGSSL true
INPROCESS_SYNC true
SYNC_INTERVAL_MINUTES 180
DEVTO_API_KEY Your dev.to API key ✓
DATABASE_URL The URI from Step 1, with the real password ✓
DASHBOARD_USER / DASHBOARD_PASSWORD Optional HTTP basic auth ✓

The dashboard login is optional. dev.to page views are normally private, so set both if you don't want your stats public. I left mine open.

There are also two Pre-fill with AI buttons (one for build settings, one for env vars). I filled everything by hand so I'd know exactly what went in.

Step 3: Deploy the App and Read the Logs

The build was quick. Seenode builds a container image with BuildKit, uploads it in a couple of seconds, and starts it.

Then npm start, and my first attempt didn't come up:

That one was on me. server.js ran migrations first and only then called app.listen(). With a wrong DATABASE_URL, it never started listening, so Seenode's health check correctly marked the deploy as failed. Tip: the Logs tab opens in Live tail; pick a time range like Last 1 day to see the runtime output from earlier attempts.

The fix was to make startup boring and loud: listen immediately, then connect to Postgres with a timeout, retrying and logging each attempt:

const server = app.listen(port, '0.0.0.0', () =>
  console.log(`[web] listening on 0.0.0.0:${port}`));

async function prepareDatabase() {
  for (let attempt = 1; ; attempt++) {
    try {
      console.log(`[db] connecting (attempt ${attempt})`);
      await migrate();
      console.log('[db] ready');
      if (process.env.INPROCESS_SYNC === 'true') startSyncLoop();
      return;
    } catch (err) {
      console.error(`[db] not ready: ${err.message}`);
      await sleep(Math.min(attempt * 5_000, 30_000));
    }
  }
}
prepareDatabase();

/healthz still checks the database (it returns 503 until SELECT 1 works), so "process up, database down" is visible instead of looking green.

After pushing the fix I used Deploy → Deploy latest commit. The service went Live, and searching the logs for [db] showed exactly what was wrong:

password authentication failed: I'd pasted the URI without the real password (see the tip in Step 1). I reset the database password, pasted the fresh URI into the service's Envs tab, and clicked Apply changes. Env changes show up as a "pending changes" bar, and applying them restarts the app.

Step 4: Verify the Live App

[db] host=up-de-fra1-postgresql-4.db.run-on-seenode.com ssl=true
[db] connecting (attempt 1)
[web] listening on 0.0.0.0:80
[migrate] applied 001_init.sql
[db] ready
[sync] loop every 180 min
[sync] run 1: 506 published articles

Three seconds from "listening" to 506 articles snapshotted in a managed Postgres. The service got a default *.seenode.app domain with a Let's Encrypt certificate already active, and custom domains are one button away under the Domains tab.

curl -s https://devto-pulse.seenode.app/healthz
# {"ok":true}

curl -s https://devto-pulse.seenode.app/api/summary
# {"articles":506,"views":636293,"reactions":10936,"comments":941, ...}

The Sync runs table at the bottom of the dashboard is the reliability log mentioned earlier. Every row is a sync that ran on Seenode:

Pricing

Seenode is prepaid: you buy credit, and it's deducted daily for whatever is running. Both pieces of this app fit on the smallest plans:

Resource Plan Size Price
Web service Basic 0.25 vCPU, 512 MB, 1 replica $4/month
PostgreSQL Basic 1 GB storage, 20 connections, 7 backups kept $4/month
Total $8/month

Web replicas are billed per replica at the plan price, so scaling the web service to two instances makes it $8 for the web side alone. My testing ran on the free trial, so I didn't spend any credit.

When you do top up, two details from the payment dialog:

  • The minimum top-up is $10. Payments go through Stripe, with PayPal, Google Pay and Apple Pay listed.
  • "Low credit prevention". An optional auto top-up ($25 when you have under seven days of credit left), so a production app never runs dry. Toggle it to suit your project.

Turning On Auto Deploy

Auto deploy is off by default. Pushing to main doesn't redeploy until you switch on Auto deploy in the service's Settings, or use Deploy → Deploy latest commit. Having it off means nothing ships by accident, and it's one toggle to turn on once you trust your pipeline.

What I didn't get to in this round: the separate Worker service type, custom domains, scaling past one replica, the "Fix with AI" button on failed deploys, and Seenode's hosted MCP server for deploying from an AI coding agent.

Deployment Checklist

If you're deploying something similar, on Seenode or anywhere else:

  • The app reads all config from env vars and nothing else.
  • It listens before it connects to anything, and logs every startup step.
  • Database connections have a timeout, and /healthz checks the database, not just the process.
  • Migrations run on boot and are safe to run twice.
  • Third-party API calls retry 429s with backoff and jitter, and fail fast on everything else.
  • Your DATABASE_URL has the real password in it, not a <password> placeholder.

What Worked Well on Seenode

  • A database in seconds. PostgreSQL 18.6 was live about five seconds after I clicked create, with daily backups already scheduled and a one-click "Backup now".
  • A free trial with no card. Seven days to deploy a real app and a real database before paying anything.
  • It read the repo for me. Branch, latest commit and the Node 24 runtime were filled in automatically, and I could pin any commit or tag.
  • Sensible env var handling. A Secret checkbox per variable, masked values afterwards, Import from .env, and a pending-changes bar that applies everything with one restart.
  • HTTPS without thinking about it. A *.seenode.app domain with a Let's Encrypt certificate was active before my first request, and custom domains are one button away.
  • Searchable logs with history. Filtering the runtime logs by [db] over the last day is how I found and fixed my connection problem in minutes.
  • A Deploy menu that covers the basics. Deploy the latest commit, a specific commit, or just restart, all from one dropdown.
  • Fast builds. The image built and uploaded in seconds, so the edit-deploy loop never got in the way.
  • Pricing that fits side projects. $4 for the web service and $4 for Postgres: a full app with a managed database for $8 a month.
  • Responsive people. When my account needed the trial enabled, Seenode sorted it out within a day.

Summary

The dev.to API tells you where your posts are. A table of snapshots tells you where they're going. That one design change, appending instead of overwriting, is what turned a terminal toy into something worth hosting, and it works for almost any third-party number you care about: GitHub stars, npm downloads, Stripe MRR.

Seenode took it from a GitHub repo to a public HTTPS URL with a managed Postgres behind it for $8 a month, and most of my time went into the app rather than the platform. If you have a side project, a small API or an internal dashboard that needs a database next to it, Seenode is an easy place to get it live. Point something like this at your own dev.to key, and in a week you'll know which of your posts are still finding readers.