josh0312 nytex_dashboard .cursorrules file for Python

// HTMX Basic Setup .cursorrules

// HTMX best practices
const htmxBestPractices = [
  "Use hx-get for GET requests",
  "Implement hx-post for POST requests",
  "Utilize hx-trigger for custom events",
  "Use hx-swap to control how content is swapped",
  "Implement hx-target to specify where to swap content",
  "Utilize hx-indicator for loading indicators",
];

// FastAPI best practices
const fastAPIBestPractices = [
  "Use async/await for database operations",
  "Implement proper type hints",
  "Use Pydantic models for request/response validation",
  "Organize routes using APIRouter with tags",
  "Use dependency injection for shared logic",
  "Implement proper error handling with HTTPException",
  "Return FileResponse for file downloads",
  "Use async context managers for database sessions",
];

// Database and Query Patterns
const databasePatterns = {
  sqlQueries: {
    location: "app/database/queries/",
    naming: "${report_name}.sql",
    format: "SQL with comments explaining purpose and structure",
    bestPractices: [
      "Keep complex queries in separate .sql files",
      "Include detailed comments explaining the query",
      "Use CTEs for better readability",
      "Document any assumptions or requirements",
      "Note the last updated date",
    ],
  },
  asyncOperations: {
    session: "Use async_session context manager",
    execution: "await session.execute(text(query))",
    transaction: "async with session.begin()",
  },
};

// Export Patterns
const exportPatterns = {
  directory: "app/static/exports/",
  naming: "${query_name}_${timestamp}.xlsx",
  formats: ["Excel", "CSV", "PDF"],
  handling: [
    "Generate unique filenames with timestamps",
    "Clean up old export files periodically",
    "Use appropriate MIME types",
    "Handle large datasets efficiently",
  ],
};

// Template Patterns
const templatePatterns = {
  inheritance: {
    base: "base.html",              // Base template with common structure
    layout: "layouts/report.html",   // Report-specific layout
    components: "components/*.html", // Reusable components
  },
  organization: {
    shared: "components/shared/",    // Shared across all reports
    category: "components/reports/", // Category-specific components
    report: "reports/",             // Individual report templates
  },
  bestPractices: [
    "Use template inheritance for consistent layouts",
    "Break complex templates into components",
    "Keep component-specific scripts with their templates",
    "Use consistent naming for template blocks",
  ],
};

// Project Structure
const projectStructure = `
app/
  ├── database/
  │   ├── models/      # SQLAlchemy models
  │   ├── schemas/     # Pydantic schemas
  │   └── queries/     # Raw SQL queries
  ├── routes/
  │   ├── reports/     # Report-specific routes
  │   ├── dashboard/   # Dashboard routes
  │   └── metrics/     # Metrics routes
  ├── services/        # Business logic layer
  │   └── reports/     # Report-specific services
  ├── templates/       # Jinja2 templates
  │   └── reports/     # Report templates
  └── static/
      ├── css/
      ├── js/
      └── exports/     # Generated report files
`;

// Additional instructions
const additionalInstructions = `
1. Use semantic HTML5 elements
2. Implement proper CSRF protection
3. Utilize HTMX extensions when needed
4. Use hx-boost for full page navigation
5. Implement proper error handling
6. Follow progressive enhancement principles
7. Use server-side templating (Jinja2)
8. Use async/await for database operations
9. Keep SQL queries in separate files
10. Use type hints consistently
11. Document complex SQL queries
12. Handle file exports securely
13. Use async context managers
14. Implement proper error logging
15. Follow template inheritance patterns
`;

// Report Structure
const reportStructure = {
  components: {
    landing: "index.html",          // Reports landing page
    categories: [
      "inventory",                  // Inventory reports
      "sales",                      // Sales reports
      "customers",                  // Customer reports
    ],
    features: [
      "filtering",                  // Report filtering
      "sorting",                    // Column sorting
      "export",                     // Excel export
      "print",                      // Print view
    ],
  },
  patterns: {
    query: "app/database/queries/", // SQL queries location
    route: "app/routes/reports/",   // FastAPI routes
    service: "app/services/reports/", // Business logic
    template: "app/templates/reports/", // HTML templates
  },
};
assembly
batchfile
c
c++
css
cython
fastapi
golang
+6 more

First Time Repository

Python

Languages:

Assembly: 3.0KB
Batchfile: 0.1KB
C: 70.9KB
C++: 267.1KB
CSS: 5.9KB
Cython: 399.9KB
HTML: 65.8KB
JavaScript: 11.0KB
Mako: 20.2KB
PowerShell: 8.6KB
Python: 23905.8KB
Shell: 2.8KB
Created: 12/28/2024
Updated: 1/1/2025

All Repositories (1)