feature-architecture
2
总安装量
2
周安装量
#66710
全站排名
安装命令
npx skills add https://github.com/gilbertopsantosjr/fullstacknextjs --skill feature-architecture
Agent 安装分布
cursor
2
claude-code
2
Skill 文档
Feature Architecture
Layer Overview
âââââââââââââââââââââââââââââââââââââââââââ
â Pages (src/app/) â Route handlers, layouts
âââââââââââââââââââââââââââââââââââââââââââ¤
â Components (features/*/components/) â UI elements
âââââââââââââââââââââââââââââââââââââââââââ¤
â Server Actions (features/*/usecases/) â API layer
âââââââââââââââââââââââââââââââââââââââââââ¤
â Services (features/*/<name>-service) â Business logic
âââââââââââââââââââââââââââââââââââââââââââ¤
â DAL (features/*/dal/) â Database access
âââââââââââââââââââââââââââââââââââââââââââ¤
â Model (features/*/model/) â Schemas, types
âââââââââââââââââââââââââââââââââââââââââââ
Implementation Order
Always implement bottom-up:
- Model – Zod schemas, types, constants
- DAL – Database operations
- Service – Business logic
- Actions – Server actions
- Components – UI
- Pages – Routes
Feature Directory Structure
src/features/<feature>/
âââ model/
â âââ <feature>-schemas.ts # Zod schemas + types
â âââ <feature>-constants.ts # Constants
âââ dal/
â âââ create_<entity>.ts # snake_case files
â âââ find_<entity>_by_id.ts
â âââ update_<entity>.ts
â âââ delete_<entity>.ts
âââ <feature>-service.ts # Business logic
âââ usecases/
â âââ create/actions/<action>.ts
â âââ update/actions/<action>.ts
â âââ delete/actions/<action>.ts
âââ components/
â âââ <Component>.tsx
â âââ <Component>-server.tsx
â âââ <Component>-client.tsx
âââ utils/ # Feature utilities
Layer Responsibilities
Model Layer
- Zod schemas for validation
- TypeScript types (inferred from Zod)
- Constants and enums
- No logic, only definitions
DAL Layer
- Direct database operations
- One file per operation
- snake_case naming
- Returns
{ success, data?, error? } - Entity-to-model converters
- No business logic
Service Layer
- Business logic and validation
- Orchestrates DAL calls
- Permission checks
- Called by actions, not directly by UI
Actions Layer
- Server actions for client calls
- Authentication via
authedProcedure - Input validation with Zod
- Calls services, NOT DAL
- Cache revalidation
Components Layer
- Server components (default)
- Client components (interactivity)
- Split pattern for hybrid needs
Pages Layer
- Route definitions
- Layout composition
- Data fetching (server components)
Naming Conventions
| Layer | Case | Example |
|---|---|---|
| Model files | kebab-case | account-schemas.ts |
| DAL files | snake_case | create_account.ts |
| Service files | kebab-case | account-service.ts |
| Action files | kebab-case | create-account-action.ts |
| Components | PascalCase | AccountCard.tsx |
| Directories | kebab-case | user-profile/ |
| Constants | SCREAMING_SNAKE | MAX_NAME_LENGTH |
Data Flow
User Action
â
Component (client)
â
Server Action (validates, authenticates)
â
Service (business logic)
â
DAL (database operation)
â
DynamoDB
Quick Reference
| Need to… | Go to… |
|---|---|
| Add validation | model/<feature>-schemas.ts |
| Add DB operation | dal/ (new snake_case file) |
| Add business rule | <feature>-service.ts |
| Add API endpoint | usecases/*/actions/ |
| Add UI element | components/ |
| Add page route | src/app/ |
Environment Setup
# Install UV for Python tools
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install dependencies
pnpm install
# Development
pnpm dev
# SST dev mode
npx sst dev --stage dev
Related Skills
- zod-validation – Schema patterns
- dynamodb-onetable – Database patterns
- nextjs-server-actions – Action patterns
- nextjs-web-client – Component patterns
- sst-infra – Deployment patterns