import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { MemoryController } from '../adapters/inbound/memory.controller';
import { InternalMemoryController } from '../adapters/inbound/internal-memory.controller';
import { MemoryService } from '../application/services/memory.service';
import { EmbeddingService } from '../infrastructure/embedding/embedding.service';
import { Neo4jService } from '../infrastructure/database/neo4j/neo4j.service';
import {
  UserMemoryPostgresRepository,
  SystemExperiencePostgresRepository,
} from '../adapters/outbound/persistence/memory-postgres.repository';
import { UserMemoryORM } from '../infrastructure/database/postgres/entities/user-memory.orm';
import { SystemExperienceORM } from '../infrastructure/database/postgres/entities/system-experience.orm';
import {
  USER_MEMORY_REPOSITORY,
  SYSTEM_EXPERIENCE_REPOSITORY,
} from '../domain/repositories/memory.repository.interface';

@Module({
  imports: [
    TypeOrmModule.forFeature([
      UserMemoryORM,
      SystemExperienceORM,
    ]),
  ],
  controllers: [MemoryController, InternalMemoryController],
  providers: [
    MemoryService,
    EmbeddingService,
    Neo4jService,
    {
      provide: USER_MEMORY_REPOSITORY,
      useClass: UserMemoryPostgresRepository,
    },
    {
      provide: SYSTEM_EXPERIENCE_REPOSITORY,
      useClass: SystemExperiencePostgresRepository,
    },
  ],
  exports: [MemoryService, Neo4jService],
})
export class MemoryModule {}
