iii-architecture-patterns
Skill này làm gì
Chỉ cách kết hợp các khối xây dựng iii thành thiết kế backend lớn hơn, như quy trình từng bước, backend phản ứng và hệ thống hướng sự kiện. Dành cho lập trình viên thiết kế các hệ thống lớn hơn một hàm đơn lẻ.
Khi nào nên dùng
- ✓Khi bạn cần một công việc nhiều bước với thử lại và theo dõi từng bước.
- ✓Khi bạn muốn các view và cache luôn đồng bộ với dữ liệu thay đổi.
- ✓Khi nhiều agent AI cần chuyển công việc cho nhau.
Liên kết skill
https://github.com/iii-hq/iii/blob/main/skills/iii-architecture-patterns/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Thiết kế một quy trình bền vững cho việc xử lý đơn hàng của chúng tôi, có thử lại và hàng đợi thư chết cho các lỗi.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill chọn một mẫu phù hợp với yêu cầu, như quy trình bền vững để thử lại hoặc observer để phản ứng với kết quả của một hàm khác. Sau đó nó xây thiết kế từ các hàm, trigger, hàng đợi và trạng thái.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Architecture Patterns
Use this skill when the task is larger than one function or trigger. Pick the pattern from the
requirement, then implement it with Function, Trigger, Worker, observers, state, queues,
streams, and pub/sub.
Pattern Map
| Requirement | Pattern | iii shape |
|---|---|---|
| Sequential work with retries, DLQ, step tracking | Durable workflow | Functions chained through named queues, progress in state |
| Keep views, metrics, cache, or clients in sync | Reactive backend | State triggers plus stream/pubsub side effects |
| React to another function's calls, results, or failures without changing it | Observer side effect | iii.observe({ function_id, on, filters }, target) (iii-observe) |
| Specialized AI agents hand work to each other | Agentic backend | One function per agent, queue handoffs, shared state |
| Commands publish events and projections update independently | Event-driven CQRS | Command functions, event log in state, subscribe triggers |
| Pure, traceable composition | Effect pipeline | Small functions composed synchronously with trigger() |
| Webhook/cron automation chains | Low-code automation | Trigger, transform, action nodes chained by enqueue |
Durable Workflow
Use named queues when steps need different retry, FIFO, or concurrency policy.
TypeScript
import { registerWorker, TriggerAction } from "iii-sdk";
const iii = registerWorker("ws://localhost:49134", { workerName: "order-workflow" });
async function track(orderId: string, step: string, status: string) {
await iii.trigger({
function_id: "state::update",
payload: { scope: "orders", key: orderId, ops: [{ type: "merge", path: ["steps"], value: { [step]: status } }] },
});
}
iii.registerFunction("orders::validate", async (order) => {
await track(order.id, "validate", "done");
return iii.trigger({
function_id: "orders::charge",
payload: order,
action: TriggerAction.Enqueue({ queue: "order-payment" }),
});
});
iii.registerFunction("orders::charge", async (order) => {
await track(order.id, "payment", "done");
return iii.trigger({
function_id: "orders::ship",
payload: order,
action: TriggerAction.Enqueue({ queue: "order-ship" }),
});
});
Python
from iii import register_worker
iii = register_worker("ws://localhost:49134")
def track(order_id, step, status):
iii.trigger({
"function_id": "state::update",
"payload": {
"scope": "orders",
"key": order_id,
"ops": [{"type": "merge", "path": ["steps"], "value": {step: status}}],
},
})
def validate(order):
track(order["id"], "validate", "done")
return iii.trigger({
"function_id": "orders::charge",
"payload": order,
"action": {"type": "enqueue", "queue": "order-payment"},
})
iii.register_function("orders::validate", validate)
Rust
use iii_sdk::TriggerAction;
use iii_sdk::protocol::TriggerRequest;
use serde_json::json;
async fn enqueue_charge(iii: iii_sdk::IIIClient, order: serde_json::Value) -> Result<serde_json::Value, iii_sdk::Error> {
iii.trigger(TriggerRequest {
function_id: "state::update".into(),
payload: json!({
"scope": "orders",
"key": order["id"],
"ops": [{ "type": "merge", "path": ["steps"], "value": { "validate": "done" } }]
}),
action: None,
timeout_ms: None,
}).await?;
iii.trigger(TriggerRequest {
function_id: "orders::charge".into(),
payload: order,
action: Some(TriggerAction::Enqueue { queue: "order-payment".into() }),
timeout_ms: None,
}).await
}
Reactive Backend
Use state triggers when the requirement says "after create/update, do this", "avoid polling", or "push live updates".
iii.registerFunction("todos::on-change", async (event) => {
await iii.trigger({
function_id: "stream::send",
payload: { stream_name: "todos-live", group_id: "default", data: event.new_value },
action: TriggerAction.Void(),
});
});
iii.registerTrigger({
type: "state",
function_id: "todos::on-change",
config: { scope: "todos" },
});
Observer Side Effects
Use an observer when "after X runs (or fails), also do Y" and X should not know about Y: audit logs, alerts, projections, cache invalidation. Every function is observable since 0.25, and an observer failure never affects the observed cal
Câu hỏi thường gặp
Hàng đợi thư chết ở đây là gì?
Đó là hàng đợi giữ các công việc thất bại sau khi đã thử lại, để có thể xem xét sau.
Nó có sửa các hàm hiện có không?
Một số mẫu, như observer, phản ứng với lệnh gọi của hàm khác mà không thay đổi hàm đó.
Những mẫu nào được bao phủ?
Quy trình bền vững, backend phản ứng, observer, pipeline agent, thiết kế hướng sự kiện, pipeline hiệu ứng và chuỗi tự động hóa.
Chi tiết
Mô tả gốc của tác giả
Use when composing iii primitives into backend architectures: durable workflows, reactive backends, observer side effects, agentic pipelines, event-driven CQRS, effect pipelines, and trigger-transform-action automation.
repo: iii-hq/iii
Độ phổ biến
- Sao GitHub
- 19k
- Vị trí xếp hạng
- #10491
- Giấy phép
- —
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
iii-sandbox
19kGiúp agent của bạn chạy mã không đáng tin hoặc do AI tạo ra một cách an toàn trong một máy ảo cô lập tạm thời, rồi hủy khi xong việc.
configuration
19kCho phép agent của bạn thiết lập một registry chung gồm các giá trị cấu hình được đặt tên, kiểm tra theo schema, để các worker có thể đọc và phản ứng với thay đổi.
iii
19kDạy agent của bạn cách các worker iii hoạt động, để nó có thể thêm một khả năng bằng cách kiểm tra trước những gì đã có, rồi xây một worker.
iii-observability
19kGiúp agent của bạn thêm tracing, log có cấu trúc, metric và cảnh báo vào engine iii, dùng OpenTelemetry để bạn thấy hệ thống đang làm gì.
Skill tương tự
api-connector-builder
280kGiúp agent của bạn xây dựng kết nối API mới theo đúng mẫu đã có, dùng khi bạn cần thêm một tích hợp mà không tạo cách làm mới.
api-design
280kGiúp agent của bạn thiết kế REST API theo các thực hành tốt nhất, hữu ích để định nghĩa cách API giao tiếp, hiển thị lỗi và tổ chức dữ liệu.
backend-patterns
280kGiúp agent của bạn với các mẫu kiến trúc phía máy chủ và tối ưu cơ sở dữ liệu, hữu ích khi xây dựng hoặc rà soát code chạy trên máy chủ.