Cursor Rules TemplatesCursor Rules Template

Cursor Rules Template for Manufacturing Analytics Dashboards

Cursor Rules Template for Manufacturing Analytics Dashboards with production orders, scrap rates, and cycle time data on a Node.js + PostgreSQL stack.

cursor-rules-templatemanufacturinganalyticsproduction-ordersscrap-ratecycle-timenodejstypescriptpostgresqldashboardCursor AI

Target User

Developers building manufacturing analytics dashboards using Cursor AI on a Node.js + PostgreSQL stack.

Use Cases

  • Define data access and transformation rules for production orders, scrap rates, and cycle time data
  • Generate safe SQL queries and API endpoints for dashboards
  • Enforce architecture constraints in monorepo
  • Guide secure data handling and auditing in analytics pipelines

Markdown Template

Cursor Rules Template for Manufacturing Analytics Dashboards

// Cursor Rules Template for Manufacturing Analytics Dashboard
Framework Role & Context
You are Cursor AI configured for a Node.js + TypeScript backend with PostgreSQL and a React/Next.js frontend. Your scope is to assist in building a manufacturing analytics dashboard focusing on production orders, scrap rates, and cycle time data. Produce safe, auditable, deterministic outputs suitable for paste into a project root.

Code Style and Style Guides
Follow TypeScript conventions, use explicit typings, no implicit any, prefer interfaces for data shapes, and align with project Prettier + ESLint rules. Name files and folders to reflect their dashboard domain (production, quality, ops).

Architecture & Directory Rules
Adhere to a monorepo style with clear separation:
- backend: apps/backend/src
- frontend: apps/frontend/src
- shared: packages/common/src
Dashboards should live under dashboards/production, dashboards/quality, dashboards/ops modules.

Authentication & Security Rules
Implement RS256 JWT validation for API routes, enforce server-side authorization checks for data access, avoid leaking credentials to the client, and sanitize inputs to prevent SQL injection.

Database and ORM patterns
PostgreSQL is the primary data store. Use parameterized queries; avoid string concatenation for IDs or raw SQL. Use a lightweight ORM or query builder on the server boundary; never access DB directly from the client.

Testing & Linting Workflows
Unit tests (Jest) for backend services; React Testing Library for frontend; Cypress for integration tests. Include linting on commit and CI with GitHub Actions: lint, test, build, and E2E steps.

Prohibited Actions and Anti-patterns for the AI
Do not bypass authentication checks. Do not generate or expose real secrets in outputs. Do not rely on uncontrolled data sources. Do not create non-deterministic outputs or assume data shapes without validation.

Overview

Cursor rules configuration defines a deterministic set of instructions for Cursor AI to assist in building a manufacturing analytics dashboard. This Cursor rules template targets a Node.js + TypeScript backend, React frontend (Next.js), and PostgreSQL as the data store, focusing on production orders, scrap rates, and cycle time data.

Direct answer: This page provides a copyable .cursorrules block and stack-specific guidance to generate safe, auditable AI-assisted development patterns for manufacturing analytics.

When to Use These Cursor Rules

  • When you are building dashboards that visualize production orders, scrap rates, and cycle time data from PostgreSQL
  • When you want a consistent, auditable AI-driven code generation flow in a Node.js + TypeScript environment
  • When you need to enforce architecture, security, and testing standards across backend and frontend dashboards

Copyable .cursorrules Configuration

// Cursor Rules Template for Manufacturing Analytics Dashboard
Framework Role & Context
You are Cursor AI configured for a Node.js + TypeScript backend with PostgreSQL and a React/Next.js frontend. Your scope is to assist in building a manufacturing analytics dashboard focusing on production orders, scrap rates, and cycle time data. Produce safe, auditable, deterministic outputs suitable for paste into a project root.

Code Style and Style Guides
Follow TypeScript conventions, use explicit typings, no implicit any, prefer interfaces for data shapes, and align with project Prettier + ESLint rules. Name files and folders to reflect their dashboard domain (production, quality, ops).

Architecture & Directory Rules
Adhere to a monorepo style with clear separation:
- backend: apps/backend/src
- frontend: apps/frontend/src
- shared: packages/common/src
Dashboards should live under dashboards/production, dashboards/quality, dashboards/ops modules.

Authentication & Security Rules
Implement RS256 JWT validation for API routes, enforce server-side authorization checks for data access, avoid leaking credentials to the client, and sanitize inputs to prevent SQL injection.

Database and ORM patterns
PostgreSQL is the primary data store. Use parameterized queries; avoid string concatenation for IDs or raw SQL. Use a lightweight ORM or query builder on the server boundary; never access DB directly from the client.

Testing & Linting Workflows
Unit tests (Jest) for backend services; React Testing Library for frontend; Cypress for integration tests. Include linting on commit and CI with GitHub Actions: lint, test, build, and E2E steps.

Prohibited Actions and Anti-patterns for the AI
Do not bypass authentication checks. Do not generate or expose real secrets in outputs. Do not rely on uncontrolled data sources. Do not create non-deterministic outputs or assume data shapes without validation.

Recommended Project Structure

project-root/
  apps/
    backend/
      src/
        main.ts
        controllers/
        services/
        db/
        routes/
      package.json
    frontend/
      src/
        pages/
        components/
        hooks/
        dashboards/
      package.json
  data/
    marts/
      production/
        production_orders.sql
        cycle_times.sql
        scrap_rates.sql
  shared/
    lib/
    types/

Core Engineering Principles

  • Strong typing and explicit data contracts across backend and frontend
  • Deterministic AI-driven code generation with auditable outputs
  • Clear separation of concerns between data access, business logic, and presentation
  • Security-first design for analytics data
  • Test-drive development with automated tests and CI

Code Construction Rules

  • Every API endpoint that serves dashboard data must validate inputs and enforce user roles
  • All database queries must be parameterized; avoid string concatenation
  • Type-safe DTOs must be used for all API responses
  • Frontend components must be data-driven with proper prop types and fallbacks

Security and Production Rules

  • Use RS256 JWTs; tokens must be validated on the server with short-lived access tokens
  • Never embed database credentials in client bundles; fetch from server via secure endpoints
  • Enable audit logging for dashboard data access
  • Enforce CSP and HSTS in production

Testing Checklist

  • Backend: unit tests for services and data access; mock DB interactions
  • Frontend: component and integration tests for dashboard widgets
  • CI: lint, unit tests, integration tests, and E2E tests on PRs

Common Mistakes to Avoid

  • Assuming data shapes without validation
  • Exposing DB credentials in client code
  • Skipping input validation and sanitization
  • Unsafe SQL concatenation or dynamic query building without safeguards

Related implementation resources: AI Agent Use Case for Environmental Consultants Using Field Notes to Generate Regulatory Reports and Using Skill Files to Stop SQL Injection in Generated Backend Code.

FAQ

What is the purpose of this Cursor Rules Template?

This template provides a ready-to-paste .cursorrules block and stack-specific instructions to guide Cursor AI in building manufacturing analytics dashboards. It enforces architecture, security, and testing practices for a Node.js + PostgreSQL stack with a React frontend.

Which stack does this template target?

The template targets a modern Node.js + TypeScript backend, PostgreSQL data layer, and a React/Next.js frontend, focused on production orders, scrap rates, and cycle time analytics in manufacturing.

How do I insert the .cursorrules block into my project?

Copy the code block inside Copyable .cursorrules Configuration and paste it into your project root at the same level as package.json, then adjust paths to your monorepo structure while preserving the documented conventions.

What are the security considerations?

Enforce JWT-based authentication for API routes, validate inputs, avoid leaking secrets, and implement server-side access control for dashboard data. Use environment-scoped secrets and audit logging for data access.

What tests should I run?

Run unit tests for backend services, frontend component tests, and end-to-end tests for dashboard flows. Integrate tests in CI with linting and build steps to ensure PR quality.