Skip to content

edglz/prisma-share

Repository files navigation

PrismaShare - Full-Stack Monorepo Template 🚀

TypeScript Prisma NestJS Next.js React TurboRepo

A modern monorepo template for sharing Prisma schema and client between frontend and backend applications

Portfolio GitHub

Buy Me A Coffee

🌟 Description

This project is a monorepo configured with Turborepo that allows sharing a Prisma package between different applications, both frontend (Next.js) and backend (NestJS). This approach maintains a single source of truth for your database schema and types, offering a coherent and type-safe development experience across the entire stack.

🏗️ Project Structure

├── apps/
│   ├── auth/               # NestJS application for authentication
│   └── web/                # Next.js frontend application
├── packages/
│   ├── db/                 # Shared Prisma package
│   │   ├── prisma/         # Prisma schema and migrations
│   │   ├── src/            # Exported Prisma client
│   ├── eslint-config/      # Shared ESLint configuration
│   └── typescript-config/  # Shared TypeScript configuration
└── package.json            # Monorepo configuration

✨ Features

  • Shared Prisma Schema: Define your data model once, use it everywhere
  • Type Safety: Complete TypeScript types across frontend and backend
  • Rapid Development: Hot reloading and fast rebuilding with Turborepo
  • Maintainability: Modular structure for easy maintenance and scalability
  • Consistency: Standardized ESLint and TypeScript configuration across all packages

🛠️ Technologies

  • ORM: Prisma - Modern ORM with TypeScript type generation
  • Backend: NestJS - Progressive Node.js framework for efficient and scalable applications
  • Frontend: Next.js - React framework with hybrid rendering
  • Monorepo Management: Turborepo - Optimized build system for JavaScript/TypeScript monorepos
  • Package Manager: pnpm - Fast and space-efficient package manager

🚀 Quick Start

  1. Clone the repository

    git clone https://github.com/edglz/prismashare.git
    cd prismashare
  2. Install dependencies

    pnpm install
  3. Set up the database
    Create a .env file in packages/db with your PostgreSQL connection URL:

    DATABASE_URL="postgresql://username:password@localhost:5432/mydb?schema=public"
    
  4. Generate the Prisma client

    cd packages/db
    pnpm prisma generate
  5. Run migrations

    pnpm prisma migrate dev
  6. Start development

    cd ../.. # Return to the monorepo root
    pnpm dev

📋 Available Commands

# Development
pnpm dev        # Start all applications in development mode

# Building
pnpm build      # Build all applications and packages

# Linting
pnpm lint       # Run ESLint on all applications and packages

# Formatting
pnpm format     # Format code with Prettier

📚 How the Prisma Client is Shared

The @repo/db package exposes both the Prisma client and generated types:

// In the backend (NestJS)
import { PrismaClient } from '@repo/db';

// In the frontend (Next.js)
import { Post, User } from '@repo/db';

🤝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

Distributed under the MIT License. See LICENSE for more information.

👨‍💻 Author

Created by Eduardo Gonzalez

Portfolio GitHub


☕ Found this project helpful?

Buy Me A Coffee

About

Este proyecto es un monorepo configurado con Turborepo que permite compartir un paquete de Prisma entre diferentes aplicaciones, tanto de frontend (Next.js) como de backend (NestJS). Este enfoque permite mantener una única fuente de verdad para tu esquema de base de datos y tipos, ofreciendo una experiencia de desarrollo coherente y type-safe.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Contributors