import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AuthModule } from './modules/auth/auth.module';
import { UsersModule } from './modules/users/users.module';
import { LocaisModule } from './modules/locais/locais.module';
import { CentrosCustoModule } from './modules/centros-custo/centros-custo.module';
import { CategoriasModule } from './modules/categorias/categorias.module';
import { FornecedoresModule } from './modules/fornecedores/fornecedores.module';
import { DemandasModule } from './modules/demandas/demandas.module';
import { SubcategoriasModule } from './modules/subcategorias/subcategorias.module';
import { DocumentosModule } from './modules/documentos/documentos.module';
import { PropostasModule } from './modules/propostas/propostas.module';
import { OrcamentoModule } from './modules/orcamento/orcamento.module';
import { WorkflowModule } from './modules/workflow/workflow.module';
import { DashboardModule } from './modules/dashboard/dashboard.module';
import { OrdensServicoModule } from './modules/ordens-servico/ordens-servico.module';
import { EsgModule } from './modules/esg/esg.module';
import { KpisModule } from './modules/kpis/kpis.module';
import { AuditModule } from './modules/audit/audit.module';
import { ImportModule } from './modules/import/import.module';
import { RelatoriosModule } from './modules/relatorios/relatorios.module';
import { MetasModule } from './modules/metas/metas.module';
import { AlertasModule } from './modules/alertas/alertas.module';
import { SeedService } from './database/seeds/seed.service';
import { Perfil } from './modules/users/entities/perfil.entity';
import { Usuario } from './modules/users/entities/usuario.entity';
import { Local } from './modules/locais/entities/local.entity';
import { CentroCusto } from './modules/centros-custo/entities/centro-custo.entity';
import { Categoria } from './modules/categorias/entities/categoria.entity';
import { Fornecedor } from './modules/fornecedores/entities/fornecedor.entity';
import { Certidao } from './modules/fornecedores/entities/certidao.entity';
import { Demanda } from './modules/demandas/entities/demanda.entity';
import { ItemLinha } from './modules/demandas/entities/item-linha.entity';
import { Subcategoria } from './modules/subcategorias/entities/subcategoria.entity';
import { Documento } from './modules/documentos/entities/documento.entity';
import { Proposta } from './modules/propostas/entities/proposta.entity';
import { OrcamentoPlanejado } from './modules/orcamento/entities/orcamento-planejado.entity';
import { WorkflowAprovacao } from './modules/workflow/entities/workflow-aprovacao.entity';
import { OrdemServico } from './modules/ordens-servico/entities/ordem-servico.entity';
import { Avaliacao } from './modules/ordens-servico/entities/avaliacao.entity';
import { DocumentoVersao } from './modules/ordens-servico/entities/documento-versao.entity';
import { Alerta } from './modules/dashboard/entities/alerta.entity';
import { AuditLog } from './modules/dashboard/entities/audit-log.entity';
import { EsgMetrica } from './modules/esg/entities/esg-metrica.entity';
import { EsgMeta } from './modules/esg/entities/esg-meta.entity';
import { Kpi } from './modules/kpis/entities/kpi.entity';
import { Meta } from './modules/metas/entities/meta.entity';
import { AlertaConfig } from './modules/alertas/entities/alerta-config.entity';

@Module({
  imports: [
    TypeOrmModule.forRoot({
      type: 'postgres',
      host: process.env.DB_HOST || 'localhost',
      port: parseInt(process.env.DB_PORT || '5432'),
      username: process.env.DB_USERNAME || 'hefesto',
      password: process.env.DB_PASSWORD || 'Hefesto2026!',
      database: process.env.DB_DATABASE || 'hefesto',
      autoLoadEntities: true,
      synchronize: true,
    }),
    TypeOrmModule.forFeature([
      Perfil, Usuario, Local, CentroCusto, Categoria, Fornecedor, Certidao,
      Demanda, ItemLinha, Subcategoria, Documento, Proposta, OrcamentoPlanejado, WorkflowAprovacao,
      OrdemServico, Avaliacao, DocumentoVersao, Alerta, AuditLog,
      EsgMetrica, EsgMeta, Kpi, Meta, AlertaConfig,
    ]),
    AuthModule,
    UsersModule,
    LocaisModule,
    CentrosCustoModule,
    CategoriasModule,
    FornecedoresModule,
    DemandasModule,
    SubcategoriasModule,
    DocumentosModule,
    PropostasModule,
    OrcamentoModule,
    WorkflowModule,
    DashboardModule,
    OrdensServicoModule,
    EsgModule,
    KpisModule,
    AuditModule,
    ImportModule,
    RelatoriosModule,
    MetasModule,
    AlertasModule,
  ],
  providers: [SeedService],
})
export class AppModule {}
