graph TD
    %% Unified Diagnostic Flowchart
    Start([Observe System Symptoms]) --> HighLat[High Latency / Slow P99]
    Start --> HighErr[High Error Rate / Crashes]

    %% Step 2: System Resource Metrics Branch (High Latency Path)
    HighLat --> CheckMetrics{Check System Resource Metrics<br/>CPU, RAM, Disk, Network}
    
    CheckMetrics --> CPUCheck{CPU > 85% consistently?}
    CPUCheck -->|Yes| CPUBound[CPU-bound<br/>Scale out / Optimize algorithms]

    CheckMetrics --> MemCheck{Memory limits / Swap active?}
    MemCheck -->|Yes| MemBound[Memory-bound<br/>Fix leaks / Add RAM]

    CheckMetrics --> DiskCheck{High iowait / Latency?}
    DiskCheck -->|Yes| DiskBound[Disk I/O-bound<br/>Add indexes / Caching / SSDs]

    CheckMetrics --> NetCheck{Bandwidth saturated / Packet drop?}
    NetCheck -->|Yes| NetBound[Network-bound<br/>Optimize payloads / CDN]

    %% Step 3: Application Internals / APMs Branch (High Errors Path)
    HighErr --> CheckInternals{Inspect Application Internals<br/>Profilers / APMs}

    CheckInternals --> DBCheck{DB connection pool exhausted?}
    DBCheck -->|Yes| DBBottleneck[DB Bottleneck<br/>Connection pooling / Query optimization]

    CheckInternals --> APICheck{External API calls hanging?}
    APICheck -->|Yes| DepBottleneck[Dependency Bottleneck<br/>Circuit breakers / Async execution]