<?php
// Backend Index - API Information
header("Content-Type: application/json; charset=UTF-8");

$apiInfo = [
    "name" => "Noahvelle POS Backend API",
    "version" => "1.0.0",
    "status" => "active",
    "endpoints" => [
        "Authentication" => "/api/auth.php",
        "Products" => "/api/products.php",
        "Customers" => "/api/customers.php",
        "Transactions" => "/api/transactions.php",
        "Suppliers" => "/api/suppliers.php",
        "Expenses" => "/api/expenses.php",
        "Promotions" => "/api/promotions.php"
    ],
    "documentation" => "./README.md",
    "setup_guide" => "./SETUP.md",
    "base_url" => "http://localhost/Noahvelle POS/backend/api/",
    "database_status" => checkDatabaseConnection() ? "Connected" : "Not Connected"
];

echo json_encode($apiInfo, JSON_PRETTY_PRINT);

function checkDatabaseConnection() {
    require_once __DIR__ . '/config/Database.php';
    try {
        $db = new Database();
        $conn = $db->getConnection();
        return $conn !== null;
    } catch (Exception $e) {
        return false;
    }
}
?>
