690514:2019 204-rfa-approval-refactor #01
CI / CD Pipeline / build (push) Successful in 6m1s
CI / CD Pipeline / deploy (push) Failing after 6m42s

This commit is contained in:
2026-05-14 20:19:21 +07:00
parent 07cc6d47b1
commit 0240d80da5
183 changed files with 20050 additions and 1017 deletions
@@ -0,0 +1,29 @@
// File: docs/ai-knowledge-base/prompts/core/coding-standards.md
# Coding Standards & Best Practices
## ✅ General Guidelines
- **English for Code**: ใช้ภาษาอังกฤษสำหรับตัวแปร, ชื่อฟังก์ชัน และ logic
- **Thai for Comments**: ใช้ภาษาไทยสำหรับการอธิบาย code, JSDoc และ Documentation
- **Strict Typing**: ห้ามใช้ `any` เด็ดขาด ให้ใช้ Interface หรือ Type เสมอ
- **Single Export**: 1 ไฟล์ควร Export เพียง 1 สัญลักษณ์หลัก
- **File Headers**: ทุกไฟล์ต้องมี `// File: path` และ `// Change Log`
## 🆔 Identifier Strategy (ADR-019)
- **Database PK**: ใช้ `INT AUTO_INCREMENT` (ห้ามเปิดเผยผ่าน API)
- **Public ID**: ใช้ `UUIDv7` สำหรับการอ้างอิงผ่าน API และ URL เท่านั้น
- **Frontend**: ใช้ `publicId` เพียงอย่างเดียว ห้ามใช้ `parseInt()` กับ UUID
## 🛡️ Security & Integrity
- **Idempotency**: ทุกการเขียนข้อมูล (POST/PUT/PATCH) ต้องรองรับ `Idempotency-Key`
- **RBAC**: ตรวจสอบสิทธิ์ผ่าน CASL Guard เสมอ
- **Data Isolation**: AI ห้ามเข้าถึง Database โดยตรง ต้องผ่าน API เท่านั้น
- **Validation**: ใช้ Zod (Frontend) และ class-validator (Backend)
## 🏗️ Architecture
- **Backend**: Thin Controller -> Service (Business Logic) -> Repository/Entity
- **Frontend**: ใช้ Component จาก shadcn/ui และจัดการ State ด้วย TanStack Query
- **Async Tasks**: งานที่ใช้เวลานานต้องส่งเข้า BullMQ เสมอ
---
// Change Log:
// - 2026-05-14: Consolidated coding standards from AGENTS.md