Cursor Rules Template: Hotel Guest Feedback Analysis Tool
Cursor rules template for building a hotel guest feedback analysis tool using Python FastAPI and PostgreSQL with Cursor AI.
Target User
Developers building hotel guest feedback analytics with Cursor AI
Use Cases
- Sentiment analysis of guest reviews
- Topic modeling and tagging of feedback
- Analytics dashboard with KPI trends
- Batch processing of feedback data for nightly reports
Markdown Template
Cursor Rules Template: Hotel Guest Feedback Analysis Tool
.cursorrules
Framework Role & Context:
- Role: Lead Python engineer building a hotel guest feedback analysis tool
- Context: You are implementing a FastAPI in Python 3.11 backend with PostgreSQL and SQLAlchemy async ORM. Cursor AI should generate safe, testable code and data flow diagrams for sentiment analysis and topic tagging of guest reviews.
Code Style and Style Guides:
- Language: Python 3.11
- Formatting: Black, isort
- Linting: Ruff
- Type hints: Optional typing with Pydantic models for schemas
- Documentation style: docstrings with following descriptive blocks
Architecture & Directory Rules:
- Project root contains app, tests, migrations, configs
- app contains core, api, models, schemas, services, and db modules
- API routes under app.api.v1 endpoints
- Use Async SQLAlchemy for DB operations
Authentication & Security Rules:
- Use OAuth2 password flow with JWT access tokens
- Token expiry and refresh handling in dependencies
- Secrets loaded from environment only; no hard coded values
Database and ORM patterns:
- PostgreSQL as the database; SQLAlchemy 2.0 async ORM with AsyncSession
- Alembic migrations for schema changes
- Models: GuestFeedback, AnalysisJob, SentimentScore, TopicTag
- Use parameterized queries to prevent SQL injection
Testing & Linting Workflows:
- Pytest for unit and integration tests; pytest-asyncio for async tests
- CI runs with lint check, tests, and type checks
- Tests mock external calls and avoid real network dependencies
Prohibited Actions and Anti-patterns for the AI:
- Do not embed credentials in code samples
- Do not bypass input validation or authentication checks
- Do not execute real network IO in unit tests
- Do not rely on mutable global state in startup codeOverview
This Cursor rules template documents a complete Cursor AI configuration for building a hotel guest feedback analysis tool using Python 3.11, FastAPI, PostgreSQL, and SQLAlchemy. It provides a copyable .cursorrules block that guides AI prompts, code style, architecture, and security to produce production-ready code paths and data flows for hospitality analytics.
Direct answer: Use this Cursor rules configuration to enforce a Python FastAPI backend with robust data models, async DB access, and safe AI-assisted implementation for processing guest reviews into actionable insights.
When to Use These Cursor Rules
- Starting a new hotel feedback analysis project that uses Python and PostgreSQL.
- Enforcing a clean architecture with clear domain models for reviewers, feedback items, and analysis jobs.
- Ensuring consistent code style, testing, and security across the API surface.
- Integrating Cursor AI prompts to generate data transformation, NLP pipelines, and reporting queries with safety constraints.
Copyable .cursorrules Configuration
.cursorrules
Framework Role & Context:
- Role: Lead Python engineer building a hotel guest feedback analysis tool
- Context: You are implementing a FastAPI in Python 3.11 backend with PostgreSQL and SQLAlchemy async ORM. Cursor AI should generate safe, testable code and data flow diagrams for sentiment analysis and topic tagging of guest reviews.
Code Style and Style Guides:
- Language: Python 3.11
- Formatting: Black, isort
- Linting: Ruff
- Type hints: Optional typing with Pydantic models for schemas
- Documentation style: docstrings with following descriptive blocks
Architecture & Directory Rules:
- Project root contains app, tests, migrations, configs
- app contains core, api, models, schemas, services, and db modules
- API routes under app.api.v1 endpoints
- Use Async SQLAlchemy for DB operations
Authentication & Security Rules:
- Use OAuth2 password flow with JWT access tokens
- Token expiry and refresh handling in dependencies
- Secrets loaded from environment only; no hard coded values
Database and ORM patterns:
- PostgreSQL as the database; SQLAlchemy 2.0 async ORM with AsyncSession
- Alembic migrations for schema changes
- Models: GuestFeedback, AnalysisJob, SentimentScore, TopicTag
- Use parameterized queries to prevent SQL injection
Testing & Linting Workflows:
- Pytest for unit and integration tests; pytest-asyncio for async tests
- CI runs with lint check, tests, and type checks
- Tests mock external calls and avoid real network dependencies
Prohibited Actions and Anti-patterns for the AI:
- Do not embed credentials in code samples
- Do not bypass input validation or authentication checks
- Do not execute real network IO in unit tests
- Do not rely on mutable global state in startup code
Recommended Project Structure
hotel-feedback/
├── app/
│ ├── api/
│ │ └── v1/
│ │ ├── endpoints/
│ │ │ └── feedback.py
│ │ └── __init__.py
│ ├── core/
│ │ ├── config.py
│ │ │ └── logging.py
│ ├── models/
│ │ ├── feedback.py
│ │ ├── job.py
│ │ └── sentiment.py
│ ├── schemas/
│ │ └── __init__.py
│ ├── services/
│ │ └── analysis.py
│ └── db/
│ └── session.py
├── migrations/
├── tests/
├── requirements.txt
├── Dockerfile
└── docker-compose.yml
Core Engineering Principles
- Explicit boundaries between API, domain, and data layers
- Type safety with Pydantic models and explicit return types
- Secure by design: validate inputs, sanitize outputs, and minimize surface area
- Idempotent operations for data processing jobs
- Observability through structured logging and tracing
- Test-driven development and CI enforced checks
- Safe AI usage with Cursor rules that prevent leakage of secrets
Code Construction Rules
- Use FastAPI routers and dependencies for authentication, rate limiting, and DB sessions
- Define Pydantic models for request and response payloads with strict validation
- Async DB access via SQLAlchemy 2.0 and AsyncSession
- Alembic migrations for all schema changes
- All business logic in services, not in route handlers
- Cursor AI prompts must produce deterministic code paths and avoid unsafe patterns
- Schema-aware API responses to reduce data leakage
Security and Production Rules
- OAuth2 with JWT tokens for API authentication; token expiry enforced
- Environment-based secrets loading; no hard coded keys
- Input validation and output sanitization at API boundaries
- Parameterized queries and ORM usage to prevent SQL injections
- Audit logs for data access and job processing
- Containerized deployments with verified images and minimal privileges
Testing Checklist
- Unit tests for models, services, and API endpoints
- Integration tests covering data flow from API to the database
- Async tests for background jobs and queues
- End-to-end tests simulate guest feedback ingestion and analysis results
- CI runs linting, tests, and type checks on push/pull requests
Common Mistakes to Avoid
- Skipping input validation and relying on client-side checks
- Mixing business logic into route handlers
- Using blocking I/O in async endpoints
- Forgetting migrations or using direct schema edits in production
- Exposing secrets in logs or error messages
Related implementation resources: AI Use Case for Geotechnical Firms Using Core Sample Records To Predict Soil Stability for Heavy Foundation Building and Skill Files for Faster Market Testing: CLAUDE.md Templates for Founders.
FAQ
What is a Cursor Rules Template and why is it used for hotel feedback tools?
A Cursor Rules Template provides a ready to paste set of prompts and constraints that guide Cursor AI to generate consistent, production-ready code, data models, and workflows for hotel guest feedback analysis tools built with a Python FastAPI and PostgreSQL stack.
Can I customize the rules for my specific database or framework?
Yes. The template defines core patterns and anti patterns, but you can adjust ORM choices, authentication methods, and API design to match your stack while preserving safe AI-driven generation practices.
What stack does this template target?
Python 3.11, FastAPI, PostgreSQL with SQLAlchemy, Pydantic models, Alembic migrations, and Cursor AI for guidance and code generation within a secure, testable workflow.
How do I maintain security when using Cursor AI?
Treat Cursor prompts as guidance for code structure and data handling. Do not embed secrets, ensure token validation, use environment variables, and enforce strict input validation and access controls in every API call.
What should I test first when implementing this tool?
Start with unit tests for data models and validators, then integration tests for API endpoints and database interactions, followed by end-to-end tests that cover ingestion of guest reviews and generation of sentiment and topic analytics.