LESSON 01 / 18·2 min readFoundation

What are modules, controllers and services?

Try code in the playground
01 Understand02 Recall03 Prepare

Understand the concept

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.

Important ideas

  • 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.

PAUSE & RECALL

Can you explain it without the notes?

What are modules, controllers and services?

Use your own words. Explain an example and one limitation before checking the explanation.

Check your explanation

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.

CONNECT IT TO YOUR INTERVIEW

Turn this concept into a clear answer.

  • A module describes dependency visibility; it is more than a folder that holds related files.
Practice this concept
YOUR NEXT STEP

Keep connecting the ideas.

Next lesson: Dependency injection

Adapted from 03_NESTJS.md · “What are modules, controllers and services?”. Examples are study fragments; framework behavior can depend on your version.