webiny-api-architect
Skill này làm gì
Skill này cung cấp cho AI của bạn các quy tắc chính để xây dựng mã backend trên Webiny API. Dành cho lập trình viên viết extension thêm logic nghiệp vụ vào dự án Webiny.
Khi nào nên dùng
- ✓Khi bạn xây dựng bất kỳ tính năng hoặc extension backend nào cho Webiny API.
- ✓Khi bạn cần quyết định giữa service và use case cho một phần logic.
- ✓Khi bạn muốn tổ chức một tính năng backend mới vào đúng thư mục và đăng ký.
Liên kết skill
https://github.com/webiny/webiny-js/blob/next/skills/user-skills/api/api-architect/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
“Xây dựng một tính năng backend trong Webiny tính phí vận chuyển, theo quy tắc kiến trúc của dự án.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill giải thích sự khác nhau giữa service và use case, cách đặt tên tính năng theo mục đích nghiệp vụ, và cách đăng ký chúng trong container phụ thuộc. Nó cũng liệt kê các lỗi thường gặp cần tránh.
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.
API Architecture Patterns
TL;DR
API extensions use createFeature to register features into the DI container. Each feature is a vertical slice with abstractions, implementations, and a feature.ts registration file. The key abstractions are Services (multi-method, singleton) and UseCases (single-method orchestrators, transient). Repositories handle persistence via CMS. Features are named by business capability, files inside by technical responsibility.
Working Context
This skill applies to both extension developers (working in extensions/) and core developers (working in packages/). The architecture patterns are identical — only imports and registration differ.
Extensions (extensions/) |
Core (packages/) |
|
|---|---|---|
| Imports | webiny/api, webiny/api/cms/model, etc. |
@webiny/feature/api, @webiny/api-headless-cms/..., etc. |
| Catalog paths | Use the Import: path |
Use the Source: path |
| Entry point | export default createFeature(...) in a file targeted by <Api.Extension src={...}> |
createFeature registered by the package initializer |
| GraphQL schemas | export default GraphQLSchemaFactory.createImplementation(...) — registered via container.register() inside the entry point's createFeature |
Same pattern, but imported from @webiny/handler-graphql |
Detect which context you're in by checking the file path: extensions/ → extension mode, packages/ → core mode.
Architecture Overview
Extension (root) ── registers ──> Features + GraphQL Schemas + Models
Feature ── registers ──> UseCase | Service | EventHandler + Repository
UseCase ── depends on ──> Service | Repository (+ EventPublisher)
Repository ── depends on ──> CMS Use Cases (GetModel, CreateEntry, etc.)
Service ── depends on ──> external APIs, other Services
- Extension: Top-level entry point. Registers all features, GraphQL schemas, and CMS models.
- Feature: A vertical slice. Registers its use cases, services, repositories, and event handlers.
- UseCase: Single-method orchestrator (
execute()). Coordinates services, repositories, and events. Transient scope. - Service: Multi-method abstraction for external API calls or cohesive domain logic. Singleton scope.
- Repository: Persistence layer using CMS as storage. Singleton scope.
- EventHandler: Thin orchestrator reacting to domain events. Delegates to services/use cases.
- GraphQL Schema: Defines types, inputs, queries, and mutations. Resolvers delegate to use cases.
- CMS Model: Defines the data schema stored in headless CMS.
Services vs UseCases
Services
Multi-method abstractions for external API calls or cohesive domain logic. A service groups related operations that belong together.
// abstractions.ts
export interface ILingotekService {
translate(documentId: string, targetLocale: string): Promise<Result<void, Error>>;
getTranslationStatus(documentId: string): Promise<Result<TranslationStatus, Error>>;
deleteProject(projectId: string): Promise<Result<void, Error>>;
}
export const LingotekService = createAbstraction<ILingotekService>("MyExt/LingotekService");
export namespace LingotekService {
export type Interface = ILingotekService;
}
- Registered in singleton scope (
.inSingletonScope()) - Located in:
features/{serviceName}/orfeatures/services/{serviceName}/ - One service per external system or cohesive domain area
- If async bootstrap is needed (loading settings from CMS, fetching remote config): use the ServiceProvider pattern — a provider abstraction with
async getService()that lazily initializes and caches the service. Consumers inje
Câu hỏi thường gặp
Khác biệt giữa service và use case là gì?
Service có nhiều phương thức và được dùng chung, còn use case có một phương thức cho một thao tác đơn.
Tính năng được đặt tên thế nào?
Tính năng được đặt tên theo năng lực nghiệp vụ, còn các file bên trong theo vai trò kỹ thuật.
Nó có bao gồm phía quản trị không?
Không. Mẫu quản trị do các skill quản trị Webiny riêng đảm nhiệm.
Chi tiết
Mô tả gốc của tác giả
The hub skill for all API/backend architecture in Webiny. Covers architecture overview, Services vs UseCases, feature naming and organization, feature structure templates, DI decision tree, anti-patterns, createFeature, createAbstraction, container registration, domain errors, entity patterns, naming conventions, scoping rules, and code conventions. Use this skill for ANY backend API work — it references sub-skills for deep implementation details.
repo: webiny/webiny-js
Độ phổ biến
- Sao GitHub
- 8.1k
- Vị trí xếp hạng
- #12583
- Giấy phép
- —
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
prd-to-plan
8.1kGiúp agent của bạn biến tài liệu yêu cầu sản phẩm thành kế hoạch theo giai đoạn gồm các lát cắt đầu-cuối nhỏ, lưu thành file Markdown.
webiny-admin-architect
8.1kDạy agent của bạn cách xây dựng màn hình quản trị cho nền tảng Webiny, dùng các tầng logic nghiệp vụ và mẫu presenter.
webiny-admin-permissions
8.1kDạy agent của bạn thêm kiểm soát quyền vào màn hình quản trị Webiny, gồm form quyền tự sinh và kiểm tra ẩn hoặc hiện.
webiny-form-model
8.1kDạy agent của bạn xây dựng form trong Webiny bằng trình tạo trường khai báo, bố cục, kiểm tra hợp lệ và quy tắc có điều kiện.
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ủ.