webiny-api-architect

Guides backend API architecture in Webiny using features, use cases, services, and dependency injection.

8.0k|673|Updated Jan 9, 2018
One-click install
npx skills add https://github.com/webiny/webiny-js --skill webiny-api-architect
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: webiny-api-architect
Source: https://github.com/webiny/webiny-js/tree/main/skills/user-skills/api/api-architect
Command: npx skills add https://github.com/webiny/webiny-js --skill webiny-api-architect

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Building backend extensions in Webiny requires consistent architectural decisions across features, use cases, services, repositories, and DI registration. This Skill provides the central reference for structuring Webiny API code so features are discoverable, correctly scoped, and free of common anti-patterns.

Core Features & Use Cases

  • Architecture Patterns: Defines the Extension → Feature → UseCase/Service/Repository hierarchy with clear scoping rules (transient vs singleton) and DI decision trees.
  • Feature Templates: Provides naming conventions and directory structure templates for event handler features, service features, and complex multi-use-case features.
  • Anti-Pattern Detection: Lists concrete mistakes to avoid, such as technical feature naming, generic errors, unfiltered event handlers, and process.env usage at runtime.
  • Use Case: When adding a new backend capability like syncing CMS entries to an external translation service, use this Skill to decide whether to build a Service or UseCase, how to name the feature directory, and how to register everything in the DI container.

Quick Start

Use the webiny-api-architect skill to design a new API feature that creates and stores a custom entity with a GraphQL mutation.

Frequently Asked Questions about webiny-api-architect

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a backend API feature in Webiny?

Create a feature directory named by business capability containing abstractions.ts, implementation files, and a feature.ts registration file. Register it via createFeature, with use cases in transient scope and services or repositories in singleton scope.

When should I use a Service versus a UseCase in Webiny?

Use a Service for multi-method abstractions wrapping external APIs or cohesive domain logic, registered as singletons. Use a UseCase for single-method orchestration coordinating services, repositories, and events, registered as transient.

How does dependency injection work in Webiny API extensions?

Webiny uses createAbstraction to define typed DI tokens and createImplementation with a dependencies array matching constructor parameter order. Features register implementations through container.register inside their register method.

Can I use process.env in a deployed Webiny API?

No, deployed API services must never read process.env at runtime. All configuration flows through BuildParams injected via DI, using buildParams.get() with null handling.

What are common Webiny API architecture anti-patterns?

Common mistakes include naming features by technical implementation, creating one abstraction per operation instead of multi-method services, using generic Error instead of domain errors, and not filtering event handlers by model ID.