Backend API for the IronHub AI Product Enrichment platform — a NestJS application that ingests product data via file upload (Excel/CSV) or API, sends it to an external AI enrichment service, and exposes the enriched results through a RESTful API with pagination, filtering, approval workflows, and Swagger documentation.
/docs (toggle via ENABLE_DOCS)/docs/compodocclass-validator and class-transformersrc/
├── app.module.ts # Root module — imports all feature modules
├── app.controller.ts # Health check, status page, favicon endpoints
├── app.service.ts # Server metadata & uptime
├── main.ts # Bootstrap — pipes, filters, CORS, Swagger setup
├── data-source.ts # TypeORM DataSource for migrations CLI
├── common/
│ ├── dto/ # Generic query, pagination, filter DTOs
│ ├── filters/ # AllExceptionsFilter
│ ├── interceptors/ # LoggingInterceptor
│ └── helpers/ # QueryBuilderHelper (filtering, sorting, search)
├── config/
│ ├── configuration.ts # Typed environment configuration
│ └── validation.schema.ts # Joi schema for env validation
├── database/
│ ├── database.module.ts # TypeORM module registration
│ └── entities/ # TypeORM entities (ImportBatch, ImportItem, EnrichmentJob, EnrichmentAttempt, EnrichmentResult)
├── migrations/ # TypeORM migrations (schema changes)
└── modules/
├── auth/ # Auth module (placeholder)
├── enrichment/ # Core enrichment module
│ ├── enrichment.controller.ts
│ ├── enrichment.service.ts
│ ├── enrichment.module.ts
│ └── dto/ # Enrichment & approval DTOs
└── integrations/ # External integrations (IronHub)npm installcp .env.example .env.env with your values:NODE_ENV=development
PORT=3001
CORS_ORIGIN=http://localhost:3000
# API
API_PREFIX=api
API_VERSION=v1
# Database (PostgreSQL)
DATABASE_HOST=localhost
DATABASE_PORT=5432
DATABASE_USERNAME=postgres
DATABASE_PASSWORD=postgres
DATABASE_NAME=ironhub_enrichment
DATABASE_SSL=false
DATABASE_SSL_REJECT_UNAUTHORIZED=false
# External AI enrichment service
PYTHON_URL=http://localhost:5000
# Documentation
ENABLE_DOCS=trueTip — CORS for local dev against staging: Append your dev origin to
CORS_ORIGIN(comma-separated), or setEXTRA_CORS_ORIGINS=http://localhost:3000, or setALLOW_CORS_LOCALHOST=true. Restart the service after changing.
# Run migrations to create / update schema
npm run migration:run
# (Optional) Reset database — local dev only, drops and recreates public schema
npm run db:reset# Development (watch mode)
npm run start:dev
# Production build
npm run build:prod # generates Compodoc docs, builds NestJS, copies static assets
npm run start:prodThe API will be available at http://localhost:3001/api.
| Method | Path | Description |
|---|---|---|
GET |
/ |
HTML status page (name, version, environment, uptime) |
GET |
/api |
JSON health-check (for monitoring tools) |
/api)| Method | Path | Description |
|---|---|---|
POST |
/enrichment/bulk |
Upload Excel/CSV file or JSON products for bulk enrichment |
GET |
/enrichment/batch/:batchId/status |
Get batch processing status & progress |
GET |
/enrichment/batch/:batchId/items |
List items in a batch with status & results |
GET |
/enrichment/jobs |
Paginated list of enrichment jobs |
GET |
/enrichment/results |
Paginated, filterable enrichment results |
GET |
/enrichment/results/stats |
Approval statistics (waiting / accepted / rejected) |
GET |
/enrichment/results/:id |
Single enrichment result detail |
PATCH |
/enrichment/results/:id/approve |
Approve or reject a result (field-level) |
POST |
/enrichment/results/:id/re-enrich |
Re-enrich a result with optional overrides |
POST |
/enrichment/results/bulk-approve |
Bulk-approve results by confidence threshold |
| Path | Description |
|---|---|
/docs |
Swagger / OpenAPI interactive API docs |
/docs/compodoc |
Compodoc application architecture docs |
# Unit tests
npm run test
# Unit tests in watch mode
npm run test:watch
# E2E tests
npm run test:e2e
# Test coverage
npm run test:cov# Lint (with auto-fix)
npm run lint
# Format (Prettier)
npm run format
# Format check (CI)
npm run format:check# Generate a new migration from entity changes
npm run migration:generate -- src/migrations/<MigrationName>
# Run pending migrations
npm run migration:run
# Revert last migration
npm run migration:revertExample :Warning: This destroys all data. For local development only.
# Interactive (recommended)
npm run db:reset
# Skip backup
npm run db:reset -- --no-backup
# Non-interactive
npm run db:reset -- --yes
# Force even in production (NOT RECOMMENDED)
npm run db:reset -- --force --yes# Full production build (Compodoc + NestJS + copy static assets)
npm run build:prod
# Generate Compodoc docs only
npm run docs:compodoc
# Serve Compodoc docs locally (http://127.0.0.1:8080)
npm run docs:compodoc:serveImportBatch, ImportItem, EnrichmentJob, EnrichmentAttempt, EnrichmentResultwaiting_for_approval → reviewers accept/reject at the field level → accepted results can be publishedversion column and links to the previous result via previousVersionIdBaseQueryDto provides pagination, sort, search, and a JSON filters parameter supporting typed operators (string, number, date)UNLICENSED (private)