NestJSInterview preparation
Foundation·Concept·2 min read

What are modules, controllers and services?

Practice this question

Definition:

Nest modules define feature boundaries and register the controllers and providers that belong to a feature. Controllers handle transport concerns, while services usually contain business rules. This separation makes code easier to reuse and test without tying every decision to HTTP.

Key points:

  • A module groups a feature and declares its dependencies.

  • A controller handles HTTP input and responses.

  • A service holds business logic; keep controllers small.

  • Keep database and business operations out of large controllers; a service can also be called by a job or scheduled task.

Interview point:

  • A module describes dependency visibility; it is more than a folder that holds related files.
Adapted from 03_NESTJS.md · “What are modules, controllers and services?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.