NAM-APJATEL-BACKEND/repository/AGENTS.md

707 B

OVERVIEW

Repository layer for NAM with 13 repos using interface-driven design and GORM transactions.

WHERE TO LOOK

  • repository/ for all implementations
  • Interface: {Entity}Repo, Constructor: New{Entity}Repo(db *gorm.DB)
  • Transaction pattern: db.Transaction(func(tx *gorm.DB) error {...})
  • Files: devices_repo.go, users_repo.go, tower_repo.go, olt_repo.go, etc.

CONVENTIONS

  • Interface naming: {Entity}Repo
  • Constructor: New{Entity}Repo(db *gorm.DB) {Entity}Repo
  • Return (data, error) pairs
  • Use wrapped errors for context

ANTI-PATTERNS

  • Skip transactions for mutating operations
  • Return nil error on failures
  • Embed business logic in repos
  • Instantiate DB connections inside repos