<?php

use App\Services\KnowledgeGraphService;
use Illuminate\Support\Facades\File;

require __DIR__ . '/vendor/autoload.php';

$app = require_once __DIR__ . '/bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap();

$service = app(KnowledgeGraphService::class);

$treePath = public_path('data/tree.json');
$edgesPath = public_path('data/edges.json');

if (!File::exists($treePath) || !File::exists($edgesPath)) {
    echo "❌ Data files not found in public/data/\n";
    exit(1);
}

$treeData = json_decode(File::get($treePath), true);
$edgesData = json_decode(File::get($edgesPath), true);

echo "Importing real data...\n";
if ($service->importGraph($treeData, $edgesData)) {
    echo "✅ Import successful!\n";
} else {
    echo "❌ Import failed.\n";
}
