AWS Builder Center
Building QCO-Check: A Zero-Hallucination BIS Compliance Engine with Next.js and Amazon S3

Building QCO-Check: A Zero-Hallucination BIS Compliance Engine with Next.js and Amazon S3

How we built a deterministic BIS Quality Control Order (QCO) compliance platform for Indian steel and fastener importers using Next.js, Prisma, PostgreSQL, and Amazon S3 for durable batch CSV and PDF report storage.

The Problem

Every year, Indian steel and fastener importers and Customs House Agents (CHAs) face costly port delays and demurrages trying to determine whether a shipment requires mandatory Bureau of Indian Standards (BIS) certification under a Quality Control Order (QCO). Manually cross-referencing Gazette notifications, IS standards, and CBIC circulars against Bill of Lading and Clearance dates is slow and error-prone.

The Solution: QCO-Check

QCO-Check is a deterministic, zero-hallucination BIS compliance engine. Instead of relying on guesswork, it evaluates shipments against structured QCO rules and returns legally traceable verdicts:
  • GREEN: Exempt or out-of-scope
  • RED: BIS certification mandatory
  • AMBER: Ambiguous case routed to an Admin Review Queue

Architecture & Tech Stack

  • Frontend & API: Next.js (App Router) with role-based access control separating the Importer Workspace from the Admin Console
  • Database & ORM: PostgreSQL with Prisma
  • Rules Engine: Pure TypeScript deterministic engine evaluating HS codes, IS grades, and Bill of Lading vs. Clearance Date transitional logic
  • Cloud Storage: Amazon S3 ( @aws-sdk/client-s3  &  @aws-sdk/s3-request-presigner )

How We Use Amazon S3

To make QCO-Check production-ready for batch processing and audit trails, we integrated Amazon S3 for firm-scoped file storage:
  1. Batch CSV Uploads: When an importer uploads a CSV of up to 1,000 SKUs, the raw file is stored in S3 under  firms/{firmId}/batches/{batchId}.csv  and linked to the database record.
  1. Customs-Ready PDF Reports: Generated determination reports are cached in S3 ( firms/{firmId}/determinations/{id}.pdf ) so subsequent downloads are served via short-lived (60-second) presigned S3 URLs without regenerating the PDF.
  1. Local Fallback: If AWS credentials are not configured in local development, the app gracefully falls back to on-the-fly generation.

Human-in-the-Loop Continuous Learning

When a shipment triggers an AMBER verdict, it enters the Admin Review Queue. Once an Admin resolves the case, they can promote it to a permanent rule with one click—ensuring the engine gets smarter with every edge case without sacrificing determinism.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article