New skills (14): - nestjs-best-practices: 40 priority-ranked rules (kadajett) - fastapi: Pydantic v2, async SQLAlchemy, JWT auth (jezweb) - architecture-patterns: Clean Architecture, Hexagonal, DDD (wshobson) - python-performance-optimization: Profiling and optimization (wshobson) - ai-sdk: Vercel AI SDK streaming and agent patterns (vercel) - create-agent: Modular agent architecture with OpenRouter (openrouterteam) - proactive-agent: WAL Protocol, compaction recovery, self-improvement (halthelobster) - brand-guidelines: Brand identity enforcement (anthropics) - ui-animation: Motion design with accessibility (mblode) - marketing-ideas: 139 ideas across 14 categories (coreyhaines31) - pricing-strategy: SaaS pricing and tier design (coreyhaines31) - programmatic-seo: SEO at scale with playbooks (coreyhaines31) - competitor-alternatives: Comparison page architecture (coreyhaines31) - referral-program: Referral and affiliate programs (coreyhaines31) README reorganized by domain: Code Quality, Frontend, Backend, Auth, AI/Agent Building, Marketing, Design, Meta. Mosaic Stack is not limited to coding — the Orchestrator serves coding, business, design, marketing, writing, logistics, and analysis. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
83 lines
2.3 KiB
Markdown
83 lines
2.3 KiB
Markdown
---
|
|
title: Organize by Feature Modules
|
|
impact: CRITICAL
|
|
impactDescription: "3-5x faster onboarding and development"
|
|
tags: architecture, modules, organization
|
|
---
|
|
|
|
## Organize by Feature Modules
|
|
|
|
Organize your application into feature modules that encapsulate related functionality. Each feature module should be self-contained with its own controllers, services, entities, and DTOs. Avoid organizing by technical layer (all controllers together, all services together). This enables 3-5x faster onboarding and feature development.
|
|
|
|
**Incorrect (technical layer organization):**
|
|
|
|
```typescript
|
|
// Technical layer organization (anti-pattern)
|
|
src/
|
|
├── controllers/
|
|
│ ├── users.controller.ts
|
|
│ ├── orders.controller.ts
|
|
│ └── products.controller.ts
|
|
├── services/
|
|
│ ├── users.service.ts
|
|
│ ├── orders.service.ts
|
|
│ └── products.service.ts
|
|
├── entities/
|
|
│ ├── user.entity.ts
|
|
│ ├── order.entity.ts
|
|
│ └── product.entity.ts
|
|
└── app.module.ts // Imports everything directly
|
|
```
|
|
|
|
**Correct (feature module organization):**
|
|
|
|
```typescript
|
|
// Feature module organization
|
|
src/
|
|
├── users/
|
|
│ ├── dto/
|
|
│ │ ├── create-user.dto.ts
|
|
│ │ └── update-user.dto.ts
|
|
│ ├── entities/
|
|
│ │ └── user.entity.ts
|
|
│ ├── users.controller.ts
|
|
│ ├── users.service.ts
|
|
│ ├── users.repository.ts
|
|
│ └── users.module.ts
|
|
├── orders/
|
|
│ ├── dto/
|
|
│ ├── entities/
|
|
│ ├── orders.controller.ts
|
|
│ ├── orders.service.ts
|
|
│ └── orders.module.ts
|
|
├── shared/
|
|
│ ├── guards/
|
|
│ ├── interceptors/
|
|
│ ├── filters/
|
|
│ └── shared.module.ts
|
|
└── app.module.ts
|
|
|
|
// users.module.ts
|
|
@Module({
|
|
imports: [TypeOrmModule.forFeature([User])],
|
|
controllers: [UsersController],
|
|
providers: [UsersService, UsersRepository],
|
|
exports: [UsersService], // Only export what others need
|
|
})
|
|
export class UsersModule {}
|
|
|
|
// app.module.ts
|
|
@Module({
|
|
imports: [
|
|
ConfigModule.forRoot(),
|
|
TypeOrmModule.forRoot(),
|
|
UsersModule,
|
|
OrdersModule,
|
|
SharedModule,
|
|
],
|
|
})
|
|
export class AppModule {}
|
|
```
|
|
|
|
Reference: [NestJS Modules](https://docs.nestjs.com/modules)
|