import { Module } from '@nestjs/common';
import { APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core';
import { ConfigModule } from '@nestjs/config';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import configuration from './config/configuration';
import { validationSchema } from './config/validation.schema';
import { DatabaseModule } from './database/database.module';
import { CacheModule } from './infrastructure/cache/cache.module';
import { LoggingModule } from './infrastructure/logging/logging.module';
import { MetricsModule } from './infrastructure/metrics/metrics.module';
import { MaintenanceModule } from './infrastructure/maintenance/maintenance.module';
import { ReliabilityModule } from './infrastructure/reliability/reliability.module';
import { QueueModule } from './infrastructure/queue/queue.module';
import { RedisModule } from './infrastructure/redis/redis.module';
import { StorageModule } from './infrastructure/storage/storage.module';
import { AuthModule } from './modules/auth/auth.module';
import { AuditModule } from './modules/audit/audit.module';
import { BlocksModule } from './modules/blocks/blocks.module';
import { ChatModule } from './modules/chat/chat.module';
import { CommentsModule } from './modules/comments/comments.module';
import { CollaborationRequestsModule } from './modules/collaboration-requests/collaboration-requests.module';
import { DevicesModule } from './modules/devices/devices.module';
import { FeedModule } from './modules/feed/feed.module';
import { EngagementModule } from './modules/engagement/engagement.module';
import { FollowsModule } from './modules/follows/follows.module';
import { LikesModule } from './modules/likes/likes.module';
import { MediaModule } from './modules/media/media.module';
import { MetadataModule } from './modules/metadata/metadata.module';
import { MarketplaceModule } from './modules/marketplace/marketplace.module';
import { MusicWorldModule } from './modules/music-world/music-world.module';
import { NotificationsModule } from './modules/notifications/notifications.module';
import { OutboxModule } from './modules/outbox/outbox.module';
import { PostsModule } from './modules/posts/posts.module';
import { ReportsModule } from './modules/reports/reports.module';
import { SavesModule } from './modules/saves/saves.module';
import { SearchModule } from './modules/search/search.module';
import { SuperAdminModule } from './modules/superadmin/superadmin.module';
import { SupportModule } from './modules/support/support.module';
import { UsersModule } from './modules/users/users.module';
import { ThrottleGuard } from './common/guards/throttle.guard';
import { MediaUrlInterceptor } from './common/interceptors/media-url.interceptor';

@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
      cache: true,
      load: [configuration],
      validationSchema,
    }),
    LoggingModule,
    MetricsModule,
    ReliabilityModule,
    MaintenanceModule,
    RedisModule,
    CacheModule,
    StorageModule,
    QueueModule,
    DatabaseModule,
    AuditModule,
    BlocksModule,
    UsersModule,
    AuthModule,
    PostsModule,
    CommentsModule,
    CollaborationRequestsModule,
    DevicesModule,
    LikesModule,
    FollowsModule,
    FeedModule,
    EngagementModule,
    NotificationsModule,
    OutboxModule,
    ChatModule,
    MediaModule,
    MetadataModule,
    MarketplaceModule,
    MusicWorldModule,
    ReportsModule,
    SavesModule,
    SearchModule,
    SupportModule,
    SuperAdminModule,
  ],
  controllers: [AppController],
  providers: [
    AppService,
    {
      provide: APP_GUARD,
      useClass: ThrottleGuard,
    },
    {
      provide: APP_INTERCEPTOR,
      useClass: MediaUrlInterceptor,
    },
  ],
})
export class AppModule {}
