packages/wizard/BUSINESS_LOGIC.md
The wizard frontend is a React application that helps users create mirrord.json configuration files through a guided wizard interface. It connects to a backend API to fetch Kubernetes cluster information.
/api/v1/is-returningHomepageNewUser - Welcome message + two panels (Learn First / Skip to Config)HomepageReturning - Welcome back + two panels (Create Config / Learn)Each homepage has two clickable panels that open different wizard flows:
New User:
Returning User:
User selects one of three modes:
Three tabs:
const ALL_API_ROUTES = {
isReturning: "/api/v1/is-returning",
clusterDetails: "/api/v1/cluster-details", // Returns { namespaces: string[], target_types: string[] }
targets: (namespace: string, targetType?: string) =>
"/api/v1/namespace/{namespace}/targets?target_type={targetType}",
// Returns Target[] where Target = { target_path, target_namespace, detected_ports }
};
const DefaultConfig: LayerFileConfig = {
feature: {
network: {
incoming: { mode: "mirror" },
outgoing: true,
},
fs: "read",
env: true,
},
};
{ path: "deployment/name", namespace: "default" }"mirror" | "steal"number[] - ports to intercept[localPort, remotePort][]{ enabled: boolean, scale_down: boolean } - for Replace modereadBoilerplateType(config) → "steal" | "mirror" | "replace" | "custom"updateConfigMode(mode, config) → Sets incoming.modeupdateConfigCopyTarget(enabled, scaleDown, config) → Sets copy_targetreadCurrentTargetDetails(config) → { type: string, name?: string }updateConfigTarget(config, targetPath, namespace) → Sets targetreadIncoming(config) → Returns entire network.incoming sectionupdateIncoming(config, newIncoming) → Replaces network.incomingreadCurrentFilters(config) → { filters: UiHttpFilter[], operator: "any"|"all"|null }updateConfigFilter(filters, operator, config) → Sets http_filterremoveSingleFilter(filter, config) → Removes one filterdisableConfigFilter(config) → Clears all filtersregexificationRay(value) → Converts exact match to regex: "foo" → "^foo$"Filter types:
interface UiHttpFilter {
value: string; // The filter pattern (regex)
type: "header" | "path";
}
readCurrentPorts(config) → number[] - ports from incoming.portsupdateConfigPorts(ports, config) → Sets incoming.ports (and http_filter.ports if filters exist)readCurrentPortMapping(config) → [localPort, remotePort][]updateConfigPortMapping(mappings, config) → Sets incoming.port_mappingaddRemoveOrUpdateMapping(remote, local, config) → Smart mapping updategetLocalPort(remotePort, config) → Returns mapped local port or remote if no mappingremovePortandMapping(remotePort, config) → Removes port and its mappingdisablePortsAndMapping(config) → Clears both ports and mappingsgetConfigString(config) → Pretty-printed JSON (removes incoming.ports in replace mode)UserDataContext: Stores boolean for isReturning statusConfigDataContext: Stores current LayerFileConfig and setterConfigDataContextProvider: Wraps app with config state (initialized to DefaultConfig)mirrord-logo.svg - Logo for homepagemirrord-architecture.svg - Architecture diagram for learning stepsflow-diagram.png - Feedback loop diagram for learning stepscopy_target.enabled=true, copy_target.scale_down=true, mode="steal"copy_target.enabled=false, mode="mirror"copy_target.enabled=false, mode="steal" (allows filters)http_filter.portsincoming.ports in export