# config.py
import json

def load_config(config_path=None):
    """Loads configuration from a JSON file.  If no path is provided, uses a default."""
    if config_path is None:
        config_path = 'config.json'  # Default config file name

    try:
        with open(config_path, 'r') as f:
            config = json.load(f)
            return config
    except FileNotFoundError:
        print(f"Configuration file not found: {config_path}. Using default configuration.")
        return {
            "genesis_core": {
                "host": "localhost",
                "port": 8080,
                "api_key": "YOUR_API_KEY"  # Replace with a real API key in production
            }
        }
    except json.JSONDecodeError:
        print(f"Error decoding JSON from {config_path}. Using default configuration.")
        return {
            "genesis_core": {
                "host": "localhost",
                "port": 8080,
                "api_key": "YOUR_API_KEY"  # Replace with a real API key in production
            }
        }


if __name__ == '__main__':
    # Example Usage (for testing)
    config = load_config()
    print(config)
