Skip to main content

Module Structure & Implementation Plan

New Module: platform-integration​

Package Layout​

platform-integration/
└── src/main/kotlin/com/transformplatform/integration/
β”‚
β”œβ”€β”€ domain/ # JPA entities
β”‚ β”œβ”€β”€ Client.kt # Tenant entity
β”‚ β”œβ”€β”€ ClientIntegration.kt # Integration config entity
β”‚ β”œβ”€β”€ IntegrationCredential.kt # Encrypted credential entity
β”‚ β”œβ”€β”€ IntegrationEventLog.kt # Audit log entity
β”‚ β”œβ”€β”€ IntegrationType.kt # enum: SFTP, KAFKA, REST, S3, FTP, AS2
β”‚ β”œβ”€β”€ IntegrationDirection.kt # enum: INBOUND, OUTBOUND, BIDIRECTIONAL
β”‚ └── IntegrationStatus.kt # enum: ACTIVE, INACTIVE, ERROR, TESTING
β”‚
β”œβ”€β”€ config/ # Type-specific config data classes
β”‚ β”œβ”€β”€ IntegrationConfig.kt # sealed class β€” base
β”‚ β”œβ”€β”€ SftpIntegrationConfig.kt
β”‚ β”œβ”€β”€ KafkaIntegrationConfig.kt
β”‚ β”œβ”€β”€ RestIntegrationConfig.kt
β”‚ └── S3IntegrationConfig.kt
β”‚
β”œβ”€β”€ connector/ # Live connection objects
β”‚ β”œβ”€β”€ IntegrationConnector.kt # interface
β”‚ β”œβ”€β”€ InboundConnector.kt # interface
β”‚ β”œβ”€β”€ OutboundConnector.kt # interface
β”‚ β”œβ”€β”€ sftp/
β”‚ β”‚ β”œβ”€β”€ SftpConnector.kt # implements both In + Out
β”‚ β”‚ β”œβ”€β”€ SftpConnectionPool.kt # Apache MINA SSHD pool
β”‚ β”‚ └── SftpInboundPoller.kt # @Scheduled polling task
β”‚ β”œβ”€β”€ kafka/
β”‚ β”‚ └── KafkaConnector.kt
β”‚ β”œβ”€β”€ rest/
β”‚ β”‚ β”œβ”€β”€ RestConnector.kt
β”‚ β”‚ └── auth/
β”‚ β”‚ β”œβ”€β”€ BasicAuthHandler.kt
β”‚ β”‚ β”œβ”€β”€ BearerAuthHandler.kt
β”‚ β”‚ └── OAuth2AuthHandler.kt
β”‚ └── s3/
β”‚ └── S3Connector.kt
β”‚
β”œβ”€β”€ registry/
β”‚ β”œβ”€β”€ IntegrationRegistry.kt # manages live connectors, handles events
β”‚ └── IntegrationFactory.kt # creates connectors from config + credentials
β”‚
β”œβ”€β”€ credential/
β”‚ β”œβ”€β”€ CredentialService.kt # encrypt / decrypt
β”‚ └── AesGcmEncryption.kt # AES-256-GCM implementation
β”‚
β”œβ”€β”€ writers/ # RecordWriter implementations for pipeline
β”‚ β”œβ”€β”€ SftpRecordWriter.kt # implements RecordWriter, looks up registry
β”‚ β”œβ”€β”€ S3RecordWriter.kt
β”‚ └── RestRecordWriter.kt
β”‚
β”œβ”€β”€ inbound/
β”‚ └── FileIngestionService.kt # orchestrates inbound polling β†’ pipeline
β”‚
β”œβ”€β”€ repository/
β”‚ β”œβ”€β”€ ClientRepository.kt
β”‚ β”œβ”€β”€ ClientIntegrationRepository.kt
β”‚ └── IntegrationCredentialRepository.kt
β”‚
β”œβ”€β”€ service/
β”‚ └── IntegrationService.kt # CRUD + lifecycle management
β”‚
└── events/
β”œβ”€β”€ IntegrationCreatedEvent.kt
β”œβ”€β”€ IntegrationUpdatedEvent.kt
└── IntegrationDeletedEvent.kt

Database Migrations (Flyway)​

Implementation Phases​

Key Dependencies to Add​

// platform-integration/build.gradle.kts

dependencies {
implementation(project(":platform-core"))
implementation(project(":platform-common"))

// SFTP β€” Apache MINA SSHD
implementation("org.apache.sshd:sshd-sftp:2.12.1")
implementation("org.apache.sshd:sshd-common:2.12.1")

// S3 β€” AWS SDK v2
implementation("software.amazon.awssdk:s3:2.25.0")

// Encryption
implementation("org.bouncycastle:bcprov-jdk18on:1.77")

// Spring Data JPA (already in Boot BOM)
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
}

Design Decisions​

DecisionChoiceReason
SFTP libraryApache MINA SSHDActively maintained, connection pooling, modern key exchange
Credential encryptionAES-256-GCMAuthenticated encryption, random IV per value
Registry eventsSpring ApplicationEventPublisherNo new infra needed, stays in-process
Config storageJSONB columnFlexible, queryable, avoids one-table-per-type sprawl
Circuit breakerResilience4jAlready standard in Spring Boot ecosystem
Credential rotationZero-downtime swapDrain old connector, activate new before closing