Developer Docs

Imaging Subgraph โ€” Integration Guide

Overview

The imaging service is a Node.js worker dedicated exclusively to processing images on behalf of the media subgraph. Because image modification (especially AI model processing) blocks the Node.js event loop, it is decoupled completely from the GraphQL Gateway.

Architecture at a Glance

Component Technology Port Access
Framework NestJS (TCP Microservice) 30020 Read-only from DB
Engine sharp, @imgly/background-removal-node โ€” Internal Network

Capabilities

1. Model Caching & AI Operations

Uses eager warm-up and Dockerfile pre-baking so the machine-learning model (for background removal) is fully loaded into memory before processing its first HTTP request, eliminating cold-start penalties for the first user.

2. Shadow Generation

Generates mathematically adaptive drop-shadows dynamically using the sharp C-bindings, maintaining full alpha transparency.

3. EXIF Extraction & Quality Optimization

Works in tandem with the Media Intelligence architecture to strip sensitive location and device data from uploaded images before they become publicly viewable, protecting Visitor and Malet Owner privacy.


Strategy Adapter

The central media service orchestrates jobs by sending TCP events over to imaging using a strategy block pattern:

  • RemoteStrategy: Sends jobs over TCP port 30020.
  • LocalStrategy (Planned): An upcoming feature allowing worker threads.

Development Verification

There is a standalone manual script bundled into the application to verify transformations without hitting GraphQL.

npx ts-node apps/imaging/scripts/manual/test-imaging.ts