Discriminator v2 - Interior Design Validation Engine

Discriminator is a technical validation service designed to analyze interior design data. It evaluates spatial layouts against a set of predefined rules covering capacity, zoning, ergonomics, visual aesthetics, and physical geometry.

Prerequisites

Development Commands

# Install dependencies
npm install

# Start the production server
npm start

# Start the development server with hot-reload
npm run dev

# Run the test suite
npm test

# Run typecheck
npm run typecheck

API Documentation

Endpoint Method Description
/ GET HTML rendering of this README file.
/api/v2/ GET Health check and version metadata.
/api/v2/validate POST Primary validation endpoint. Runs all rules.
/api/v2/zone POST Dedicated endpoint for automatic zone detection logic.
/api/v2/path POST Dedicated endpoint for pathfinding and clearance calculation.

Data Model

Coordinate System & Geometry

Object Properties (roomData.objects)

Request

type Point = [number, number];
type Position = { x: number; y: number; z: number };
type RGB = { r: number; g: number; b: number };

type ValidationRequest = {
  lang: 'en' | 'cs';
  roomData: {
    size: Position;
    objects: Array<{
      id: string;
      name: string;
      categoryId: string;
      position: Position;
      size: Position;
      rotation: number;
      colors: RGB[];
      designStyle: string[];
      material: string[];
      seatingCapacity: number;
      zoneId: null | string;
      isDominant: boolean;
      isZoneDev: boolean;
      isBorder: boolean;
    }>;
  };
  questionnaire: {
    numberOfAdults: number;
    numberOfChildren: number;
    numberOfGuests: number;
    workplace: boolean;
    playground: boolean;
  };
  zones: null | Array<{ id: string; polygon: Point[] }>;
  paths: null | Array<{ objectIdFrom: string; objectIdTo: string; points: Point[] }>;
};

Responses

200 OK (Success)

Standard successful response.

type ValidateResult = {
  executionTime: number;
  summary: {
    totalRules: number;
    passed: number;
    failed: number;
    warnings: number;
    passRate: number;
    overallStatus: 'pass' | 'fail' | 'warning';
  };
  zones: Array<{ id: string; polygon: Point[] }>;
  paths: Array<{ objectIdFrom: string; objectIdTo: string; points: Point[] }>;
  results: Array<{
    status: 'pass' | 'warning' | 'fail';
    ruleId: string;
    userMessage: string;
    userRepairInstructions?: string; // only for fail and warning
    impactedObjectId?: string;
    measuredValue?: number;
    errorValue?: number;
  }>;
};
400 Bad Request

Returned when the request data fails schema validation.

{
  "error": "Invalid request",
  "message": "Detailed validation error message"
}
500 Internal Server Error

Returned when an unexpected error occurs during processing.

{
  "error": "Internal Server Error",
  "message": "Detailed error message"
}

Computational Logic

Automatic Zone Detection

The engine processes all objects with a zoneId. The room's total area is partitioned into specific polygons based on the distribution of these anchored objects.

Pathfinding (PATH)

The algorithm generates a movement graph based on: