Cursor Rules Template: Django Subscription Box Platform
Cursor Rules Template for a Django-based subscription box ecommerce stack with recurring orders, inventory, Stripe billing, and a customer portal. Includes a copyable .cursorrules block and stack-specific project structure.
Target User
Backend engineers, full-stack developers, and platform teams building Django-based subscription ecommerce with recurring orders
Use Cases
- Bootstrap a Django-based subscription box platform with recurring orders
- Define inventory, billing, and customer portal workflows
- Standardize API contracts and data models for subscriptions
- Guide CI/CD, testing, and security patterns for production
- Provide a copyable .cursorrules block for Cursor AI integration
Markdown Template
Cursor Rules Template: Django Subscription Box Platform
Framework: Django
Context: You are a backend Django developer building a subscription box ecommerce platform with recurring orders, inventory management, Stripe billing, and a customer portal. You oversee API endpoints, ORM usage, security, and deployment considerations.
Role: Backend Engineer for Django stack
CodeStyle: PEP8, Black, isort
ArchitectureAndDirectoryRules:
- project_root/
- apps/subscriptions/
- apps/payments/
- apps/users/
- api/v1/
- templates/
- static/
AuthenticationAndSecurity:
- Use Django authentication with session auth for web and JWT for API if required
- Validate Stripe webhooks with signature verification
- Enforce HTTPS, CSRF protection on API endpoints, and secure cookie flags
DatabaseAndORM:
- PostgreSQL as the data store
- Django ORM with atomic transactions
- Use select_related and prefetch_related for query optimization
- Index foreign keys and frequently queried fields
TestingAndLinting:
- pytest-django for unit/integration tests
- flake8 and black for linting and formatting
- pre-commit hooks and GitHub Actions for CI
ProhibitedActionsAndAntiPatterns:
- Do not write raw SQL in views when ORM suffices
- Do not bypass ORM layer for reads/writes
- Do not expose sensitive keys in code or logs
- Do not hardcode secrets in migration filesOverview
The Cursor rules configuration provides a prescriptive, copyable set of rules that guide Cursor AI to assist in building a Django-based subscription box ecommerce platform with recurring orders, inventory management, Stripe billing, and a customer portal. This page includes a ready-to-paste .cursorrules block and stack-specific project structure tailored to this stack. Direct answer: paste the code block below into your project root; Cursor AI will generate stack-aligned backend models, API endpoints, and deployment guidance.
When to Use These Cursor Rules
- Starting a Django subscription box marketplace with recurring orders and inventory tracking.
- Defining project architecture, security layers, and billing integration in Cursor AI workflows.
- Ensuring consistent code style, testing, and CI/CD for a production-ready customer portal.
Copyable .cursorrules Configuration
Framework: Django
Context: You are a backend Django developer building a subscription box ecommerce platform with recurring orders, inventory management, Stripe billing, and a customer portal. You oversee API endpoints, ORM usage, security, and deployment considerations.
Role: Backend Engineer for Django stack
CodeStyle: PEP8, Black, isort
ArchitectureAndDirectoryRules:
- project_root/
- apps/subscriptions/
- apps/payments/
- apps/users/
- api/v1/
- templates/
- static/
AuthenticationAndSecurity:
- Use Django authentication with session auth for web and JWT for API if required
- Validate Stripe webhooks with signature verification
- Enforce HTTPS, CSRF protection on API endpoints, and secure cookie flags
DatabaseAndORM:
- PostgreSQL as the data store
- Django ORM with atomic transactions
- Use select_related and prefetch_related for query optimization
- Index foreign keys and frequently queried fields
TestingAndLinting:
- pytest-django for unit/integration tests
- flake8 and black for linting and formatting
- pre-commit hooks and GitHub Actions for CI
ProhibitedActionsAndAntiPatterns:
- Do not write raw SQL in views when ORM suffices
- Do not bypass ORM layer for reads/writes
- Do not expose sensitive keys in code or logs
- Do not hardcode secrets in migration files
Recommended Project Structure
django_subscription_project/
manage.py
django_subscription_project/
settings.py
urls.py
apps/
subscriptions/
__init__.py
models.py
views.py
urls.py
migrations/
tests/
payments/
__init__.py
models.py
views.py
urls.py
migrations/
users/
__init__.py
models.py
views.py
urls.py
api/
v1/
__init__.py
urls.py
serializers.py
templates/
static/
requirements.txt
Core Engineering Principles
- Single source of truth for data models via Django ORM.
- Explicit data validation and error handling at API boundaries.
- Security by default: secure cookies, CSRF protection, and signed webhook verification.
- Idempotent billing operations and robust webhook handling with Stripe.
- Test-driven development with a strong CI/CD pipeline.
Code Construction Rules
- Use Django models for subscriptions, orders, inventory, and customers.
- Keep business logic in services or domain layers, not in views.
- Validate inputs in forms or serializers before persisting.
- Document API contracts and data schemas in code comments.
- Follow Django recommendations for query optimization and migrations.
Security and Production Rules
- Store secrets in environment variables; never commit keys.
- Validate Stripe signatures for all webhook endpoints.
- Enable HTTPS, HSTS, and secure cookies in production.
- Limit API exposure with proper authentication and authorization checks.
Testing Checklist
- Unit tests for models and utilities.
- Integration tests for subscription flow and billing events.
- End-to-end tests for customer portal interactions.
- Automated linting, type checks, and dependency scans in CI.
Common Mistakes to Avoid
- Mixing business logic inside Django views or templates.
- Overfetching data or missing select_related optimization.
- Weak webhook verification or brittle billing flows.
- Ignoring migrations across environments or hardcoding secrets.
Related Cursor rules templates
Explore adjacent Cursor rules templates for similar stacks, workflows, and production constraints.
- Cursor Rules Template: LMS with Courses, Lessons, Quizzes, Certificates, Payments, and Admin Dashboard
- Cursor Rules Template: Podcast Management Stack
- Cursor Rules Template — Real Estate Dashboard with Cash Flow, ROI, and Analytics
- Cursor Rules Template: AI Tutor SaaS Stack
FAQ
What is a Cursor Rules Template?
A Cursor Rules Template is a copyable .cursorrules block designed for a specific stack. It guides Cursor AI to generate consistent, production-ready patterns for that stack, including architecture, security, tests, and project structure.
Which stack does this template cover?
This template targets Django with PostgreSQL for a subscription box ecommerce platform featuring recurring orders, inventory management, Stripe billing, and a customer portal. It aligns with Django ORM patterns and Stripe webhook flows.
What files should I paste into my project root?
Paste the .cursorrules block into your project root. It will instruct Cursor AI to generate or validate backend models, API endpoints, billing logic, and portal features within Django.
How does this template handle billing?
The template specifies Stripe-based billing with webhook verification, idempotent operations, and secure handling of customer invoices, subscriptions, and plans within the Django app and admin.
How do I adapt this for different payment providers?
Follow the Architecture and Security sections to swap Stripe specifics with the provider you choose, keeping API contracts, webhook verification, and security checks intact.