Skip to content

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]
## 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 โดยออกแบบให้รองรับ failure mode

ดึง quest ลงเครื่องแล้วทำตามในเครื่องของคุณ:

Terminal window
npx degit Poom5741/ai-sdlc-course/quests/block-5-architecture/quest-13-rag-design my-quest
cd my-quest
node test.js

สิ่งที่ต้องมีใน rag-design.md (อยู่ในโฟลเดอร์ quest):

  1. Chunking strategy — แบ่ง documents ยังไง (ตาม heading + ขนาด window)
  2. Embedding strategy — ใช้ model อะไร ฝัง chunk/query ยังไง
  3. Retrieval quality metric — recall@5 / precision / NDCG เพื่อวัดคุณภาพการ retrieve
  4. Failure handling — ทำอะไรเมื่อ retrieve ว่าง / confidence ต่ำ / query นอก corpus (fallback, graceful degradation)
  5. 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 ลงเครื่องแล้วทำตามในเครื่องของคุณ:

Terminal window
npx degit Poom5741/ai-sdlc-course/quests/block-5-architecture/quest-14-full-system my-quest
cd my-quest
node test.js

ตัวอย่างระบบใน reference คือ automated PR reviewer (PR webhook → fetch diff → analyze → LLM review → post comment) คุณเลือกระบบตัวเองหรือใช้ตัวอย่างนี้ก็ได้

สิ่งที่ต้องมีใน system-design.md (อยู่ในโฟลเดอร์ quest):

  1. Component diagram — กล่อง ``` ใน markdown ที่มีลูกศร (→ หรือ --> หรือ Mermaid graph)
  2. Interface contracts — interface / contract / API พร้อม function signature + I/O types ของทุก component
  3. Data flow — data flow / flow: จาก input สู่ output
  4. 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:

  1. ✅ Block 1: AI Tools Setup
  2. ✅ Block 2: Prompt Engineering
  3. ✅ Block 3: Security
  4. ✅ Block 4: Agentic Workflows
  5. ✅ 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

  1. Apply: Use these skills in your real projects
  2. Share: Teach others what you’ve learned
  3. Iterate: Continuously improve your workflow
View All Code Quests →