MV

MVC

Used in 205 typescript projects (avg ★151)

Details

Language / Topic
typescriptTypeScript
Category
Architecture

Rules

balanced
- Separate concerns: Models hold data and business logic, Views render UI, Controllers handle user input and orchestration.
- Keep controllers thin — delegate business logic to models or services.
- Use TypeScript interfaces for model shapes and DTOs — controllers validate with Zod schemas and return typed response objects.
- In backend (Express, NestJS): controllers parse requests, call services, return responses. Services contain logic. Models represent data.
- In frontend (React, Vue): components are the View, hooks/stores are the Controller, types/services are the Model.
- Don't put database queries in controllers. Don't put HTTP handling in models.
- Use validation middleware between the controller and service layer.