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

// Import controller
import { QuoteMasterController } from './quote-master.controller';

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

// Import JWT service for token handling
import { JwtService } from '@nestjs/jwt';

// Import service containing business logic
import { QuoteMasterService } from './quote-master.service';

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

// Import entity representing the database table
import { QuoteMasterEntity } from 'src/entities/QuoteMaster.entity';

/**
 * QuoteMasterModule - Feature module for quote management functionality
 *
 * This module encapsulates all components related to quote master operations.
 * It follows NestJS modular architecture with a focused scope on quote dashboard data.
 *
 * Module Characteristics:
 * - Lightweight module with single controller endpoint
 * - Focused on dashboard data rather than full CRUD operations
 * - Includes caching for performance optimization
 * - Integrates with JWT authentication system
 *
 * Business Context:
 * - Likely part of a sales, CRM, or quoting system
 * - Provides dashboard overview of quotes (summary, metrics, statistics)
 * - May integrate with larger sales pipeline or order management
 */
@Module({
  /**
   * controllers - Array of controllers that handle HTTP requests
   *
   * QuoteMasterController: Contains single endpoint for dashboard data
   * - GET /dashboard-quote: Returns aggregated quote statistics
   * - Simple controller focused on dashboard view
   */
  controllers: [QuoteMasterController],

  /**
   * providers - Injectable services and classes available within this module
   *
   * 1. QuoteMasterService: Core business logic for quote dashboard
   *    - Contains aggregation logic for quote statistics
   *    - May perform complex queries for dashboard metrics
   *    - Could calculate totals, averages, trends, etc.
   *
   * 2. JwtService: Utility for JWT token operations
   *    - Likely used by guards/strategies not shown in this module
   *    - May be required by CacheModule or RedisService in parent modules
   *    - Provides token validation capabilities
   */
  providers: [QuoteMasterService, JwtService],

  /**
   * imports - External modules and dependencies required by this module
   *
   * 1. CacheModule.register(): Configures the caching system
   *    - Provides in-memory caching by default
   *    - Important for dashboard data which may be expensive to compute
   *    - Dashboard metrics often benefit from caching (e.g., 5-minute cache)
   *
   * 2. TypeOrmModule.forFeature([QuoteMasterEntity]):
   *    - Registers the QuoteMasterEntity with TypeORM
   *    - Makes QuoteMasterRepository available for injection
   *    - Enables database operations for quote data
   *    - Repository used by QuoteMasterService for data aggregation
   */
  imports: [
    CacheModule.register(), // Default cache configuration
    TypeOrmModule.forFeature([QuoteMasterEntity]), // Database entity registration
  ],
})
export class QuoteMasterModule {}
