backend.mdc 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. ---
  2. description:
  3. globs: **/**/*.go
  4. alwaysApply: false
  5. ---
  6. # Cursor Rules
  7. You are an expert in Go, Gin, Gorm, Gen, Cosy (https://cosy.uozi.org/) with a deep understanding of best practices and performance optimization techniques in these technologies.
  8. ## 1. Code Style and Structure
  9. - **Concise and Maintainable Code:**
  10. Write technically accurate and easily understandable Go code with relevant examples.
  11. - **API Controllers:**
  12. Implement API controllers in the `api/$modules_name` directory.
  13. - **Database Models:**
  14. Define database table models in the `model/` folder.
  15. - **Query Simplification:**
  16. Use [Gen](mdc:https:/cosy.uozi.org) to streamline query operations, reducing boilerplate code.
  17. - **Business Logic and Error Handling:**
  18. Place complex API logic and custom error definitions in `internal/$modules_name`. Follow the best practices outlined in the [Cosy Error Handler](mdc:https:/cosy.uozi.org/error-handler).
  19. - **Routing:**
  20. Register all application routes in the `router/` directory.
  21. - **Configuration Management:**
  22. Manage and register configuration settings in the `settings/` directory.
  23. ## 2. CRUD Operations
  24. - **Standardized Operations:**
  25. Utilize [Cosy](mdc:https:/cosy.uozi.org) to implement Create, Read, Update, and Delete (CRUD) operations consistently across the project.
  26. ## 3. Performance Optimization
  27. - **Efficient Database Pagination:**
  28. Implement database pagination techniques to handle large datasets efficiently.
  29. - **Overall Performance:**
  30. Apply performance optimization techniques to ensure fast response times and resource efficiency.
  31. ## 4. File Organization and Formatting
  32. - **Modular Files:**
  33. Keep individual files concise by splitting code based on functionality, promoting better readability and maintainability.
  34. - **Consistent Syntax and Formatting:**
  35. Follow consistent coding standards and formatting rules across the project to enhance clarity.
  36. ## 5. Documentation and Comments
  37. - **English Language:**
  38. All code comments and documentation should be written in English to maintain consistency and accessibility.