Radar Verdict

Importers paste a product link and get back a risk verdict they can defend — with the evidence, the rule it was judged against, and a snapshot that never changes.

Reading
10 min read
Role
Product engineer, part-time
Period
Dec 2025 — now
Owned
Data model, pipeline, RAG, billing
Stack
NestJS · Prisma · Postgres · pgvector · React
IProduct

Overview#

Radar Verdict is a B2B pre-purchase risk platform for importers, sourcing teams and marketplace sellers who buy from overseas suppliers. A team pastes a product link. Radar captures an immutable snapshot of the page, works out the product's category, runs the risk checks that apply to that category, and returns a verdict with its evidence attached. The team then approves, rejects or asks for more evidence, and that decision stays on record.

The idea#

A chat assistant can search the web and write a conclusion. A sourcing decision needs more than that: every claim a supplier makes has to be matched with proof, and the team has to be able to show what it saw and what it was judged against on the day it decided. Radar turns that into a reproducible evidence pipeline instead of a one-off answer.

Every supplier claim gets a proof, a source and a date. History has to stay true even when the source data changes.

Key features#

  • Snapshots and monitoring. Each listing is captured with its text, images, specs, prices and supplier data. Later captures are stored as deltas, and monitors raise alerts when the price, specs or supplier change.
  • Category-aware risk checks. A product is mapped to a category, and the category pulls in its risk packs. Each risk key in a pack has explicit red-flag and green-flag definitions and ends up red, yellow, green or unknown.
  • Claim vs proof. Evidence slots list what has to be proven: company registration, certificates, test reports, labeling photos, invoices. Each slot is missing, partial, satisfied or waived.
  • Decision workflow. Process templates create tasks, evidence requests and approval gates on a Kanban board. Team members vote, the decision and its history are kept, and the real outcome can be recorded later for a post-mortem.
  • Supplier dossier. Contacts (including WeChat and WhatsApp), a message log, notes, attachments, approval status, sample orders with quality results, and a multi-tier supply-chain graph.
  • Unit economics. Landed cost from FOB price, shipping, duty and fees, plus marketplace fees, margin, break-even and ROI next to the risk verdict.
  • Sharing and organisation. Side-by-side comparisons on shared risk keys, collections across projects, public links with a password and an expiry date, and exports to PDF, Notion, Google Docs and JSON.

Evidence sources#

Every evidence layer is connected the way its source allows. Open datasets and public APIs are checked automatically. Registries without an API are verified by hand, and the result is stored as evidence with its date.

  • Legal existence: the official Chinese company registry (GSXT) shows whether the entity exists, along with its legal representative and its business scope. Manual verification first.
  • Export activity: US import shipment records show whether the supplier really ships, and whether what it ships matches the category it claims.
  • Sanctions: OFAC sanctions lists, downloaded, indexed and matched automatically against the supplier's name, representative and address.
  • Corporate identity: the GLEIF LEI index, through its public API, for larger suppliers and counterparties. EU VAT and EORI checks cover European ones.
  • Certificates: issuer, number, scope and expiry are extracted from the uploaded document and checked against IAF CertSearch or the issuer's own directory (SGS and others). The result is recorded as verified, not found, expired or scope mismatch.
  • Product safety: recalls of similar products in the target market, from EU Safety Gate and the US CPSC recalls API.
IITechnical

Architecture#

Radar started as one NestJS monolith and now runs as a set of services on one Docker Compose host. The NestJS API still owns auth, billing, teams and every write to the business tables in Postgres through Prisma: 105 models, every query scoped to a team. Analysis runs go to a Go workflow runtime, which calls a scraper, an integrations service and a Python LangGraph agent over gRPC. Every model call, from any service, goes through a LiteLLM gateway, and lands in Langfuse with its tokens and cost. Category retrieval still uses pgvector (1536-dimension embeddings with an HNSW index), and files live in Cloudflare R2.

Radar Verdict service architecture: React client and browser extension, Caddy, the NestJS server, the Go workflow runtime, Redis, Postgres, the scraper, integrations and LangGraph agent services, the LiteLLM gateway, external APIs, and Langfuse plus the OpenTelemetry stack.

Who owns what

  • Server (NestJS). The only writer of business data. Other services read and write through its internal gRPC API, so team scoping, billing and the audit log stay in one place.
  • Workflow runtime (Go). My own orchestrator, extended for Radar with parallel steps, a Postgres store, schedules, compensation steps and resume after a restart. It knows steps, not prompts.
  • Scraper. Zyte first, Playwright as the fallback. It cleans the HTML, pulls JSON-LD, writes markdown and screenshots to object storage and returns references, never bytes.
  • Integrations. One adapter per verification source, each with its own cache, rate limit and circuit breaker. A source that is down returns “couldn't evaluate” instead of failing the run.
  • Agent (Python, LangGraph). Every AI step of the pipeline as a typed graph: extraction, category choice, block hydration, and a critic that checks every claim has a source.
  • LiteLLM and Langfuse. The gateway holds every provider key and routes each call by alias; Langfuse records each call as part of one trace per analysis.
Decision · Two orchestrators, two jobs
Context
Both the Go workflow runtime and LangGraph can run steps. Letting both drive the pipeline would split retries, billing and progress across two places.
Choice
The runtime owns the job: step order, retries, timeouts, cancellation, refunds and progress. LangGraph lives only inside the AI steps and decides how to think: tools, loops, parallel blocks and the critic.
Trade-off
Two state stores to reason about, the job store and the graph checkpoints, in exchange for failure handling that never depends on prompt logic.
Decision · One gateway for every model call
Context
Four provider SDKs and their keys lived inside the API, and every feature called them directly. Cost per analysis was guesswork.
Choice
A LiteLLM proxy in its own container: an alias per pipeline stage, fallbacks across providers, a virtual key per service and spend tracked per team. The server and the agent both use one OpenAI-compatible client.
Trade-off
One more hop and one more service to run, in exchange for keys in one place and a cost line for every call.
OptionGainsCosts
Own AI serviceFull control, reuses the existing provider codeI maintain retries, fallbacks and cost tracking myself
LangSmith gatewayHosted, tight LangChain integrationCloud only; self-hosting needs the Enterprise plan
LiteLLM proxy (chosen)Open source, self-hosted, OpenAI-compatibleA Python service to operate
Decision · Only the server writes business data
Context
Five services now touch an analysis. If each wrote its own rows, team scoping, billing and audit would be enforced in five places.
Choice
Workers return results to the runtime, which hands them to the server through an internal gRPC API. Every write is idempotent by analysis, step and key.
Trade-off
An extra hop per write, in exchange for one place that owns tenancy, billing and the realtime events the client already listens to.

Risk taxonomy#

The product's knowledge lives in data, not in prompts. The hierarchy runs Team → Taxonomy → Category → Risk pack → Risk key.

  • Global and team taxonomies. The platform taxonomy is read-only for every team. A team can fork a key or a pack into its own taxonomy, and the fork records the source version, so drift from the original is visible.
  • Categories with trade codes. A category maps to HS, US HTS, China and EU tariff codes, UK tariff, UNSPSC, GPC, NAICS and marketplace categories, per country.
  • Versioned risk keys and packs. A risk key has a base severity and versioned detector specs: an LLM judge, rules, or both. Packs are versioned and apply to specific categories, to whole domains, or to everything.
  • Audience filters. Global content can be limited by domain, region, plan tier or a team allowlist.

Composable analysis blocks#

An analysis is assembled from typed blocks: prompt, table, checklist, scorecard, simulator, decision, chart and alternatives. Each block definition has input, output and config schemas. A block's type decides how it runs and renders, and its binding decides where it applies: to a category, a risk pack or a risk key. Templates group blocks into tabs, and the template layout is frozen into the analysis when it is created, so a later template edit never changes a past report.

Snapshots and evidence#

Every analysis starts from an immutable snapshot with a content hash and an evidence-chain hash. Chain events link to the previous hash, so any tampering breaks the chain. When the page changes, the change is stored as a delta that records which fields moved and by how much the price changed.

OptionGainsCosts
Re-fetch on demandNothing to storeCan't prove what was seen on decision day
Full copy per runSimple to read backStorage grows with every run
Snapshot + deltas (chosen)Provable, compact, hash-chainedReads need to replay deltas
Decision · Results copy their rule
Context
Rules change. A result that points at the live risk key silently changes its own history when the key is edited, deprecated or deleted.
Choice
Each risk-key result stores a snapshot of the key it was judged against: its code, title, description and base severity. The link to the live key is nullable and set to null on delete, never cascaded.
Trade-off
Some rule text is duplicated, in exchange for verdicts that render the same forever.

Analysis pipeline#

Each analysis moves through explicit states, so a stuck or partial run is visible and recoverable instead of guessed. Blocks also have their own states: one can be retrying with backoff, or skipped when a dependency is missing. The UI renders each block as soon as it is ready. Results are normalized into per-key and per-pack rows that the UI reads directly, so it never has to parse free-form output. In the new architecture each state is a step in the workflow runtime, and hydration fans out into one branch per block.

Radar Verdict analysis pipeline: eight states from QUEUED to DONE with what each stage writes, the other endings (PARTIAL, FAILED, CANCELED) and per-block states.
  • Idempotency: the same team, project, normalized URL, template and import country within five minutes resolve to one analysis.
  • Model routing: provider and model resolve per block, then per template, then per pipeline stage, then from the global default. The result maps to a LiteLLM alias such as radar-extraction or radar-reasoning, so cheap stages go to cheap models, reasoning goes to strong ones, and each alias has a fallback chain.
  • LLM audit trail: every call is kept with its prompt, images, response, tokens, cost, duration and queue wait. The same call appears in a Langfuse trace whose id is the analysis id. The raw trail is visible only in the admin debug view.

Moving off the monolith#

The new pipeline runs next to the old one behind an ANALYSIS_ENGINE flag. The client and the browser extension didn't change: the API, the Socket.IO events and the billing rules are the same for both engines. The workflow engine becomes the default only after a parity gate: the same golden set of listings, scored on extraction accuracy, category, per-block quality, cost and latency.

load-test analyses finished DONE
18 / 18
p95 per analysis under load
80 s
duplicate writes after a mid-run killVerified by killing the runtime and the API mid-analysis; the other services are still to test.
0
model calls across evals, load and chaos tests
2,533

Billing ledger#

Billing is an append-only credit ledger with separate buckets for plan allowance, purchased credits and adjustments. Each run, and each block inside it, is charged as its own entry, so a balance is always the sum of its history. Unique constraints make grants idempotent: a subscription period or a payment order can't be credited twice, even if a webhook arrives again.

schema.prisma · simplified
model CreditLedger {
  id         String       @id @default(cuid())
  teamId     String?
  delta      Int          // negative = charge
  bucket     CreditBucket // ALLOWANCE | PURCHASED | ADJUSTMENT
  reason     CreditReason // ANALYSIS_RUN | ANALYSIS_BLOCK | SUBSCRIPTION_GRANT | REFUND | …
  analysisId String?      // one entry per run…
  blockId    String?      // …and per analysis block
  subscriptionId String?
  periodStart    DateTime?
  orderId        String?
  createdAt  DateTime     @default(now())

  @@unique([subscriptionId, periodStart, reason]) // a period is granted once
  @@unique([orderId, reason])                     // an order is credited once
}
RejectedBalance column
  • One number, updated in place
  • No answer to “why is it 40?”
ShippedAppend-only ledger
  • Balance = sum of entries
  • Every charge traces to a run or block
  • Webhook replays can't double-credit

Multi-tenancy and safety#

  • Every mutable entity has a version column for optimistic concurrency, so concurrent edits fail instead of overwriting each other.
  • Roles are built from per-permission rows, and projects have their own members.
  • When a user's access changes, a session version is bumped. The client sees the change in a response header and reloads its permissions.
  • An audit log records app, system and database-trigger events. Team API keys are stored only as hashes with scopes, and integration configs are encrypted at rest.
data models
105
indexes and unique constraints
417
explicit analysis states
8
category code systems
14

Discussion

Loading comments…