Cursor Rules TemplatesCursor Rules Template

Cursor Rules Template: Research Paper Summarization Toolkit for Consultants (Python + FastAPI)

Cursor Rules Template for a Python + FastAPI stack to build consultant-focused research paper summarization tools using Cursor AI.

.cursorrules templatecursor-rules-templatecursor-rules pythonCursor AI rulesresearch paper summarizationconsultantspythonfastapipostgresqlsqlalchemyci/cdlintingtesting

Target User

Backend/API engineers, AI engineers, data scientists, and consultants building research paper summarization tools.

Use Cases

  • Build a modular research paper summarization service that ingests PDFs or HTML, extracts abstracts, and summarizes with AI models; stores results in PostgreSQL; exposes APIs for downstream clients; ensures auditability and reproducibility.

Markdown Template

Cursor Rules Template: Research Paper Summarization Toolkit for Consultants (Python + FastAPI)

Framework Role & Context
Role: Cursor Engineer for Python + FastAPI research tool for consultants
Context: You generate scaffolded code and Cursor AI rules for a consultant-focused research paper summarization service.

Code Style and Style Guides
Style: PEP8, type hints, docstrings
Guides: mypy, flake8

Architecture & Directory Rules
Directory layout:
app/
  main.py
  api/
  core/
  models/
  services/
  schemas/
config/
migrations/
tests/

Authentication & Security Rules
Auth: OAuth2 with JWTs; TLS in production; secrets from environment

Database and ORM patterns
DB: PostgreSQL; ORM: SQLAlchemy; migrations via Alembic

Testing & Linting Workflows
Tests: pytest + pytest-cov; lint with flake8; pre-commit hooks; CI integration

Prohibited Actions and Anti-patterns for the AI
Do not embed real API keys or secrets
Do not bypass authentication or authorization checks
Do not bypass rate limits or data validation

Overview

Cursor rules configuration for building research paper summarization tools on the Python + FastAPI stack. This template provides a concrete, copyable .cursorrules block and project conventions to help consultants deliver safe AI-assisted summarization solutions with Cursor AI.

When to Use These Cursor Rules

  • When building a consultant-focused research paper summarization service using Python, FastAPI, PostgreSQL, and SQLAlchemy.
  • When you need a shareable, copyable .cursorrules configuration for onboarding engineers.
  • When enforcing secure data handling, reproducible experiments, and auditable AI interactions in client projects.

Copyable .cursorrules Configuration

Framework Role & Context
Role: Cursor Engineer for Python + FastAPI research tool for consultants
Context: You generate scaffolded code and Cursor AI rules for a consultant-focused research paper summarization service.

Code Style and Style Guides
Style: PEP8, type hints, docstrings
Guides: mypy, flake8

Architecture & Directory Rules
Directory layout:
app/
  main.py
  api/
  core/
  models/
  services/
  schemas/
config/
migrations/
tests/

Authentication & Security Rules
Auth: OAuth2 with JWTs; TLS in production; secrets from environment

Database and ORM patterns
DB: PostgreSQL; ORM: SQLAlchemy; migrations via Alembic

Testing & Linting Workflows
Tests: pytest + pytest-cov; lint with flake8; pre-commit hooks; CI integration

Prohibited Actions and Anti-patterns for the AI
Do not embed real API keys or secrets
Do not bypass authentication or authorization checks
Do not bypass rate limits or data validation

Recommended Project Structure

project/
  app/
    main.py
    api/
    core/
    models/
    services/
    schemas/
  config/
  migrations/
  tests/
  requirements.txt
  Dockerfile
  README.md

Core Engineering Principles

  • Clear separation of concerns between API, domain logic, and data access
  • Idempotent endpoints and deterministic model inference
  • Declarative validation and strict typing
  • Observability: structured logging and metrics
  • Security by default and defense-in-depth
  • Reproducible experimentation with deterministic seeds
  • Auditable AI interactions and traceable prompts

Code Construction Rules

  • Use FastAPI path operations with Pydantic schemas for input/output
  • Encapsulate business rules in service layer; keep API lean
  • Store summaries and provenance in PostgreSQL with SQLAlchemy models
  • Document endpoints with OpenAPI; keep examples deterministic
  • Validate inputs, sanitize outputs, and bound model sizes
  • Do not write raw SQL in handlers; use ORM with parameterized queries

Security and Production Rules

  • Enable TLS; enforce HSTS in production
  • Use OAuth2 with JWTs; short-lived access tokens; refresh tokens securely stored
  • Never log secrets; use environment-based config
  • Rate limit API endpoints; apply input validation to prevent DoS
  • Isolate database access; use read replicas for analytics

Testing Checklist

  • Unit tests for models and utilities
  • Integration tests for API endpoints and DB interactions
  • End-to-end tests for the data flow from upload to summarization output
  • Linting and type checks in CI; run tests on PRs

Common Mistakes to Avoid

  • Skipping input validation and error handling
  • Overusing global mutable state in the service layer
  • Ignoring data provenance and audit trails
  • Hard-coding secrets or keys in repository
  • Neglecting test coverage for edge cases in summarization

Related implementation resources: AI Use Case for Translation Agencies Using Sdl Trados To Pre-Translate Legal Documents Before Human Review and Connecting AI to Excel: Practical patterns for production-grade workflows.

FAQ

What is a Cursor Rules Template?

A Cursor Rules Template provides a copyable, stack-specific configuration that guides Cursor AI in building and enforcing architecture, security, and testing practices for a given tech stack. It helps consultants reproduce safe AI-assisted development workflows for their research paper summarization tools.

Which stack does this template target?

This template targets a Python + FastAPI backend with PostgreSQL via SQLAlchemy, designed for consultant-focused research paper summarization tools using Cursor AI.

How do I apply the copyable configuration?

Copy the .cursorrules block into the root of your project as .cursorrules and adjust paths, tokens, and environment-specific values. The block defines roles, architecture rules, security, and testing to guide Cursor AI in code generation and reviews.

What should I include in the project structure?

Include a clean Python package layout with app, models, services, and tests; migrations directory for Alembic; a config folder; and CI configuration. Keep dependencies controlled via requirements.txt or poetry.

How is security enforced in production?

Use TLS, OAuth2 with JWT, short-lived tokens, proper secret management, and least-privilege DB access. Enforce input validation, rate limiting, and regular code scanning in CI/CD.