service-layer-architecture
Controller-service-query layered API architecture with data enrichment and parallel fetching. Use when building REST APIs or GraphQL resolvers with clean separation of concerns. Triggers on API architecture, service layer, controller pattern, data enrichment, REST API.
Why use this skill?
Learn how to build scalable and performant REST APIs and GraphQL resolvers using the service-layer-architecture pattern for clean code, parallel data fetching, and separation of concerns.
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/wpank/service-layer-architectureWhat This Skill Does
The service-layer-architecture skill provides a standardized blueprint for structuring backend applications, specifically REST APIs and GraphQL resolvers. By enforcing a strict separation of concerns, it divides logic into three distinct tiers: Controllers for HTTP orchestration, Services for business logic and data enrichment, and Queries for performant database access. The architecture specifically emphasizes the use of parallel data fetching via Promise.all within the service layer, ensuring that aggregate API responses—which often require multiple database hits—are calculated with minimal latency. This approach significantly improves testability, as developers can isolate business logic from database drivers and HTTP transport layers.
Installation
To install this skill, run the following command in your project terminal: clawhub install openclaw/skills/skills/wpank/service-layer-architecture
Use Cases
This skill is ideal for projects transitioning from monolithic "spaghetti code" to a clean, maintainable architecture. Use it when:
- You are building high-traffic REST APIs where response latency must be minimized through concurrent data fetching.
- You are developing complex GraphQL resolvers that need to gather data from disparate sources (e.g., MongoDB, Redis, and remote microservices) and compose them into a single schema.
- Your team needs a standard contribution pattern that prevents business logic from leaking into your controller files, making codebases easier to maintain and audit.
Example Prompts
- "Help me refactor my current Express controller by moving the data aggregation logic into a service layer using the service-layer-architecture pattern."
- "Can you show me how to implement parallel database fetches for a user profile endpoint using the pattern's service layer structure?"
- "Apply the controller-service-query pattern to this existing API route to ensure I am using lean queries and decoupling my HTTP logic from my database logic."
Tips & Limitations
To maximize the efficacy of this skill, ensure that all database queries consistently use the .lean() method (or equivalent) to minimize object overhead in memory. Always maintain unidirectional dependency flow: Controllers depend on Services, and Services depend on Queries; never allow a Query to import a Service, or a Service to import a Controller. Be aware that while parallel fetching is excellent for performance, it can increase database connection load; monitor your pool limits when scaling. Lastly, this architecture is best suited for Node.js environments and might require adaptation for languages with different concurrency models.
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-wpank-service-layer-architecture": {
"enabled": true,
"auto_update": true
}
}
}Tags(AI)
Flags: code-execution
Related Skills
mermaid-diagrams
Create software diagrams using Mermaid syntax. Use when users need to create, visualize, or document software through diagrams including class diagrams, sequence diagrams, flowcharts, ERDs, C4 architecture diagrams, state diagrams, git graphs, and other diagram types. Triggers include requests to diagram, visualize, model, map out, or show the flow of a system.
api-design-principles
Skill by wpank
auto-context
Automatically read relevant context before major actions. Loads TODO.md, roadmap.md, handoffs, task plans, and other project context files so the AI operates with full situational awareness. Use when starting a task, implementing a feature, refactoring, debugging, planning, or resuming a session.
clear-writing
Write clear, concise prose for humans — documentation, READMEs, API docs, commit messages, error messages, UI text, reports, and explanations. Combines Strunk's rules for clearer prose with technical documentation patterns, structure templates, and review checklists.
track-performance
Track the performance of Uniswap LP positions over time — check which positions need attention, are out of range, or have uncollected fees. Use when the user asks how their positions are doing.