Repository pattern ทำหน้าที่นามธรรม (abstract) การเข้าถึงข้อมูล ไว้เบื้องหลัง interface ที่มีลักษณะคล้าย collection โดยแยก business logic ออกจากวิธีการจัดเก็บและดึงข้อมูล มันช่วยลดการผูกติด (decouple) ระหว่างแอปพลิเคชันกับแหล่งข้อมูล (databases, APIs) ทำให้ทดสอบและบำรุงรักษาได้ง่ายขึ้น
Repository pattern ทำอะไร
REPOSITORY → an abstraction layer between business logic and DATA ACCESS:
→ provides a clean interface (like a collection: findById, save, delete, findAll)
→ HIDES how/where data is actually stored (database, API, cache, files)
→ business logic uses the repository, NOT the database directly
→ separate WHAT data operations from HOW they're implemented
