Block 5 - Architecture
Block 5: Architecture
16:45 - 18:00 75 minutes 2 Quests🎯 Learning Goals
เมื่อจบบล็อกนี้ คุณจะ:
- ออกแบบ AI-powered system architecture
- สร้าง RAG (Retrieval-Augmented Generation) system
- บันทึก architectural decisions
📖 Concept: System Architecture (30 min)
What is System Architecture?
System Architecture คือการออกแบบโครงสร้างของระบบ รวมถึง:
- Components: ส่วนประกอบของระบบ
- Interfaces: การเชื่อมต่อระหว่างส่วนประกอบ
- Data Flow: การไหลของข้อมูล
- Security: การป้องกันระบบ
AI-Powered System Patterns
Pattern 1: RAG (Retrieval-Augmented Generation)
┌─────────────┐ ┌─────────────┐ ┌─────────────┐│ Documents │────▶│ Embeddings │────▶│ Vector Store│└─────────────┘ └─────────────┘ └──────┬──────┘ │┌─────────────┐ ┌─────────────┐ ││ Query │────▶│ Embeddings │───────────┘└─────────────┘ └──────┬──────┘ │ ▼ ┌─────────────┐ │ LLM │ └──────┬──────┘ │ ▼ ┌─────────────┐ │ Answer │ └─────────────┘Use Cases:
- Chat with your documents
- Knowledge base Q&A
- Document search
Pattern 2: Multi-Agent System
┌──────────┐ ┌──────────┐ ┌──────────┐│ Planner │───▶│ Coder │───▶│ Reviewer │└──────────┘ └──────────┘ └────┬─────┘ │ ┌────────────────┘ ▼ ┌──────────┐ │ Tester │ └──────────┘Use Cases:
- Complex code generation
- Automated workflows
- Quality assurance
Pattern 3: Event-Driven Architecture
┌─────────┐ ┌─────────┐ ┌─────────┐│ Event │────▶│ Handler │────▶│ Side ││ Source │ │ │ │ Effects │└─────────┘ └─────────┘ └─────────┘Use Cases:
- Microservices
- Real-time systems
- Scalable applications
🛠️ Architecture Documentation
Architecture Decision Records (ADR)
บันทึกการตัดสินใจทางสถาปัตยกรรม:
# ADR-001: [Decision Title]
## StatusAccepted
## Context[สถานการณ์ที่ต้องตัดสินใจ]
## Decision[สิ่งที่ตัดสินใจ]
## Consequences- [ผลบวก]- [ผลลบ]System Design Document
# System Design: [System Name]
## Overview- Purpose- Users- Key Features
## Architecture- Components- Interfaces- Data Flow
## Security- Authentication- Authorization- Encryption
## Deployment- Infrastructure- CI/CD- Monitoring🎮 Code Quests
🟡 Quest 5.1: RAG Design
Goal: Design a Retrieval-Augmented Generation system โดยออกแบบให้รองรับ failure mode
ดึง quest ลงเครื่องแล้วทำตามในเครื่องของคุณ:
npx degit Poom5741/ai-sdlc-course/quests/block-5-architecture/quest-13-rag-design my-questcd my-questnode test.jsสิ่งที่ต้องมีใน rag-design.md (อยู่ในโฟลเดอร์ quest):
- Chunking strategy — แบ่ง documents ยังไง (ตาม heading + ขนาด window)
- Embedding strategy — ใช้ model อะไร ฝัง chunk/query ยังไง
- Retrieval quality metric — recall@5 / precision / NDCG เพื่อวัดคุณภาพการ retrieve
- Failure handling — ทำอะไรเมื่อ retrieve ว่าง / confidence ต่ำ / query นอก corpus (fallback, graceful degradation)
- Corpus — ระบุว่าจะ index ส่วนไหนของ workshop docs
วัฒนธรรมที่จะได้เรียนรู้: Design for the failure mode — อย่าปล่อยให้ระบบ hallucinate เมื่อข้อมูลไม่พอ
Deliverable: rag-design.md ที่ผ่าน node test.js
🔴 Quest 5.2: Full System Design
Goal: ออกแบบระบบ AI ที่สมบูรณ์ — ระบุ interface ก่อน implementation
ดึง quest ลงเครื่องแล้วทำตามในเครื่องของคุณ:
npx degit Poom5741/ai-sdlc-course/quests/block-5-architecture/quest-14-full-system my-questcd my-questnode test.jsตัวอย่างระบบใน reference คือ automated PR reviewer (PR webhook → fetch diff → analyze → LLM review → post comment) คุณเลือกระบบตัวเองหรือใช้ตัวอย่างนี้ก็ได้
สิ่งที่ต้องมีใน system-design.md (อยู่ในโฟลเดอร์ quest):
- Component diagram — กล่อง ``` ใน markdown ที่มีลูกศร (
→หรือ-->หรือ Mermaidgraph) - Interface contracts —
interface/contract/APIพร้อม function signature + I/O types ของทุก component - Data flow — data flow / flow: จาก input สู่ output
- Named components — ชื่อ component ที่แตกต่างกันอย่างน้อย 3 ตัว
วัฒนธรรมที่จะได้เรียนรู้: Specify interfaces before implementing — ล็อค contract ก่อนแล้วแต่ละ component ถึงทำและ test แยกกันได้
Deliverable: system-design.md ที่ผ่าน node test.js
✅ Block 5 Checklist
- Understand AI architecture patterns
- Quest 5.1 completed
- Quest 5.2 completed
🎉 Workshop Complete!
Congratulations! You’ve completed all 5 blocks:
- ✅ Block 1: AI Tools Setup
- ✅ Block 2: Prompt Engineering
- ✅ Block 3: Security
- ✅ Block 4: Agentic Workflows
- ✅ Block 5: Architecture
What You’ve Learned
- Setting up and using AI coding tools
- Writing effective prompts
- Identifying and fixing security vulnerabilities
- Creating automated development loops
- Designing AI-powered systems
Next Steps
- Apply: Use these skills in your real projects
- Share: Teach others what you’ve learned
- Iterate: Continuously improve your workflow