
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from '@/App';
import '@/index.css';
import { initializeDatabase } from '@/config/database';
import { initializeSchema } from '@/config/schema';
import { initializeBalanceSchema } from '@/config/balanceSchema';
import { initializeEarningsSchema } from '@/config/earningsSchema';
import { initializeOrdersDatabase } from '@/config/orderSchema';

// Initialize Simulated Backend
const initBackend = async () => {
  try {
    console.log('[App] Starting application backend services...');
    await initializeDatabase();
    await initializeSchema();
    await initializeBalanceSchema(); 
    await initializeEarningsSchema();
    initializeOrdersDatabase(); // Initialize Orders Database (Real)
    console.log('[App] Backend services ready.');
  } catch (error) {
    console.error('[App] Failed to initialize backend services:', error);
  }
};

initBackend();

ReactDOM.createRoot(document.getElementById('root')).render(
    <App />
);
