Feature-Based-Layered-Architecture

Organize Next.js applications into Handler, Service, Repository, and Adapter layers.

1|Updated Jan 24, 2026
One-click install
npx skills add https://github.com/sasatech-labs/skills --skill feature-based-layered-architecture
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Feature-Based-Layered-Architecture
Source: https://github.com/sasatech-labs/skills/tree/main/skills/feature-based-layered-architecture
Command: npx skills add https://github.com/sasatech-labs/skills --skill feature-based-layered-architecture

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires server-only, pino, pino-pretty, vitest, @supabase/supabase-js, and includes scripts (resource) components.

What problem does it solve?

Feature-Based Layered Architecture provides a clear pattern for organizing Next.js apps into distinct layers (Handler, Service, Repository, and Adapter) and feature modules, improving maintainability and scalability.

Core Features & Use Cases

  • Feature-based Layer Architecture for Next.js (App Router) with Supabase: a four-layer structure that guides where to place handlers, services, repositories, and adapters.
  • Feature-based module structure under features/ to group functionality by domain, with clear public API exposure via index.server.ts and index.client.ts.
  • Guidelines for guides and rules to enforce architecture, including a default stack and directory layout.

Quick Start

Create a new feature under features/ and implement Handler/Service/Repository/Adapter layers following the prescribed structure.

Frequently Asked Questions about Feature-Based-Layered-Architecture

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

FAQPage Schema
What is feature-based layered architecture in Next.js?

Feature-based layered architecture in Next.js organizes applications into Handler, Service, Repository, and Adapter layers within domain-specific feature modules to enforce separation of concerns and improve scalability.

How do I structure Next.js API routes and domain logic into separate layers?

Structure Next.js API routes and domain logic by grouping functionality under a features/ directory, separating code into Handler, Service, Repository, and Adapter layers, and exposing public APIs via index.server.ts and index.client.ts files.

Does this Next.js architecture pattern work with Supabase and server-only directives?

Yes, this architecture pattern works with Supabase and server-only directives. It integrates the @supabase/supabase-js dependency and enforces server-only directives to clearly separate client and server execution contexts.

What's the best way to organize a scalable Next.js App Router project by domain?

The best way to organize a scalable Next.js App Router project by domain is using a feature-based module structure. This groups functionality by domain under features/ rather than by technical role, ensuring maintainability and clear public API exposure.

When should I use a four-layer separation in my Next.js application?

Use a four-layer separation in your Next.js application when you need strict boundaries between API routing, business logic, data access, and external integrations to prevent code entanglement and ensure long-term maintainability.