PicaDeckSync

Databases, by design.

@picadeck/prisma-parser

Parse a Prisma schema file (.prisma) into a UniversalSchema for visualization.

Installation

npm install @picadeck/prisma-parser

Import

import {
  parsePrismaSchema,
  parsePrismaFile,
} from "@picadeck/prisma-parser";

API

parsePrismaSchema(schemaContent: string): UniversalSchema

Accepts the raw contents of a .prisma file as a string. Parses models, fields, types, attributes, and relation directives.

parsePrismaFile(filePath: string): UniversalSchema

Reads the file at the given path and passes its contents to parsePrismaSchema. Throws if the file does not exist.

Full Example

server.ts
import express from "express";
import { schemaVisualizer } from "@picadeck/core";
import { parsePrismaFile } from "@picadeck/prisma-parser";

const app = express();

// Point to your Prisma schema file
const schema = parsePrismaFile("./prisma/schema.prisma");

app.use("/schema", schemaVisualizer(schema, {
  theme: "dark",
  title: "Blog Database",
}));

app.listen(3000, () => {
  console.log("Schema visualizer at http://localhost:3000/schema");
});

Supported Types

Prisma TypeNormalizedType
StringSTRING
IntINTEGER
FloatFLOAT
DecimalDECIMAL
BooleanBOOLEAN
DateTimeDATETIME
JsonJSON
BytesBINARY
BigIntBIGINT

Notes

  • Framework-agnostic. Works identically with Express, NestJS, Next.js, or any other setup.
  • Relation fields (e.g., author User @relation(...)) are parsed as relationships with the correct cardinality.
  • Enums defined in the Prisma schema are included in the output as type definitions.