A blazing fast, standalone Dynamic Open Graph (OG) Image Generation microservice built for Neuralwire. Generates branded, high-resolution 1200 Γ 630 social preview cards on-the-fly featuring an Editorial Cyberpunk / Technical Dark Mode visual identity.
- Zero-Chromium Architecture: Powered by Satori (JSX to SVG flexbox layout) and @resvg/resvg-js (Rust-based SVG-to-PNG rasterizer). Renders cards in ~15β40ms with minimal memory footprint.
- Embedded Static Fonts: Preloads and caches Newsreader (Editorial Serif), JetBrains Mono (Technical Monospace), and Inter (Modern Sans) directly in memory for sub-millisecond layout calculations without external network dependencies.
- Production-Grade HTTP Caching: Deterministic SHA-256
ETagvalidation with304 Not Modifiedsupport,Cache-Control: public, max-age=86400, s-maxage=604800, stale-while-revalidate=86400. - Interactive Studio Playground: Built-in visual playground UI at
/with real-time side-by-side previews, quick presets, character limit counters, copyable meta tags, and instant PNG downloads. - Reliability & Security: Zod input validation, XSS and ASCII control character sanitization, parameter length constraints, and in-memory sliding window rate limiting.
- Multi-Runtime Ready: Fully compatible with Node.js 20+, Bun, and multi-stage containerized deployments.
| Component | Specification |
|---|---|
| Canvas Size | Exactly 1200 Γ 630 pixels (1.91:1 standard social aspect ratio) |
| Palette | Background #0A0E17, Cyber Cyan #22D3EE, Emerald Green #10B981, Slate #94A3B8, White #F8FAFC |
| Header | NEURALWIRE logo mark with pulsing cyan glow dot + live formatted issue date [DD MMM YYYY] |
| Category Pill | Monospace uppercase tag e.g. // RESEARCH & SYSTEMS, // HARDWARE & CHIPS |
| Headline | Newsreader Editorial Serif auto-scaled to max 3 lines with graceful clamp |
| Footer Bar | Source attribution (SRC // ...), Read time (TIME // X MIN READ), Impact Score badge (IMPACT SCORE: 94/100), domain watermark (βΊ neuralwire.info) |
# Clone the repository
git clone https://github.com/neuralwire-media/og.git
cd og
# Install dependencies
npm install
# Start development server with live reload
npm run devVisit http://localhost:3000 in your browser to open the interactive studio playground.
# Install dependencies
bun install
# Run server
bun run src/index.ts# Build and run with Docker Compose
docker compose up --build -d
# Inspect health status
curl http://localhost:3000/api/healthGenerates a 1200x630 PNG preview card.
| Parameter | Type | Required | Default | Constraints / Description |
|---|---|---|---|---|
title |
string |
Yes | β | Headline text (max 150 characters, auto-sanitized). |
category |
string |
No | AI & Systems |
Monospace category pill (max 50 characters). |
source |
string |
No | Neuralwire Editorial |
Attribution badge text (max 60 characters). |
score |
number |
No | None | Impact score 0β100 (renders emerald/cyan/amber badge). |
read_time |
string |
No | 3 min |
Estimated reading duration (e.g. 4 min, 10 min). |
HTTP/1.1 200 OK
Content-Type: image/png
Content-Length: 217718
Cache-Control: public, max-age=86400, s-maxage=604800, stale-while-revalidate=86400
ETag: "fac2a4f2841c458953af6ac0"
X-Content-Type-Options: nosniff
Server-Timing: render;dur=22
X-RateLimit-Limit: 120
X-RateLimit-Remaining: 119# Minimal request
curl "http://localhost:3000/api/og?title=Frontier%20AI%20Reasoning%20Benchmarks" -o card.png
# Full parameter request
curl "http://localhost:3000/api/og?title=Autonomous%20Agent%20Swarms%3A%20Emergence%20of%20Collective%20Intelligence&category=Research&source=MIT%20Technology%20Review&score=94&read_time=4%20min" -o preview.pngReturns microservice operational status, uptime, and timestamp.
{
"status": "ok",
"service": "og",
"uptime": 142,
"timestamp": "2026-09-17T12:00:00.000Z"
}Interactive web playground featuring:
- Real-time side-by-side card rendering.
- Quick preset buttons (Agent Swarms, Neuromorphic, Frontier Models, Decentralized AI).
- Form inputs for title, category, source, score, and read time.
- Direct URL generator, HTML
<meta>tag generator, and Markdown code snippets. - One-click PNG image download.
<meta property="og:title" content="Autonomous Agent Swarms: Emergence of Collective Intelligence" />
<meta property="og:type" content="article" />
<meta property="og:image" content="https://og.neuralwire.info/api/og?title=Autonomous%20Agent%20Swarms%3A%20Emergence%20of%20Collective%20Intelligence&category=Research&source=MIT%20Technology%20Review&score=94&read_time=4%20min" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta property="og:image:type" content="image/png" />
<!-- Twitter / X Card -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content="https://og.neuralwire.info/api/og?title=Autonomous%20Agent%20Swarms%3A%20Emergence%20of%20Collective%20Intelligence&category=Research&source=MIT%20Technology%20Review&score=94&read_time=4%20min" />export function generateMetadata({ article }: { article: Article }): Metadata {
const ogUrl = new URL('https://og.neuralwire.info/api/og');
ogUrl.searchParams.set('title', article.title);
ogUrl.searchParams.set('category', article.category);
ogUrl.searchParams.set('source', article.source);
if (article.impactScore) ogUrl.searchParams.set('score', String(article.impactScore));
if (article.readingTime) ogUrl.searchParams.set('read_time', article.readingTime);
return {
title: article.title,
openGraph: {
images: [
{
url: ogUrl.toString(),
width: 1200,
height: 630,
type: 'image/png',
},
],
},
};
}The repository includes comprehensive unit and integration tests powered by Vitest:
# Run test suite
npm run test
# Run tests in watch mode
npm run test:watch
# Run TypeScript type check
npm run typecheckTest coverage includes:
- Engine Tests: Font loading, deterministic ETag generation, 1200x630 dimension verification, PNG binary magic header verification (
0x89504E470D0A1A0A), dynamic score color tiers. - Sanitization Tests: Control character stripping, HTML/XSS injection neutralization, whitespace normalization, parameter length bounds, score boundary clamping.
- Route Tests:
GET /api/health,GET /api/healthz,GET /api/og(status 200, caching headers, 304 Not Modified, 400 validation errors),GET /playground UI, 404 handling, and rate limiter headers.
The provided Dockerfile utilizes a two-stage build:
- Builder Stage (
node:22-alpine): Installs build dependencies, compiles TypeScript todist/, and prunes dev packages. - Runner Stage (
node:22-alpine): Runs as non-root usernodejs(uid: 10001), containing only production artifacts and font assets. Image footprint is < 150MB.
# Build standalone Docker image
docker build -t neuralwire/og:latest .
# Run container
docker run -d -p 3000:3000 --name neuralwire-og neuralwire/og:latestThe repository includes GitHub Actions CI/CD workflows tailored to the Main Branch Protection ruleset:
- Intelligent Path Filtering (
dorny/paths-filter@v3): Detects modifications to code (src/**,assets/**,tests/**, dependencies, configs) vs Docker assets vs documentation. Documentation-only updates bypass resource-heavy testing suites automatically. - Type Checking: Runs TypeScript verification with
tsc --noEmit. - Test Matrix: Executes Vitest suite across Node.js
20.xand22.x. - Docker Validation: Builds container image and runs container healthcheck test against
/api/health. - Strict Status Check Gatekeeper (
CI / Required Status Checks): Evaluates all sub-jobs and provides a unified required check compatible with GitHub'sstrict_required_status_checks_policy: true.
- Container Registry Publishing: Automatically builds and pushes multi-architecture container images (
linux/amd64,linux/arm64) to GitHub Container Registry (ghcr.io/neuralwire-media/og) upon release or merge tomain. - Automated VPS Deployment (SSH): Connects to the host using organization secrets (
VPS_HOST,VPS_USERNAME,VPS_SSH_KEY, and optionalVPS_PORT), pulls the fresh image, gracefully replaces the running containerneuralwire-og, and validates the/api/healthcheck endpoint.
neuralwire/og/
βββ assets/
β βββ fonts/
β βββ Newsreader-SemiBold.ttf # Editorial Headline Serif
β βββ JetBrainsMono-Regular.ttf # Technical Monospace
β βββ JetBrainsMono-Bold.ttf # Monospace Bold
β βββ Inter-SemiBold.ttf # Modern Sans SemiBold
β βββ Inter-Bold.ttf # Modern Sans Bold
βββ src/
β βββ index.ts # Server bootstrap & process lifecycle
β βββ app.ts # Hono application pipeline
β βββ engine/
β β βββ fonts.ts # In-memory font loader & cache
β β βββ template.tsx # Satori JSX 1200x630 Cyberpunk Template
β β βββ renderer.ts # Satori + Resvg pipeline with ETag hashing
β βββ routes/
β β βββ og.ts # GET /api/og route with caching & validation
β β βββ health.ts # GET /api/health and /api/healthz
β β βββ playground.ts # GET / Studio Playground UI
β βββ middleware/
β β βββ rate-limit.ts # Sliding window rate limiter
β β βββ security.ts # Security & timing headers
β βββ schemas/
β β βββ og-query.ts # Zod query schema & sanitization
β βββ types/
β βββ index.ts # TypeScript interfaces
βββ tests/
β βββ engine.test.ts # Unit tests for rendering & fonts
β βββ routes.test.ts # Route integration tests & caching
β βββ sanitization.test.ts # XSS, length & security tests
βββ Dockerfile # Multi-stage production container build
βββ compose.yml # Docker Compose service definition
βββ .dockerignore
βββ .gitignore
βββ package.json
βββ tsconfig.json
βββ vitest.config.ts
βββ README.md
MIT License Β© 2026 Neuralwire Media. All rights reserved.