/* Copyright (C) 2023-2026 QuantumNous This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ import { Database, HardDrive, Server } from 'lucide-react' import { useTranslation } from 'react-i18next' import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert' import { StatusBadge } from '@/components/status-badge' import type { SetupStatus } from '../types' interface DatabaseStepProps { status?: SetupStatus } const DATABASE_META: Record< string, { label: string descriptionKey: string variant: 'info' | 'success' | 'warning' } > = { sqlite: { label: 'SQLite', descriptionKey: 'SQLite stores all data in a single file. Make sure that file is persisted when running in containers.', variant: 'warning', }, mysql: { label: 'MySQL', descriptionKey: 'MySQL is a production-ready relational database. Keep your credentials secure.', variant: 'success', }, postgres: { label: 'PostgreSQL', descriptionKey: 'PostgreSQL offers advanced reliability and data integrity for production workloads.', variant: 'success', }, } function resolveDatabaseMeta(type?: string) { if (!type) return null const normalized = type.toLowerCase() return ( DATABASE_META[normalized] ?? { label: type, descriptionKey: 'Custom database driver detected.', variant: 'info' as const, } ) } export function DatabaseStep({ status }: DatabaseStepProps) { const { t } = useTranslation() const meta = resolveDatabaseMeta(status?.database_type) const electronApi = typeof window !== 'undefined' ? ((window as unknown as Record)?.electron as | Record | undefined) : undefined const isElectron = Boolean(electronApi?.isElectron) const electronDataDir = electronApi?.dataDir as string | undefined return (

{t('Detected database')}

{meta?.label ?? t('Unknown')}

{t( meta?.descriptionKey ?? 'The setup wizard will use this database during initialization.' )}

{status?.database_type === 'sqlite' && ( {t('Persist your data file')}

{t( 'When running in containers or ephemeral environments, ensure the SQLite file is mapped to persistent storage to avoid data loss on restart.' )}

{isElectron && electronDataDir && (

{t('Data directory:')} {electronDataDir}

)} {isElectron && !electronDataDir && (

{t( 'Data is stored locally on this device. Use system backups to keep a safe copy.' )}

)}
)} {status?.database_type === 'mysql' && ( {t('MySQL detected')} {t( 'MySQL is production ready. Ensure automated backups and a dedicated user with the minimal required privileges are configured.' )} )} {status?.database_type === 'postgres' && ( {t('PostgreSQL detected')} {t( 'PostgreSQL offers strong reliability guarantees. Double check your maintenance window and retention policies before going live.' )} )}
) }