Skip to content

02.03 สถาปัตยกรรมระบบ (System Architecture) ​


📌 At a Glance ​

รายการรายละเอียด
TopicSystem Architecture
Difficulty⭐⭐ Intermediate
Reading Time12 นาที
TargetSolution Architect, Developer, System Integrator
Related APIsAll APIs

⏱ Reading Time ​

ประมาณ 12 นาที


🎯 Learning Objectives ​

หลังจากศึกษาหัวข้อนี้แล้ว ผู้อ่านจะสามารถ

  • เข้าใจสถาปัตยกรรมของ SISAHYGO Integration Platform
  • เข้าใจหน้าที่ของแต่ละ Layer
  • เข้าใจการไหลของ Request และ Response
  • เข้าใจจุดที่ Business Logic ทำงาน
  • เข้าใจการแยกหน้าที่ของ Client System และ SISAHYGO

Overview ​

SISAHYGO Integration Platform ถูกออกแบบตามหลัก Layered Architecture เพื่อให้ระบบสามารถขยายตัว ดูแลรักษา และพัฒนาต่อยอดได้ในระยะยาว

สถาปัตยกรรมนี้แบ่งความรับผิดชอบของแต่ละส่วนออกจากกันอย่างชัดเจน ตั้งแต่การรับ Request การตรวจสอบสิทธิ์ การประมวลผล Business Logic การเข้าถึงข้อมูล และการจัดเก็บข้อมูล

การออกแบบในลักษณะนี้ช่วยลดการพึ่งพาระหว่าง Module ทำให้สามารถเพิ่มบริการใหม่หรือปรับปรุงระบบได้โดยไม่กระทบต่อส่วนอื่น


Business Value ​

Layered Architecture ช่วยให้องค์กรได้รับประโยชน์ดังนี้

  • พัฒนาระบบได้อย่างเป็นระบบ
  • ลดผลกระทบเมื่อมีการปรับปรุงระบบ
  • รองรับการเพิ่ม API ใหม่ในอนาคต
  • เพิ่มความปลอดภัยของข้อมูล
  • รองรับการขยายระบบเมื่อจำนวนผู้ใช้งานเพิ่มขึ้น

Figure 2-3 System Architecture ​

(แทรกรูป Figure 2-3 : System Architecture Diagram)

Figure 2-3

Figure 2-3 แสดงสถาปัตยกรรมของ SISAHYGO Integration Platform ซึ่งแบ่งออกเป็น 6 ชั้นหลัก ได้แก่ Presentation Layer, Integration Layer, Application Layer, Data Access Layer, Data Layer และ Infrastructure Layer

Client System ส่งคำขอผ่าน HTTPS ไปยัง Integration Layer เพื่อทำ Authentication และ Validation ก่อนเข้าสู่ Business Services จากนั้นระบบจะติดต่อ Repository เพื่ออ่านหรือบันทึกข้อมูลในฐานข้อมูล และส่งผลลัพธ์กลับไปยัง Client System ในรูปแบบ JSON


Architecture Layers ​

LayerResponsibilityTechnology
Presentation LayerClient System, Web Application, Mobile ApplicationHTTPS
Integration LayerAuthentication, Validation, REST APILaravel, Nginx
Application LayerBusiness ServicesLaravel Service Classes
Data Access LayerRepository PatternEloquent ORM
Data LayerDatabaseMySQL
Infrastructure LayerWeb Server, Cache, Storage, MonitoringLinux, Docker, Forge

Request Flow ​

ทุก API ของ SISAHYGO จะทำงานตามลำดับดังนี้

  1. Client System ส่ง HTTP Request
  2. API Gateway รับ Request
  3. Authentication ตรวจสอบ API Key
  4. Validation ตรวจสอบข้อมูล
  5. Business Service ประมวลผลข้อมูล
  6. Repository ติดต่อฐานข้อมูล
  7. ส่ง JSON Response กลับไปยัง Client

Business Scenario ​

บริษัท ABC เรียก

POST /order-checkings

ลำดับการทำงาน

Client System

↓

HTTPS

↓

Authentication

↓

Validation

↓

Order Checking Service

↓

Repository

↓

Database

↓

JSON Response

Client System ไม่จำเป็นต้องทราบรายละเอียดการทำงานภายในของแต่ละ Layer เพียงเรียก API ตามมาตรฐานที่กำหนด


Security Architecture ​

ระบบใช้แนวทาง Security by Design

  • HTTPS ทุก Endpoint
  • API Key Authentication
  • Request Validation
  • Authorization
  • Audit Log
  • Rate Limiting (รองรับในอนาคต)

Technology Stack ​

ComponentTechnology
BackendLaravel
LanguagePHP
DatabaseMySQL
APIREST API
FormatJSON
AuthenticationAPI Key
ServerNginx
DeploymentDocker / Forge

Key Concepts ​

คำศัพท์ความหมาย
Layered Architectureการแบ่งระบบออกเป็นหลายชั้น
Business Serviceส่วนประมวลผลกฎทางธุรกิจ
Repositoryชั้นสำหรับเข้าถึงข้อมูล
API Gatewayจุดรับ Request ของระบบ
JSON Responseรูปแบบข้อมูลที่ส่งกลับ

Best Practices ​

RecommendationReason
อย่าเรียก Database โดยตรงจาก Controllerแยก Business Logic ออกจาก Presentation
ใช้ Service Class สำหรับ Business Logicลดความซ้ำซ้อนของโค้ด
ใช้ Repository สำหรับ Data Accessเปลี่ยนฐานข้อมูลได้ง่ายในอนาคต
Validate ทุก Requestลดข้อมูลผิดพลาดเข้าสู่ระบบ
ใช้ HTTPS ทุกครั้งเพิ่มความปลอดภัย

Summary ​

สถาปัตยกรรมของ SISAHYGO ถูกออกแบบให้รองรับการขยายระบบในระยะยาว โดยแบ่งหน้าที่ของแต่ละ Layer อย่างชัดเจน ทำให้ระบบมีความยืดหยุ่น ปลอดภัย และดูแลรักษาได้ง่าย


Ready for Next Chapter ​

ก่อนศึกษาหัวข้อถัดไป โปรดตรวจสอบว่า

  • [ ] เข้าใจ Layered Architecture
  • [ ] เข้าใจ Request Flow
  • [ ] เข้าใจ Technology Stack
  • [ ] เข้าใจหน้าที่ของแต่ละ Layer

References ​

  • REST API Design Best Practices
  • JSON RFC 8259
  • HTTP RFC 9110

  • 02.02 Business Process Overview
  • 02.04 Order Lifecycle
  • Chapter 4 Authentication

Next Step ​

➡️ 02.04 Order Lifecycle

SISAHYGO API Integration Guide