Appearance
02.03 สถาปัตยกรรมระบบ (System Architecture)
📌 At a Glance
| รายการ | รายละเอียด |
|---|---|
| Topic | System Architecture |
| Difficulty | ⭐⭐ Intermediate |
| Reading Time | 12 นาที |
| Target | Solution Architect, Developer, System Integrator |
| Related APIs | All 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 แสดงสถาปัตยกรรมของ 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
| Layer | Responsibility | Technology |
|---|---|---|
| Presentation Layer | Client System, Web Application, Mobile Application | HTTPS |
| Integration Layer | Authentication, Validation, REST API | Laravel, Nginx |
| Application Layer | Business Services | Laravel Service Classes |
| Data Access Layer | Repository Pattern | Eloquent ORM |
| Data Layer | Database | MySQL |
| Infrastructure Layer | Web Server, Cache, Storage, Monitoring | Linux, Docker, Forge |
Request Flow
ทุก API ของ SISAHYGO จะทำงานตามลำดับดังนี้
- Client System ส่ง HTTP Request
- API Gateway รับ Request
- Authentication ตรวจสอบ API Key
- Validation ตรวจสอบข้อมูล
- Business Service ประมวลผลข้อมูล
- Repository ติดต่อฐานข้อมูล
- ส่ง 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
| Component | Technology |
|---|---|
| Backend | Laravel |
| Language | PHP |
| Database | MySQL |
| API | REST API |
| Format | JSON |
| Authentication | API Key |
| Server | Nginx |
| Deployment | Docker / Forge |
Key Concepts
| คำศัพท์ | ความหมาย |
|---|---|
| Layered Architecture | การแบ่งระบบออกเป็นหลายชั้น |
| Business Service | ส่วนประมวลผลกฎทางธุรกิจ |
| Repository | ชั้นสำหรับเข้าถึงข้อมูล |
| API Gateway | จุดรับ Request ของระบบ |
| JSON Response | รูปแบบข้อมูลที่ส่งกลับ |
Best Practices
| Recommendation | Reason |
|---|---|
| อย่าเรียก 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
Related Chapters
- 02.02 Business Process Overview
- 02.04 Order Lifecycle
- Chapter 4 Authentication
Next Step
➡️ 02.04 Order Lifecycle
