Cursor Rules Template: ERP Dashboard with Next.js, PostgreSQL, Prisma, Clerk and Shadcn UI
Cursor Rules Template for building an ERP dashboard with Next.js, PostgreSQL, Prisma, Clerk, and Shadcn UI. Includes a copyable .cursorrules block and stack-specific guidance.
Target User
Developers building ERP dashboards for SMEs using modern web stack
Use Cases
- ERP dashboard for SMEs
- Sales analytics
- Inventory management UI
- Role-based access control UI
- Data visualization
Markdown Template
Cursor Rules Template: ERP Dashboard with Next.js, PostgreSQL, Prisma, Clerk and Shadcn UI
framework: Next.js
role: Architect
context: You are a Cursor AI assistant building a production ERP dashboard for SMEs using Next.js, PostgreSQL, Prisma, Clerk and Shadcn UI
cursor_rules_version: 1
style_guide: Airbnb TypeScript
architecture:
app_router: true
monorepo: true
dirs:
- apps/erp-dashboard/app
- apps/erp-dashboard/components
- apps/erp-dashboard/hooks
- packages/ui
- prisma
auth_and_security:
provider: Clerk
session_management: JWT
token_expiry: 15m
cors: configured for same-origin API routes
secrets_handling: secret values injected via environment variables only
database_and_orm:
engine: PostgreSQL
orm: Prisma
migrations: Prisma migrate dev in development, migrate deploy in CI
data_model_guidelines: strict typing, explicit selects, indexed fields for search
ui_and_component_library:
library: Shadcn UI
components_usage: consistent styling via Tailwind presets, accessibility tuned
testing_and_ci:
unit_tests: Vitest
e2e_tests: Playwright
linting: ESLint + Prettier
ci_checks: type-check, lint, unit & e2e tests, build
prohibited_actions:
actions:
- Do not use Mongoose or Sequelize
- Do not bypass authentication or authorization checks
- Do not commit secrets or credentials
- Do not ship API routes without input validationOverview
The Cursor rules configuration provides a concrete, production-grade blueprint for building a modern ERP dashboard using Next.js, PostgreSQL, Prisma, Clerk, and Shadcn UI. This Cursor Rules Template translates real-world ERP domain needs into enforceable AI instructions so Cursor AI can guide code generation, reviews, and integration tasks for SMEs.
Direct answer
Use this Cursor Rules Template to drive AI-assisted implementation for a Next.js ERP dashboard with a PostgreSQL database via Prisma, authenticated by Clerk, and styled with Shadcn UI. It encodes architecture, security, testing, and devops constraints as a single, pasteable configuration.
When to Use These Cursor Rules
- Starting a new ERP dashboard project for SMEs with a modern stack
- Integrating Clerk for authentication and user management
- Modeling PostgreSQL data with Prisma ORM for robust relations
- Implementing a component library UI with Shadcn UI
- Enforcing a clean architecture with clear domain boundaries
- Setting up CI/CD and automated testing for production-readiness
Copyable .cursorrules Configuration
framework: Next.js
role: Architect
context: You are a Cursor AI assistant building a production ERP dashboard for SMEs using Next.js, PostgreSQL, Prisma, Clerk and Shadcn UI
cursor_rules_version: 1
style_guide: Airbnb TypeScript
architecture:
app_router: true
monorepo: true
dirs:
- apps/erp-dashboard/app
- apps/erp-dashboard/components
- apps/erp-dashboard/hooks
- packages/ui
- prisma
auth_and_security:
provider: Clerk
session_management: JWT
token_expiry: 15m
cors: configured for same-origin API routes
secrets_handling: secret values injected via environment variables only
database_and_orm:
engine: PostgreSQL
orm: Prisma
migrations: Prisma migrate dev in development, migrate deploy in CI
data_model_guidelines: strict typing, explicit selects, indexed fields for search
ui_and_component_library:
library: Shadcn UI
components_usage: consistent styling via Tailwind presets, accessibility tuned
testing_and_ci:
unit_tests: Vitest
e2e_tests: Playwright
linting: ESLint + Prettier
ci_checks: type-check, lint, unit & e2e tests, build
prohibited_actions:
actions:
- Do not use Mongoose or Sequelize
- Do not bypass authentication or authorization checks
- Do not commit secrets or credentials
- Do not ship API routes without input validation
Recommended Project Structure
apps/erp-dashboard/
app/
layout.tsx
page.tsx
components/
ui/
hooks/
styles/
prisma/
schema.prisma
packages/
ui/
tailwind.config.js
lib/
api-client.ts
scripts/
deploy.sh
public/
styles/
Core Engineering Principles
- Type safety and explicit contracts across server and client boundaries
- Single source of truth for data models and UI state
- Separation of concerns: domain, app, infra, and UI layers
- Idempotent migrations and reproducible builds
- Security by default: least privilege, proper auth checks, and secrets isolation
- Observability: structured logging and metrics from start to finish
- Accessibility and internationalization considerations for enterprise use
- Reusable components and utilities to reduce tech debt
Code Construction Rules
- Use Next.js App Router with server components for data fetching and client components for interactivity
- Define Prisma models with explicit relations and index critical fields
- Access Clerk session data via server components when possible; hydrate in client components safely
- Follow TypeScript strict mode; enable noImplicitAny; prefer interfaces for public APIs
- Adopt Shadcn UI for consistent styling; wrap interactive elements with accessible controls
- Use environment variables for all secrets; never hardcode credentials
- Implement API routes with proper input validation and error handling
- Document public APIs and data contracts for internal use
- Do not bypass authentication or authorization checks in routes
Security and Production Rules
- Enforce role-based access control for ERP entities
- Use Clerk for auth flows and protect API routes with middleware guards
- Validate all inputs server-side; prevent SQL injection and XSS
- Enable TLS, secure cookies, and CSRF protection where applicable
- Log only non-sensitive data; redact secrets in logs
- Monitor error rates and have a rollback plan for migrations
Testing Checklist
- Unit tests for data fetching hooks and utilities
- Integration tests for Prisma queries and API endpoints
- End-to-end tests for ERP workflows using Playwright
- Type checking and linting in CI; run migrations in a test database
- Seed data for deterministic tests; reset between tests
Common Mistakes to Avoid
- Mixing server and client logic without clear boundaries
- Omitting input validation or using unsafe eval-like patterns
- Hardcoding secrets or publishing API keys in code
- Neglecting authentication in admin routes or dashboards
- Over-fetching data or returning overly large payloads from APIs
- Skipping migrations or running migrations in production without backups
Related Cursor rules templates
Explore adjacent Cursor rules templates for similar stacks, workflows, and production constraints.
- Cursor Rules Template: LMS with Courses, Lessons, Quizzes, Certificates, Payments, and Admin Dashboard
- Headless Commerce Admin Panel Cursor Rules Template
- Cursor Rules Template: Django Payroll Dashboard with Timesheets, Deductions, Approvals and Exportable Reports
- Cursor Rules Template: Manufacturing Execution Dashboard (NestJS + PostgreSQL)
FAQ
What is a Cursor Rules Template for ERP dashboards?
A Cursor Rules Template provides a structured, pasteable configuration that guides Cursor AI in building a production ERP dashboard stack with Next.js, PostgreSQL, Prisma, Clerk, and Shadcn UI. It encodes architecture, security, testing, and deployment practices to accelerate reliable development.
How do I integrate Clerk authentication in this stack?
Install Clerk, configure your frontend and API keys, wrap the app with ClerkProvider, and use Clerk hooks to enforce access control on routes and components. Cache user context on the client while validating tokens on the server side for API routes.
How are Prisma migrations handled in this template?
Use Prisma migrate dev during local development to evolve the schema and generate SQL migrations. In CI and production, run prisma migrate deploy to apply migrations in a controlled, non-destructive manner with proper backups.
How should I test the ERP dashboard end-to-end?
Run unit tests for utilities and hooks with Vitest, integration tests for Prisma queries, and end-to-end tests with Playwright that cover common ERP workflows like login, dashboards loading, and create/update actions. Seed deterministic data for reliable results.
Can I adapt this template to another stack?
Yes. Replace the framework, ORM, and auth provider in the Cursor Rules block and adjust architecture, security, and testing guidance accordingly. Ensure stack-specific constraints and best practices are reflected in the rules, directory layout, and tests.