// Import core NestJS module decorator
import { Module } from '@nestjs/common';

// Import controller
import { MenuGroupsController } from './menu-groups.controller';

// Import TypeORM integration for database operations
import { TypeOrmModule } from '@nestjs/typeorm';

// Import JWT service for token handling (likely used by RedisService or guards)
import { JwtService } from '@nestjs/jwt';

// Import service containing business logic
import { MenuGroupsService } from './menu-groups.service';

// Import entity representing the database table/collection
import { MenuGroupsEntity } from 'src/entities/MenuGroups.entity';

// Import cache module for caching capabilities
import { CacheModule } from '@nestjs/cache-manager';

// Import custom Redis service for cache management
import { RedisService } from '../redis/redis.service';

/**
 * MenuGroupsModule - Feature module for menu groups functionality
 *
 * This module encapsulates all components related to menu groups:
 * - Controllers: Handle HTTP requests
 * - Services: Contain business logic
 * - Entities: Define data models
 * - Dependencies: External services and modules
 *
 * The module follows the modular architecture pattern where related
 * functionality is grouped together for better organization and
 * dependency management.
 */
@Module({
  /**
   * controllers - Array of controllers that handle incoming HTTP requests
   *
   * MenuGroupsController: Defines all REST endpoints for menu groups operations
   * such as CRUD, searching, status updates, etc.
   */
  controllers: [MenuGroupsController],

  /**
   * providers - Services and other injectable classes available in this module
   *
   * 1. MenuGroupsService: Core business logic service for menu groups operations
   * 2. JwtService: Utility for JWT token operations (encoding/decoding/verification)
   *    - Likely used by RedisService for token validation in cache operations
   *    - Could also be used by SessionGuard (not shown in this file)
   * 3. RedisService: Custom service for Redis cache operations
   *    - Manages caching layer for performance optimization
   *    - Might cache frequently accessed menu groups data
   */
  providers: [MenuGroupsService, JwtService, RedisService],

  /**
   * imports - External modules and dependencies required by this module
   *
   * 1. CacheModule.register(): Configures the caching system
   *    - Provides in-memory caching by default (can be configured for Redis)
   *    - Enables @CacheKey() and @CacheTTL() decorators in services
   *    - Note: RedisService might override or extend this with Redis-specific logic
   *
   * 2. TypeOrmModule.forFeature([MenuGroupsEntity]):
   *    - Registers the MenuGroupsEntity with TypeORM
   *    - Makes MenuGroupsRepository available for injection
   *    - Enables database operations for menu groups table
   *    - The repository can be injected into MenuGroupsService using @InjectRepository
   */
  imports: [
    CacheModule.register(), // Configures default cache manager (in-memory)
    TypeOrmModule.forFeature([MenuGroupsEntity]), // Database entity registration
  ],
})
export class MenuGroupsModule {}
