defmodule MatchmakingEx.Application do
  @moduledoc """
  The main application module for MatchmakingEx.

  It starts the top-level supervisor, which in turn starts all the necessary
  processes for the matchmaking system to function, including the `Registry`,
  the `DynamicSupervisor` for pending matches, the `CooldownManager`, and the main `Server`.
  """
  use Application

  @impl true
  def start(_type, _args) do
    children = [
      # The Registry is used for naming and finding processes dynamically.
      {Registry, keys: :unique, name: MatchmakingEx.Registry},
      # The DynamicSupervisor manages the temporary match confirmation processes.
      {DynamicSupervisor, strategy: :one_for_one, name: MatchmakingEx.PendingMatchSupervisor},
      # The dedicated GenServer for managing player cooldowns.
      MatchmakingEx.CooldownManager,
      # The main server that manages the matchmaking queue.
      MatchmakingEx.Server
    ]

    opts = [strategy: :one_for_one, name: MatchmakingEx.Supervisor]
    Supervisor.start_link(children, opts)
  end
end
