Cursor Rules TemplatesCursor Rules Template

Inventory Reorder Cursor Rules Template for Wholesale SMEs | Cursor Rules Template

Cursor Rules Template for Node.js + PostgreSQL inventory reorder systems tailored to wholesale SMEs. Includes a copyable .cursorrules block and stack-specific guidelines.

.cursorrules templatecursor rules templateinventory reorderwholesale SMEsNode.jsPostgreSQLCursor AI rulesinventory managementlead timereorder pointsSQL

Target User

Developers building inventory reorder systems for wholesale SMEs

Use Cases

  • Compute reorder points based on stock and lead times
  • Forecast stockouts and optimize safety stock
  • Automate reorder recommendations across multiple warehouses
  • Audit AI-driven reorder decisions for compliance
  • Integrate with supplier lead-time data and order history

Markdown Template

Inventory Reorder Cursor Rules Template for Wholesale SMEs | Cursor Rules Template

.cursorrules
Framework: Node.js (TypeScript) + PostgreSQL
Context: Build an inventory reorder recommender for wholesale SMEs using Cursor AI. Target stack: Node.js, Express, TypeScript, PostgreSQL, and raw SQL via pg.
CodeStyle: Enforce ESLint + Prettier; TS strict; prefer named exports; use async/await; avoid callbacks; no implicit any.
Architecture & Directory Rules:
  - src/controllers/
  - src/services/
  - src/db/
  - src/routes/
  - src/middleware/
  - tests/
  - migrations/
  - config/
  - .env
Authentication & Security Rules:
  - JWTs for API authentication
  - RBAC with roles: admin, inventory_manager, analyst
  - Secrets stored in environment variables, rotated regularly
Database and ORM patterns:
  - PostgreSQL with parameterized SQL (pg)
  - No ORM; use explicit SQL in services
  - Tables: products, warehouses, stock, orders, reorder_points, suppliers, lead_times
Testing & Linting Workflows:
  - Unit tests for services, repositories
  - Integration tests for REST endpoints
  - ESLint, Prettier, Jest, and Stryker for mutation testing
Prohibited Actions and Anti-patterns for the AI:
  - Do not bypass input validation
  - Do not generate raw SQL via string concatenation
  - Do not perform destructive migrations in production without safeguards
  - Do not return sensitive fields in API responses
  - Do not assume ORM behavior when using raw SQL

Overview

Direct answer: This Cursor rules template configures a Node.js + PostgreSQL stack to build an inventory reorder recommendation system for wholesale SMEs. It defines the stack, architecture, and Cursor AI constraints. Paste the included .cursorrules configuration block into your project root to enforce consistent guidelines during development.

Cursor AI usage: The rules guide the AI to follow a production-ready pattern tailored for inventory reorder workloads on a Node.js + PostgreSQL stack.

When to Use These Cursor Rules

  • Building a reorder engine that factors stock levels, lead times, demand forecasts, and supplier data.
  • Enforcing consistent project structure, security controls, and testing across a Node.js + PostgreSQL codebase.
  • Adopting a SQL-first data access approach with parameterized queries for safety and predictability.
  • Working on wholesale SMEs where multi-warehouse and supplier variability are common.

Copyable .cursorrules Configuration

.cursorrules
Framework: Node.js (TypeScript) + PostgreSQL
Context: Build an inventory reorder recommender for wholesale SMEs using Cursor AI. Target stack: Node.js, Express, TypeScript, PostgreSQL, and raw SQL via pg.
CodeStyle: Enforce ESLint + Prettier; TS strict; prefer named exports; use async/await; avoid callbacks; no implicit any.
Architecture & Directory Rules:
  - src/controllers/
  - src/services/
  - src/db/
  - src/routes/
  - src/middleware/
  - tests/
  - migrations/
  - config/
  - .env
Authentication & Security Rules:
  - JWTs for API authentication
  - RBAC with roles: admin, inventory_manager, analyst
  - Secrets stored in environment variables, rotated regularly
Database and ORM patterns:
  - PostgreSQL with parameterized SQL (pg)
  - No ORM; use explicit SQL in services
  - Tables: products, warehouses, stock, orders, reorder_points, suppliers, lead_times
Testing & Linting Workflows:
  - Unit tests for services, repositories
  - Integration tests for REST endpoints
  - ESLint, Prettier, Jest, and Stryker for mutation testing
Prohibited Actions and Anti-patterns for the AI:
  - Do not bypass input validation
  - Do not generate raw SQL via string concatenation
  - Do not perform destructive migrations in production without safeguards
  - Do not return sensitive fields in API responses
  - Do not assume ORM behavior when using raw SQL

Recommended Project Structure

project-root/
src/
  controllers/
  services/
  routes/
  db/
  middleware/
  models/        # optional, if you introduce a data model abstraction
tests/
migrations/
config/
.env
package.json
tsconfig.json

Core Engineering Principles

  • Explicit boundaries between layers (controller, service, data) to reduce coupling.
  • Fail-fast input validation and typed interfaces for all components.
  • Principle of least privilege for authentication and data access.
  • Idempotent operations and clear error handling for API calls.
  • Observability: structured logging, metrics, and tracing for reorder decisions.

Code Construction Rules

  • Use TypeScript with strict mode; enable "noImplicitAny" and "strictNullChecks".
  • Prefer parameterized SQL to prevent injection; never interpolate user input into SQL strings.
  • Store credentials in environment variables; never commit secrets.
  • Organize code into clear layers: controllers, services, and data access.
  • Write unit tests for pure functions and services; integration tests for endpoints.
  • Document APIs via inline comments and simple README usage examples in the code.
  • Follow ESLint + Prettier formatting; run linting as part of CI.
  • Do not rely on global state; avoid side effects in modules that handle business logic.

Security and Production Rules

  • Use TLS for all external traffic; rotate API keys and DB credentials periodically.
  • Validate all inputs; implement server-side validation for business rules (stock, lead_time, demand).
  • Audit reorder decisions with deterministic seeds for testing reproducibility.
  • Limit API rate and implement proper authentication checks for sensitive endpoints.
  • Keep migrations versioned and guarded; run migrations in CI and pinned environments.

Testing Checklist

  • Unit tests for inventory domain logic (stock levels, reorder point calculation).
  • Integration tests for REST endpoints returning reorder recommendations.
  • End-to-end tests simulating real ordering scenarios and lead times.
  • Linting and type-checking in CI; run tests on PRs.
  • Test data resets and seed scripts for consistent runs.

Common Mistakes to Avoid

  • Hardcoding thresholds for reorder points; lack of configurability per warehouse.
  • Over-reliance on in-memory data for production workloads.
  • Skipping input validation or using unchecked user input in queries.
  • Neglecting security around secrets and API keys.

Related implementation resources: Using Skill Files to Stop SQL Injection in Generated Backend Code.

FAQ

What is this Cursor Rules Template for?

This template defines a production-ready Cursor AI configuration for building an inventory reorder recommender on Node.js + PostgreSQL. It establishes architecture, security, testing, and coding standards specific to wholesale SMEs, enabling safe and repeatable AI-assisted development.

Which stack does this template target?

The template targets Node.js with TypeScript, Express-style routing, and PostgreSQL as the primary data store, using raw SQL via the pg library rather than an ORM for full control over queries.

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

Copy the block from the Copyable section and paste it into a new .cursorrules file at your project root. Run your Cursor AI tool to apply the rules during code generation, ensuring the AI adheres to the constraints.

Can I customize this for different stock or warehouses?

Yes. The template supports per-warehouse configurations for lead times, stock thresholds, and reorder points. Update the database schema and configuration input to reflect each warehouse's values without altering core architecture.

Is this suitable for wholesale SMEs?

Yes. It emphasizes scalable stock handling, multiple suppliers, lead-time variability, and auditability—common needs for wholesale SMEs managing inventory breadth and supplier relationships.