{
  config,
  lib,
  pkgs,
  ...
}:
with lib; let
  serviceName = "example";
  cfg = config.homelab.services.${serviceName};
  homelabCfg = config.homelab;
in {
  imports = [
    (import ../lib/features/monitoring.nix serviceName)
    (import ../lib/features/logging.nix serviceName)
    (import ../lib/features/proxy.nix serviceName)
  ];

  # Core service options
  options.homelab.services.${serviceName} = {
    enable = mkEnableOption "Example Homelab Service";

    description = mkOption {
      type = types.str;
      default = "Example Homelab Service";
    };

    port = mkOption {
      type = types.port;
      default = 1234;
    };

    openFirewall = mkOption {
      type = types.bool;
      default = true;
      description = ''
        Whether to open the ports specified in `port` and `webPort` in the firewall.
      '';
    };

    systemdServices = mkOption {
      type = types.listOf types.str;
      default = [
        "example.service"
        "example"
      ];
      description = "Systemd services to monitor";
    };
  };

  # Service configuration with smart defaults
  config = mkIf cfg.enable (mkMerge [
    {
      networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [cfg.port];
    }
    {
      homelab.services.${serviceName}.monitoring = {
        metrics.path = "/metrics";

        healthCheck.path = "/healthz";
        healthCheck.conditions = ["[STATUS] == 200" "[RESPONSE_TIME] < 1000"];

        extraLabels = {
          component = "example";
        };
      };
    }
    {
      homelab.services.${serviceName}.logging = {
        files = ["/var/log/example/log.log"];
        # parsing = {
        #   regex = "^ts=(?P<timestamp>[^ ]+) caller=(?P<caller>[^ ]+) level=(?P<level>\\w+) msg=\"(?P<message>[^\"]*)\"";
        #   extractFields = ["level" "caller"];
        # };
        extraLabels = {
          component = "example";
          application = "example";
        };
      };
    }
    {
      homelab.services.${serviceName}.proxy = {
        enableAuth = true;
      };
    }
  ]);
}
