RuleStack

Configs

Stacks

Compare

Diff

RuleStack

Configs

Stacks

Compare

Diff

Read API

RuleStack

Configs

Stacks

Compare

Diff

Read API

Configs/Cursor rules/madebyaris/poinf-of-sales

Cursor rule

.cursor/rules/backend-golang.mdc

Golang backend development patterns and conventions for POS System

Cursor rules

Quality

69/100

Scores the file, not the repository.

Length

510 words

24 headings · 4 code blocks

Repository

118

— · pushed 339 days ago

Last changed

3 days ago

First indexed 3 days ago.
madebyaris/poinf-of-sales/.cursor/rules/backend-golang.mdcRawGitHub
1---
2globs: *.go,go.mod,go.sum
3description: Golang backend development patterns and conventions for POS System
4---
5 
6# Backend Development Guidelines (Golang)
7 
8## Code Organization
9 
10### Package Structure
11Follow the [backend/internal/](mdc:backend/internal/) package layout:
12- `models/` - Data structures and DTOs
13- `handlers/` - HTTP request handlers
14- `middleware/` - HTTP middleware functions
15- `database/` - Database connection and utilities
16- `api/` - Route definitions and setup
17- `utils/` - Shared utility functions
18 
19### Handler Pattern
20All handlers follow the pattern in [handlers/orders.go](mdc:backend/internal/handlers/orders.go):
21 
22```go
23type OrderHandler struct {
24 db *sql.DB
25}
26 
27func NewOrderHandler(db *sql.DB) *OrderHandler {
28 return &OrderHandler{db: db}
29}
30 
31func (h *OrderHandler) GetOrders(c *gin.Context) {
32 // Implementation
33}
34```
35 
36## Database Operations
37 
38### Raw SQL Usage
39- Use parameterized queries to prevent SQL injection
40- Follow the patterns in [handlers/orders.go](mdc:backend/internal/handlers/orders.go) for database operations
41- Always handle `sql.ErrNoRows` explicitly
42- Use transactions for multi-table operations
43 
44### Example Query Pattern:
45```go
46func (h *Handler) getRecord(id uuid.UUID) (*Model, error) {
47 var record Model
48 query := `SELECT id, field1, field2 FROM table WHERE id = $1`
49
50 err := h.db.QueryRow(query, id).Scan(&record.ID, &record.Field1, &record.Field2)
51 if err == sql.ErrNoRows {
52 return nil, fmt.Errorf("record not found")
53 }
54 if err != nil {
55 return nil, fmt.Errorf("database error: %w", err)
56 }
57
58 return &record, nil
59}
60```
61 
62## Authentication & Security
63 
64### JWT Middleware
65Use the authentication middleware from [middleware/auth.go](mdc:backend/internal/middleware/auth.go):
66- Protected routes must use `authMiddleware`
67- Role-based access with `RequireRoles([]string{"admin", "manager"})`
68- Extract user info with `GetUserFromContext(c)`
69 
70### Error Handling
71Follow the API response pattern from [models/models.go](mdc:backend/internal/models/models.go):
72 
73```go
74c.JSON(http.StatusBadRequest, models.APIResponse{
75 Success: false,
76 Message: "User-friendly error message",
77 Error: stringPtr("error_code"),
78})
79```
80 
81## API Endpoints
82 
83### RESTful Design
84Follow REST conventions as shown in [api/routes.go](mdc:backend/internal/api/routes.go):
85- `GET /api/v1/orders` - List resources
86- `POST /api/v1/orders` - Create resource
87- `GET /api/v1/orders/:id` - Get single resource
88- `PUT /api/v1/orders/:id` - Update entire resource
89- `PATCH /api/v1/orders/:id/status` - Partial update
90- `DELETE /api/v1/orders/:id` - Delete resource
91 
92### Response Format
93All API responses use the standard format from [models/models.go](mdc:backend/internal/models/models.go):
94 
95```go
96type APIResponse struct {
97 Success bool `json:"success"`
98 Message string `json:"message"`
99 Data interface{} `json:"data,omitempty"`
100 Error *string `json:"error,omitempty"`
101}
102```
103 
104## Performance Best Practices
105 
106### Database Connections
107- Use connection pooling as configured in [database/connection.go](mdc:backend/internal/database/connection.go)
108- Set appropriate connection limits and timeouts
109- Always close rows and statements
110 
111### Query Optimization
112- Use indexes for frequently queried columns (see [database/init/01_schema.sql](mdc:database/init/01_schema.sql))
113- Avoid N+1 queries by using JOINs or batch loading
114- Implement pagination for large result sets
115 
116## Error Handling
117 
118### Database Errors
119- Always wrap database errors with context
120- Handle connection errors gracefully
121- Use the `IsConnectionError` helper from [database/connection.go](mdc:backend/internal/database/connection.go)
122 
123### HTTP Errors
124- Return appropriate HTTP status codes
125- Provide clear, actionable error messages
126- Don't expose internal system details to clients
127 
128## Testing Guidelines
129 
130### Unit Tests
131- Test handlers with mock database connections
132- Test middleware functions independently
133- Focus on business logic and edge cases
134 
135### Integration Tests
136- Test complete API endpoints
137- Use test database with proper cleanup
138- Test authentication and authorization flows
139 
140## Logging
141 
142### Structured Logging
143- Use Gin's built-in logging middleware
144- Log important business events (orders created, payments processed)
145- Include request IDs for tracing
146- Don't log sensitive information (passwords, tokens)

Sections

  • Backend Development Guidelines (Golang)
  • Code Organization
  • Package Structure
  • Handler Pattern
  • Database Operations
  • Raw SQL Usage
  • Example Query Pattern:
  • Authentication & Security
  • JWT Middleware
  • Error Handling
  • API Endpoints
  • RESTful Design
  • Response Format
  • Performance Best Practices
  • Database Connections
  • Query Optimization
  • Error Handling
  • Database Errors
  • HTTP Errors
  • Testing Guidelines
  • Unit Tests
  • Integration Tests
  • Logging
  • Structured Logging

What it covers

testlint-formatcode-stylearchitecturetesting-strategysecuritydatabaseapiperformance

Stack — with the evidence

typescript

(1.00)

react

(1.00)

tailwind

(1.00)

docker

(1.00)

vite

(0.70)

eslint

(0.70)

javascript

(0.50)

Glob targeting

  • *.go
  • go.mod
  • go.sum

Format

Cursor rules

The most expressive format here. Many small .mdc files, each with frontmatter declaring when it should load, so a rule about migrations only enters context when a migration is open. Costs the most to maintain and only one editor reads it.

What the corpus says about it

Repository

Owner
madebyaris
Language
—
License
—
Archived
no

All configs in this repo

Also in madebyaris/poinf-of-sales

Diff this repo’s formats

One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?

The other instruction files in this repository
RepositoryFormatStackCoversScoreChanged
madebyaris/poinf-of-sales.cursor/rules/admin-interface-patterns.mdc · 118Cursor rulestypescriptreact+5stylearchsecurityapi+262/1003 days ago
madebyaris/poinf-of-sales.cursor/rules/api-patterns.mdc · 118Cursor rulestypescriptreact+5lint-formatstylesecuritydatabase+362/1003 days ago
madebyaris/poinf-of-sales.cursor/rules/authentication-and-security-patterns.mdc · 118Cursor rulestypescriptreact+5setupteststylesecurity+481/1003 days ago
madebyaris/poinf-of-sales.cursor/rules/business-logic-patterns.mdc · 118Cursor rulestypescriptreact+5teststyledatabaseperformance+150/1003 days ago
madebyaris/poinf-of-sales.cursor/rules/database-patterns.mdc · 118Cursor rulestypescriptreact+5stylearchtypessecurity+262/1003 days ago
madebyaris/poinf-of-sales.cursor/rules/development-workflow.mdc · 118Cursor rulestypescriptreact+5setupbuildteststyle+386/1003 days ago
madebyaris/poinf-of-sales.cursor/rules/docker-deployment.mdc · 118Cursor rulestypescriptreact+6setupbuildteststyle+877/1003 days ago
madebyaris/poinf-of-sales.cursor/rules/frontend-react.mdc · 118Cursor rulestypescriptreact+5buildtestlint-formatstyle+469/1003 days ago
madebyaris/poinf-of-sales.cursor/rules/makefile-scripting.mdc · 118Cursor rulestypescriptreact+5setuplint-formatstylearch+281/1003 days ago
madebyaris/poinf-of-sales.cursor/rules/performance-optimization-patterns.mdc · 118Cursor rulestypescriptreact+5buildteststyledatabase+366/1003 days ago
madebyaris/poinf-of-sales.cursor/rules/project-architecture.mdc · 118Cursor rulestypescriptreact+5setupteststylearch+678/1003 days ago
madebyaris/poinf-of-sales.cursor/rules/react-native-mobile-patterns.mdc · 118Cursor rulestypescriptreact+5buildstylearchui+274/1003 days ago
madebyaris/poinf-of-sales.cursor/rules/role-based-access-patterns.mdc · 118Cursor rulestypescriptreact+5styletypessecuritydatabase+258/1003 days ago
madebyaris/poinf-of-sales.cursor/rules/tech-debt-prevention.mdc · 118Cursor rulestypescriptreact+5styletesting-strategyui50/1003 days ago
madebyaris/poinf-of-sales.cursor/rules/testing-patterns.mdc · 118Cursor rulestypescriptreact+6setupteststylearch+474/1003 days ago
madebyaris/poinf-of-sales.cursor/rules/user-journey-optimization.mdc · 118Cursor rulestypescriptreact+5styleperformanceagent-behaviour50/1003 days ago
Diff against .cursor/rules/admin-interface-patterns.mdc Diff against .cursor/rules/api-patterns.mdc Diff against .cursor/rules/authentication-and-security-patterns.mdc Diff against .cursor/rules/business-logic-patterns.mdc Diff against .cursor/rules/database-patterns.mdc Diff against .cursor/rules/development-workflow.mdc Diff against .cursor/rules/docker-deployment.mdc Diff against .cursor/rules/frontend-react.mdc Diff against .cursor/rules/makefile-scripting.mdc Diff against .cursor/rules/performance-optimization-patterns.mdc Diff against .cursor/rules/project-architecture.mdc Diff against .cursor/rules/react-native-mobile-patterns.mdc Diff against .cursor/rules/role-based-access-patterns.mdc Diff against .cursor/rules/tech-debt-prevention.mdc Diff against .cursor/rules/testing-patterns.mdc Diff against .cursor/rules/user-journey-optimization.mdc

Similar configs

Same format, overlapping stack, ranked by quality.

Same format, overlapping stack, ranked by quality
RepositoryFormatStackCoversScoreChanged
hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126Cursor rulesgobun+5setupbuildtestlint-format+6100/1003 days ago
TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45Cursor rulestypescriptpytest+15testlint-formatstylearch+5100/1003 days ago
markstev/mark-starter.cursor/rules/frontend.mdc · 0Cursor rulestypescriptturborepo+14setuptestlint-formatstyle+699/1003 days ago
Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0Cursor rulestypescriptturborepo+13setuptestlint-formatstyle+799/1003 days ago
dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0Cursor rulestypescriptturborepo+15setuptestlint-formatstyle+799/1003 days ago
deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1Cursor rulestypescriptnextjs+5setuptestlint-formatstyle+799/1003 days ago
langflow-ai/langflow.cursor/rules/docs_development.mdc · 153kCursor rulespythonnode+16setupbuildtestlint-format+797/1003 days ago
TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45Cursor rulestypescriptpytest+15teststyletesting-strategysecurity+397/1003 days ago
RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack