Skip to content

MM25Zamanian/prismate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

16 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

๐Ÿš€ Prismate

Turn your Prisma schema into a modern, productionโ€‘ready admin panel โ€” at runtime.

License: MIT TypeScript Next.js Prisma Tailwind UI Server

๐Ÿ“š Table of Contents

  • Overview
  • Tech Stack Decision
  • Architecture
  • Features (MVP + Future)
  • Quick Start
  • Configuration
  • Usage
  • Coding Standards
  • Folder Structure
  • Limitations
  • Roadmap
  • License

๐ŸŽฏ Overview

Prismate is a runtime library that reads your Prisma schema (DMMF) and provides a readyโ€‘toโ€‘use admin experience for your Next.js app. It removes the repetitive work of building CRUD forms and data tables for each model, keeping the UI in sync with your database by design.

  • Single Source of Truth: your schema.prisma
  • Maximum Automation: CRUD UI and API generated at runtime
  • Extensible by Design: roadmap for custom fields/actions/hooks (future)

๐Ÿงฐ Tech Stack Decision

  • Next.js 15 (App Router) โ€” admin UI runtime
  • TypeScript 5.x โ€” type safety everywhere
  • Prisma 6 โ€” database layer + DMMF
  • Tailwind CSS 4 โ€” styling
  • shadcn/ui โ€” lightweight, accessible UI components
  • Elysia โ€” fast server runtime for HTTP endpoints

Note: Prismate is designed specifically for this stack and is not frameworkโ€‘agnostic.

๐Ÿ—๏ธ Architecture

Highโ€‘level flow:

Prisma Schema  โ”€โ”€โ–ถ  Prisma DMMF  โ”€โ”€โ–ถ  Prismate Runtime
                                     โ”œโ”€โ”€ Validation (Zod)
                                     โ”œโ”€โ”€ UI Mapping (shadcn/ui)
                                     โ”œโ”€โ”€ API Adapter (Elysia)
Next.js App  โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Runtime boundaries:

  • Data model: Prisma is the source of truth
  • Transport: Elysia handles HTTP endpoints (CRUD)
  • UI: Next.js + shadcn/ui renders list/forms from model metadata

Deployment:

  • Same repository (monorepo via Turborepo)
  • Elysia endpoints can run alongside Next.js or as a separate process

โœจ Features

โœ… MVP

  • Autoโ€‘generated list, create, edit, delete for all Prisma models
  • Typeโ€‘driven field rendering (String, Int, Boolean, Date, Enum, Relations)
  • Zod validation inferred from schema metadata
  • Basic search, sort, and pagination
  • Responsive, accessible UI built on shadcn/ui
  • Caching for schemaโ€‘toโ€‘UI mapping

๐Ÿ”ฎ Future

  • File uploads (configurable via environment variables)
  • Pluggable storage backends (local, S3, Cloudinary)
  • Component overrides and theming controls
  • Custom actions and hooks (pre/post CRUD)
  • Roleโ€‘based access control
  • Bulk operations and advanced filters

โšก Quick Start

Install in a Next.js + Prisma project:

pnpm add prismate

Generate Prisma client and DMMF:

pnpm prisma generate

Initialize Prismate with your Prisma client and DMMF:

// apps/demo/lib/prismate.ts
import { Server } from 'prismate'
import { db } from './prisma'
import { Prisma } from '@/generated/prisma'

export const prismate = new Server(db, Prisma.dmmf)

Expose HTTP endpoints using Elysia (adapter-based runtime):

// apps/demo/server/elysia.ts (example)
import { Elysia } from 'elysia'
import { prismate } from '@/lib/prismate'

// Example sketch โ€” actual adapter API may evolve
export const app = new Elysia({ prefix: '/api/admin' })
  .get('/:model', async ({ params, query }) => {
    // List (with optional pagination, search)
    return prismate['findMany']?.(params.model as any, {
      take: Number(query.take ?? 20),
      skip: Number(query.skip ?? 0)
    })
  })
  .get('/:model/:id', async ({ params }) => {
    return prismate['findUnique']?.(params.model as any, {
      where: { id: params.id }
    })
  })
  .post('/:model', async ({ params, body }) => {
    return prismate['create']?.(params.model as any, { data: body })
  })
  .put('/:model/:id', async ({ params, body }) => {
    return prismate['update']?.(params.model as any, {
      where: { id: params.id },
      data: body
    })
  })
  .delete('/:model/:id', async ({ params }) => {
    return prismate['delete']?.(params.model as any, { where: { id: params.id } })
  })

Render the admin UI in Next.js:

// apps/demo/app/admin/page.tsx
export default function AdminHome() {
  return (
    <div className="space-y-6">
      <h1 className="text-2xl font-semibold">Admin</h1>
      <p className="text-muted-foreground">Pick a model from the sidebar.</p>
    </div>
  )
}

Note: The Elysia adapter is the recommended transport layer. The exact adapter API may evolve as the runtime solidifies.

๐Ÿ”ง Configuration

Environment variables (current and planned):

  • DATABASE_URL: Prisma connection string
  • STORAGE_PROVIDER: planned for uploads (local, s3, cloudinary)
  • UPLOAD_PATH: planned local storage path
  • MAX_FILE_SIZE: planned upload size limit
  • S3_BUCKET, S3_REGION, S3_ACCESS_KEY, S3_SECRET_KEY: planned S3 config

All fileโ€‘related settings are read from env at runtime (future).

๐Ÿง‘โ€๐Ÿ’ป Usage

Minimal usage patterns:

  • Instantiate Server(db, Prisma.dmmf) once and reโ€‘use
  • Point your Elysia routes to the generated CRUD handlers
  • Consume endpoints from the Next.js admin UI

Edge cases to handle in UI:

  • loading state while fetching
  • error state for failed requests
  • empty state when no data exists

โœ… Coding Standards

  • Next.js App Router with clear Server/Client component separation
  • SSR/ISR where appropriate; client components only for interactive views
  • Absolute imports with @/ alias
  • TypeScript strict mode; no any in public APIs
  • Small, focused components and hooks; avoid bloated components
  • Handle all states (loading, error, empty, success)
  • No dead/duplicate code; keep modules cohesive and testable
  • Conventional Commits (e.g., feat(admin): add list pagination)
  • ESLint + Prettier; format on commit (CI enforces)

๐Ÿ—‚๏ธ Folder Structure

Monorepo (Turborepo + pnpm workspaces):

prismate/
โ”œโ”€ apps/
โ”‚  โ””โ”€ demo/
โ”‚     โ”œโ”€ app/                  # Next.js app router
โ”‚     โ”‚  โ””โ”€ admin/             # Admin UI pages
โ”‚     โ”œโ”€ lib/
โ”‚     โ”‚  โ”œโ”€ prisma.ts          # Prisma client
โ”‚     โ”‚  โ””โ”€ prismate.ts        # Prismate bootstrap (Server + DMMF)
โ”‚     โ”œโ”€ prisma/
โ”‚     โ”‚  โ””โ”€ schema.prisma      # Source of truth
โ”‚     โ””โ”€ server/
โ”‚        โ””โ”€ elysia.ts          # HTTP endpoints (Elysia)
โ”œโ”€ packages/
โ”‚  โ”œโ”€ main/                    # Prismate runtime library
โ”‚  โ”‚  โ””โ”€ src/
โ”‚  โ”‚     โ”œโ”€ prisma-client.ts   # Prisma wrapper + schema extraction
โ”‚  โ”‚     โ”œโ”€ services.ts        # Validation + helpers
โ”‚  โ”‚     โ””โ”€ index.ts           # Public exports
โ”‚  โ”œโ”€ eslint-config/
โ”‚  โ””โ”€ typescript-config/
โ””โ”€ turbo.json / pnpm-workspace.yaml

Conventions:

  • UI primitives from shadcn/ui
  • Business logic in small, testable utilities/hooks
  • Reusable components in components/ with @/ alias

โš ๏ธ Limitations

  • Stackโ€‘specific: Next.js + Prisma + Tailwind + shadcn/ui + Elysia
  • No customization API yet (component overrides, field mapping)
  • No custom actions/hooks yet
  • File uploads are not implemented yet

๐Ÿ—บ๏ธ Roadmap (Short)

  • File uploads with envโ€‘driven storage backends
  • Component overrides and perโ€‘model UI config
  • Custom actions and lifecycle hooks
  • Roleโ€‘based access control

๐Ÿ“„ License

MIT โ€” see LICENSE

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors