PicaDeckSync

Databases, by design.

UniversalSchema

The central data format that all parsers output and the visualizer consumes.

Top-Level Interface

interface UniversalSchema {
  version: string;
  source: {
    framework: string;  // e.g. "mongoose", "typeorm", "prisma"
    database: string;   // e.g. "mongodb", "postgresql", "mysql"
  };
  entities: Entity[];
  relationships: Relationship[];
  types?: SchemaTypeDef[];
  metadata?: SchemaMetadata;
}

Entity

Represents a database table, collection, or model.

interface Entity {
  id: string;          // Unique identifier
  name: string;        // Table or model name
  fields: Field[];
  indexes?: Index[];
  description?: string;
}

Field

Represents a column, attribute, or field within an entity.

interface Field {
  name: string;
  type: string;                  // Raw type from the ORM
  normalizedType: NormalizedType; // Standardized type enum
  nullable: boolean;
  primaryKey: boolean;
  unique: boolean;
  defaultValue?: string;
  description?: string;
}

Relationship

Represents a foreign key or reference between two entities.

interface Relationship {
  id: string;
  name?: string;
  sourceEntityId: string;
  targetEntityId: string;
  sourceFieldId?: string;
  targetFieldId?: string;
  type: "one-to-one" | "one-to-many" | "many-to-one" | "many-to-many";
}

NormalizedType

A standardized enum that maps ORM-specific types to a common set. This ensures the visualizer renders types consistently regardless of which parser produced the schema.

enum NormalizedType {
  STRING = "STRING",
  TEXT = "TEXT",
  INTEGER = "INTEGER",
  BIGINT = "BIGINT",
  FLOAT = "FLOAT",
  DECIMAL = "DECIMAL",
  BOOLEAN = "BOOLEAN",
  DATE = "DATE",
  DATETIME = "DATETIME",
  TIMESTAMP = "TIMESTAMP",
  TIME = "TIME",
  UUID = "UUID",
  JSON = "JSON",
  BINARY = "BINARY",
  ENUM = "ENUM",
  ARRAY = "ARRAY",
  UNKNOWN = "UNKNOWN",
}

SchemaTypeDef

Optional custom type definitions (e.g., Prisma enums, TypeORM embedded entities).

interface SchemaTypeDef {
  id: string;
  name: string;
  kind: "enum" | "composite" | "custom";
  values?: string[];      // For enums
  fields?: Field[];       // For composite types
  description?: string;
}

SchemaMetadata

interface SchemaMetadata {
  name?: string;
  description?: string;
  generatedAt?: string;    // ISO 8601 timestamp
  parserVersion?: string;
}