# Routers

**Overview**

In this NestJS project, the routing is organized in a modular fashion. The main responsibility of the routers is to handle incoming HTTP requests and direct them to the appropriate controllers within the modules. The routers are also responsible for applying any necessary guards, interceptors, or middleware for request validation, authorization, and security.

The routing is divided into two primary groups:

1. **Client Router** - Handles routes related to client-side functionalities, such as authentication, user preferences, and traffic channels.
2. **Admin Router** - Handles routes related to administrative tasks, such as user management, access control, and system configuration.

All routes are unified under a main **router.module.ts** to provide easy integration with the main application.<br>

<pre class="language-typescript"><code class="lang-typescript"><strong>router.module.ts
</strong>// Core
import { Module } from "@nestjs/common";
import { RouterModule } from "@nestjs/core";

// Modules
import { AdminRouter } from "@app/modules/admin/admin.router";
import { ClientRouter } from "@app/modules/client/client.router";

@Module({
  imports: [
    RouterModule.register([
      {
        path: "",
        module: AdminRouter,
      },
      {
        path: "",
        module: ClientRouter,
      },
    ]),
    AdminRouter,
    ClientRouter,
  ],
})
export class AppRouter {}
</code></pre>

```typescript
client.router.ts

// Core
import { Module } from "@nestjs/common";
import { RouterModule } from "@nestjs/core";

// Modules
import { HealthModule } from "@app/modules/client/health/health.module";
import { ClientModule } from "@app/modules/client/client.module";
import { AuthModule } from "@app/modules/client/auth/auth.module";
import { UserLoginModule } from "@app/modules/client/user-login/user-login.module";
import { UserModule } from "@app/modules/client/user/user.module";
import { SignUpModule } from "@app/modules/client/auth/sign-up/sign-up.module";
import { SignInModule } from "@app/modules/client/auth/sign-in/sign-in.module";
import { SignOutModule } from "@app/modules/client/auth/sign-out/sign-out.module";
import { PasswordRecoveryModule } from "@app/modules/client/auth/recovery/password-recovery.module";

@Module({
  imports: [
    RouterModule.register([
      {
        path: "client",
        module: ClientModule,
        children: [
          {
            path: "health",
            module: HealthModule,
          },
          {
            path: "auth",
            module: AuthModule,
            children: [
              {
                path: "sign-up",
                module: SignUpModule,
              },
              {
                path: "sign-in",
                module: SignInModule,
              },
              {
                path: "sign-out",
                module: SignOutModule,
              },
              {
                path: "password-recovery",
                module: PasswordRecoveryModule,
              },
            ],
          },
        ],
      },
    ]),
    ClientModule,
    AuthModule,
    SignUpModule,
    SignInModule,
    SignOutModule,
    PasswordRecoveryModule,
    UserLoginModule,
    UserModule.register({ isGlobal: true }),
  ],
})
export class ClientRouter {}
```

```typescript
admin.router.ts

// Core
import { Module } from "@nestjs/common";
import { RouterModule } from "@nestjs/core";

// Modules
import { AdminModule } from "@app/modules/admin/admin.module";
import { HealthModule } from "@app/modules/admin/health/health.module";

@Module({
  imports: [
    RouterModule.register([
      {
        path: "admin",
        module: AdminModule,
        children: [
          {
            path: "health",
            module: HealthModule,
          },
        ],
      },
    ]),
    AdminModule,
  ],
})
export class AdminRouter {}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-affiliates.inlaze.com/architecture/initial-folders-estructure/main-files-and-folders/routers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
