Files
ins-landing-page/docs/superpowers/plans/2026-12-01-ins-landing-page.md

3.9 KiB

INS Landing Page Implementation Plan

For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (- [ ]) syntax for tracking.

Goal: One INS landing page with a lead form that stores submissions in SQLite.

Architecture: A single server.js (Node 22 built-ins only) serves public/index.html and handles POST /api/leads, inserting into a SQLite file. Shipped as a Docker image for k8s with the DB on a volume, 1 replica.

Tech Stack: Node 22 (node:http, node:sqlite, node:test), plain HTML/CSS/JS, Docker.

Spec: docs/superpowers/specs/2026-12-01-ins-landing-page-design.md

Global Constraints

  • Zero npm dependencies.
  • Node >= 22.13 (node:sqlite without a flag).
  • DB path from env DB_PATH, default ./data/leads.db; port from PORT, default 3000.
  • Copy only facts confirmed on infinitynetworks.com.my; no "0" counters.

Review Focus

  • Non-JSON or oversized body: respond 400 / 413, never crash the process. (Task 1 test)
  • Invalid email format: 400 with an error message. (Task 1 test)
  • Over-long fields: reject anything above 200 chars (message 2000). (Task 1 test)
  • Server error on save: the page shows a visible error, not a fake success. (Task 2 manual browser check)
  • HTML in fields is stored as text and never rendered (no admin UI, so no XSS surface now).

Task 1: Lead API + storage

Files:

  • Create: server.js, server.test.js, package.json (scripts only: start, test)

Interfaces:

  • Produces: createServer(dbPath: string) => http.Server exported from server.js; module runs listen(PORT) only when executed directly.

  • POST /api/leads JSON {name, email, phone, company, industry?, message?, website?, utm_source?, utm_medium?, utm_campaign?} → 201 {ok:true} | 400 {error} | 413 {error}. Honeypot website non-empty → 200 {ok:true}, nothing stored.

  • Table leads(id INTEGER PK, created_at TEXT DEFAULT CURRENT_TIMESTAMP, name, email, phone, company, industry, message, referrer, utm_source, utm_medium, utm_campaign).

  • Step 1: Write failing tests in server.test.js using a temp DB path and port 0:

    • valid lead → 201, row count 1, stored fields match
    • missing phone → 400, row count 0
    • invalid email "abc" → 400
    • name of 201 chars → 400
    • body "not json" → 400; body > 10 KB → 413
    • honeypot website: "x" → 200, row count 0
  • Step 2: node --test — expect FAIL (module missing).

  • Step 3: Implement server.js. GET / serves public/index.html; other paths 404.

  • Step 4: node --test — expect all PASS.

  • Step 5: Commit feat: lead capture API with SQLite storage.

Task 2: Landing page

Files:

  • Create: public/index.html, public/logo.png (downloaded from the source site)

Interfaces:

  • Consumes: POST /api/leads from Task 1. Sends UTM params from location.search.

  • Step 1: Build the page: hero, about/track record, solutions by industry, Guest Wi-Fi, OneBox, IT services, lead form, contact footer. Responsive, accessible labels.

  • Step 2: Verify in a browser with playwright-cli against npm start: empty submit shows required-field errors; valid submit shows success and a row appears in the DB; stop server mid-session and submit → visible error. Screenshot desktop + mobile.

  • Step 3: Commit feat: INS landing page with lead form.

Task 3: Docker + README

Files:

  • Create: Dockerfile, .dockerignore, README.md

  • Step 1: Dockerfile from node:22-alpine, ENV DB_PATH=/data/leads.db, VOLUME /data, non-root user, EXPOSE 3000.

  • Step 2: README: run, test, deploy notes (1 replica + PVC at /data), CSV export command.

  • Step 3: docker build then run with a volume, curl a lead, confirm it persists after container restart.

  • Step 4: Commit chore: Dockerfile and README.