import asyncio
from typing import List, Dict
from .cve_data_fetcher import CVEDataFetcher
from .vulnerability_checker import VulnerabilityChecker
from .dependency_scanner import DependencyScanner
from .risk_scorer import RiskScorer
from .report_generator import ReportGenerator

class CVEChecker:
    def __init__(self):
        self.cve_data_fetcher = CVEDataFetcher()
        self.vulnerability_checker = VulnerabilityChecker(self.cve_data_fetcher)
        self.dependency_scanner = DependencyScanner(self.cve_data_fetcher)
        self.risk_scorer = RiskScorer()
        self.report_generator = ReportGenerator()

    async def check_dependencies(self, dependency_file: str) -> str:
        vulnerabilities = await self.dependency_scanner.scan_dependencies(dependency_file)
        scored_vulnerabilities = self.risk_scorer.prioritize_vulnerabilities(vulnerabilities)
        report = self.report_generator.generate_report(scored_vulnerabilities, 'json')
        return report

    async def check_package(self, package_name: str, version: str) -> str:
        vulnerabilities = await self.vulnerability_checker.check_vulnerabilities(package_name, version)
        scored_vulnerabilities = self.risk_scorer.prioritize_vulnerabilities(vulnerabilities)
        report = self.report_generator.generate_report(scored_vulnerabilities, 'json')
        return report

def main():
    cve_checker = CVEChecker()
    
    # Example usage
    dependency_file = 'requirements.txt'
    report = asyncio.run(cve_checker.check_dependencies(dependency_file))
    print(f"Vulnerability report for {dependency_file}:")
    print(report)

    package_name = 'example_package'
    version = '1.0.0'
    report = asyncio.run(cve_checker.check_package(package_name, version))
    print(f"Vulnerability report for {package_name} version {version}:")
    print(report)

if __name__ == "__main__":
    main()
