import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { ThrottlerModule, ThrottlerGuard } from '@nestjs/throttler';
import { APP_GUARD } from '@nestjs/core';
import { PrismaModule } from './prisma/prisma.module';
import { AuthModule } from './modules/auth/auth.module';
import { UsersModule } from './modules/users/users.module';
import { CoursesModule } from './modules/courses/courses.module';
import { ContentsModule } from './modules/contents/contents.module';
import { PromptsModule } from './modules/prompts/prompts.module';
import { ToolsModule } from './modules/tools/tools.module';
import { SandboxModule } from './modules/sandbox/sandbox.module';
import { OrdersModule } from './modules/orders/orders.module';
import { AdminModule } from './modules/admin/admin.module';
import { PaymentModule } from './modules/payment/payment.module';
import { CategoriesModule } from './modules/categories/categories.module';
import { DashboardModule } from './modules/dashboard/dashboard.module';
import { SearchModule } from './modules/search/search.module';
import { ModelsModule } from './modules/models/models.module';
import { UploadModule } from './modules/upload/upload.module';
import { CommunityModule } from './modules/community/community.module';
import { EnterpriseModule } from './modules/enterprise/enterprise.module';
import { NotificationModule } from './modules/notifications/notification.module';
import { LearningModule } from './modules/learning/learning.module';
import { SkillsModule } from './modules/skills/skills.module';
import { AiAssistantModule } from './modules/ai-assistant/ai-assistant.module';
import { PracticesModule } from './modules/practices/practices.module';
import { DonationsModule } from './modules/donations/donations.module';
import { RedisThrottlerStorage } from './common/redis-throttler-storage';

@Module({
  imports: [
    ConfigModule.forRoot({ isGlobal: true }),
    ThrottlerModule.forRoot({
      throttlers: [
        { name: 'short', ttl: 60000, limit: 60 },
        { name: 'medium', ttl: 300000, limit: 200 },
      ],
      storage: new RedisThrottlerStorage(),
    }),
    PrismaModule,
    AuthModule, UsersModule, CoursesModule, ContentsModule,
    PromptsModule, ToolsModule, SandboxModule, OrdersModule,
    AdminModule, PaymentModule, CategoriesModule, DashboardModule,
    SearchModule, ModelsModule, UploadModule, CommunityModule,
    EnterpriseModule, NotificationModule, LearningModule, SkillsModule,
    AiAssistantModule,
    PracticesModule,
    DonationsModule,
  ],
  providers: [
    { provide: APP_GUARD, useClass: ThrottlerGuard },
  ],
})
export class AppModule {}
