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]
## Status
Accepted
## 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
- Understand RAG components
- Document Store: เก็บเอกสาร
- Embedding Service: แปลงข้อความเป็น vector
- Vector Store: เก็บ embeddings
- LLM: สร้างคำตอบ
- Design the system
class RAGPipeline { constructor(documentStore, embeddingService) {} async retrieve(query) {} async generate(query, context) {} async query(question) {} } - Implement core components
- Test with sample documents
Deliverable: Working RAG pipeline
🔴 Quest 5.2: Full System Design
Goal: Design a complete AI-powered system
- Choose a system: Chatbot, Code Reviewer, or Content Generator
- Define components
Component Purpose Input Handler Process user input AI Engine Generate responses Data Store Persist data Output Formatter Format responses - Design interfaces
class AISystem { addComponent(name, component) {} async process(input) {} getStatus() {} toDocumentation() {} } - Document architecture
- Overview
- Components
- Data Flow
- Security
Deliverable: Complete system design with documentation
✅ 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