Cursor Rules TemplatesCursor Rules Template

Cursor Rules Template: Waste Management Operations Dashboard

Cursor Rules Template for a Waste Management Operations Dashboard, tailored for a Node.js + PostgreSQL stack with Cursor AI. Includes a copyable .cursorrules block and stack-specific guidance.

.cursorrules templatecursor rulescursor-rules-waste-dashboardwaste managementdashboardnodejstypescriptpostgresqlcursor-aiapi designtesting

Target User

Developers building data-driven dashboards with Cursor AI

Use Cases

  • Model collection routes for waste pickup
  • Track recycling volumes and material throughput
  • Capture costs and operational expenditures
  • Forecast demand, volumes, and costs for next quarters

Markdown Template

Cursor Rules Template: Waste Management Operations Dashboard

FrameworkRoleContext:
  Role: Senior Backend Engineer for a Waste Management Operations Dashboard using Node.js + TypeScript (Express) and PostgreSQL.
  Context:
    - Project root contains /apps/api (backend), /apps/dashboard (frontend), /db (migrations)
    - Data models: CollectionRoute, RecyclingVolume, Cost, Forecast
    - Cursor AI to guide API design, data contracts, and query optimization
CodeStyleAndGuides:
  - TypeScript with strict settings, ESLint, and Prettier
  - Use explicit types; no any; prefer DTOs for API boundaries
  - Enforce consistent naming, e.g., snake_case for DB, camelCase for JS/TS
ArchitectureAndDirectoryRules:
  - /apps/api backend with src/controllers, src/models, src/routes
  - /apps/dashboard frontend with src/pages, src/components
  - /db migrations and seeds in /db
  - /packages/shared for types and contracts
  - Use path aliases like @app/* to access modules
AuthenticationAndSecurityRules:
  - Use JWT with short-lived access tokens; refresh tokens in httpOnly cookies
  - Enforce CSRF protection for state-changing requests
  - Validate all inputs server-side; sanitize outputs; avoid leaking stack traces
DatabaseAndOrmPatterns:
  - PostgreSQL as the primary data store
  - Use node-postgres (pg) with parameterized queries
  - Data models: CollectionRoute, RecyclingVolume, Cost, Forecast, User
  - No heavy ORM abstractions; prefer lightweight query builders if needed
TestingAndLintingWorkflows:
  - Unit tests with Jest or Vitest
  - Integration tests with Supertest for API layers
  - Lint with ESLint; format with Prettier; type checks with tsc
  - CI pipeline runs tests, linting, and type checks on each PR
ProhibitedActionsAndAntiPatternsForAI:
  - Do not fetch secrets in client code or commit secrets
  - Do not bypass input validation or rely on unchecked user input
  - Do not perform unsafe dynamic code execution or eval
  - Do not generate database migrations without validation checks

Overview

Cursor rules configuration for Cursor AI is a copyable .cursorrules block intended for a Waste Management Operations Dashboard stack. This template targets a Node.js + TypeScript backend (Express) with PostgreSQL and a React frontend, modeling collection routes, recycling volumes, costs, and forecasts. It provides structure, constraints, and guardrails to guide AI-assisted implementation.

Direct answer: paste the included .cursorrules block into your project root to enable Cursor AI to generate, validate, and enforce code and data contracts for this stack.

When to Use These Cursor Rules

  • Starting a data-driven waste management dashboard on a Node.js + PostgreSQL stack
  • Standardizing API contracts, data models, and queries for routes, volumes, and forecasts
  • Guiding Cursor AI to enforce security, validation, and testing before deployment
  • Ensuring code style consistency across backend and frontend in a monorepo

Copyable .cursorrules Configuration

FrameworkRoleContext:
  Role: Senior Backend Engineer for a Waste Management Operations Dashboard using Node.js + TypeScript (Express) and PostgreSQL.
  Context:
    - Project root contains /apps/api (backend), /apps/dashboard (frontend), /db (migrations)
    - Data models: CollectionRoute, RecyclingVolume, Cost, Forecast
    - Cursor AI to guide API design, data contracts, and query optimization
CodeStyleAndGuides:
  - TypeScript with strict settings, ESLint, and Prettier
  - Use explicit types; no any; prefer DTOs for API boundaries
  - Enforce consistent naming, e.g., snake_case for DB, camelCase for JS/TS
ArchitectureAndDirectoryRules:
  - /apps/api backend with src/controllers, src/models, src/routes
  - /apps/dashboard frontend with src/pages, src/components
  - /db migrations and seeds in /db
  - /packages/shared for types and contracts
  - Use path aliases like @app/* to access modules
AuthenticationAndSecurityRules:
  - Use JWT with short-lived access tokens; refresh tokens in httpOnly cookies
  - Enforce CSRF protection for state-changing requests
  - Validate all inputs server-side; sanitize outputs; avoid leaking stack traces
DatabaseAndOrmPatterns:
  - PostgreSQL as the primary data store
  - Use node-postgres (pg) with parameterized queries
  - Data models: CollectionRoute, RecyclingVolume, Cost, Forecast, User
  - No heavy ORM abstractions; prefer lightweight query builders if needed
TestingAndLintingWorkflows:
  - Unit tests with Jest or Vitest
  - Integration tests with Supertest for API layers
  - Lint with ESLint; format with Prettier; type checks with tsc
  - CI pipeline runs tests, linting, and type checks on each PR
ProhibitedActionsAndAntiPatternsForAI:
  - Do not fetch secrets in client code or commit secrets
  - Do not bypass input validation or rely on unchecked user input
  - Do not perform unsafe dynamic code execution or eval
  - Do not generate database migrations without validation checks

Recommended Project Structure

.
├── apps
│   ├── api
│   │   └── src
│   │       ├── controllers
│   │       ├── models
│   │       ├── routes
│   │       └── index.ts
│   └── dashboard
│       └── src
│           ├── pages
│           ├── components
│           └── hooks
├── db
│   ├── migrations
│   └── seeds
├── packages
│   └── shared
└── scripts

Core Engineering Principles

  • Single source of truth for data contracts and API schemas
  • Strict typing and validation across backend and frontend
  • Security by default: proper auth, CSRF protection, and input validation
  • Clear separation of concerns between API, DB, and UI
  • Observability: structured logging, metrics, and tracing for data pipelines
  • Deterministic, testable code with repeatable CI workflows

Code Construction Rules

  • Use TypeScript end-to-end; define interfaces for all API payloads
  • Backend: parameterized SQL using pg; avoid string concatenation
  • Define and share data contracts in a /packages/shared directory
  • Naming: API endpoints under /api, DB tables named with snake_case
  • Frontend data fetching aligns with backend DTOs; avoid over-fetching
  • Directory structure stays monorepo-friendly with clear boundaries
  • Do not bypass validation or rely on client-side checks

Security and Production Rules

  • JWT-based authentication with short-lived access tokens
  • Refresh tokens stored in httpOnly cookies; CSRF protection enabled
  • All inputs validated server-side; outputs sanitized; proper error handling
  • Least-privilege database roles and parameterized queries
  • Secrets managed via environment variables or vault, not in code
  • CI/CD gates: lint, type-check, tests before deployment

Testing Checklist

  • Unit tests for all utilities and DTOs
  • Integration tests for API routes with a test DB
  • End-to-end tests for critical user journeys (dashboard data fetches)
  • Linters and type checks in CI
  • Migration tests to ensure idempotency

Common Mistakes to Avoid

  • Relying on frontend validation to secure API endpoints
  • Embedding secrets or credentials in code or migrations
  • Ignoring parameterized queries leading to SQL injection risks
  • Unclear data contracts causing drift between backend and UI
  • Over-engineering ORM layers for simple queries

Related Cursor rules templates

Explore adjacent Cursor rules templates for similar stacks, workflows, and production constraints.

FAQ

What is a Cursor Rules Template for a waste management dashboard?

This Cursor Rules Template provides a ready-to-paste copyable .cursorrules configuration along with stack-specific guidance to implement a Node.js + PostgreSQL waste dashboard. It defines roles, architecture, security, and testing rules so Cursor AI can assist throughout the development lifecycle.

Which stack is this template written for?

The template targets a Node.js + TypeScript backend (Express) with PostgreSQL and a React frontend. It uses a lightweight approach to data access (pg) and avoids heavy ORMs, ensuring clean data contracts and reliable SQL.

How do I use the copyable .cursorrules block?

Copy the block into your project root as the basis for Cursor AI guidance. Then adjust paths and model names to match your database schema and API surface while preserving the defined constraints and anti-patterns.

Can I adapt this template for other data models?

Yes. The template describes a waste dashboard domain but the structure—roles, architecture rules, validation, and testing—applies to any data-driven dashboard. Replace models like CollectionRoute and Forecast with your own domain entities, keeping the same contract and security approach.

Does this cover security and production readiness?

Yes. It includes token-based authentication, CSRF protections, input validation, and secure handling of secrets, plus CI/CD checks and migration safety. Adapt the policies to your environment while maintaining a strict security baseline.