MV

MVC

Used in 205 javascript projects (avg ★151)

Details

Language / Topic
javascriptJavaScript
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.
- Controllers parse requests and return responses — business logic lives in services/models, not in route handlers.
- 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.