# Challenge Questions — APEX

> **Referenced by:** step-00-init.md
> Question templates for context detection, hierarchy validation, and need challenging.
> Previously split across `challenge-questions.md` and `initialization-challenge-flow.md` — now consolidated here.

---

## 4-Level Navigation Hierarchy (BLOCKING RULE)

SmartStack uses a **4-level navigation hierarchy:**
- **Level 1: Application** — e.g., "HumanResources", "ProjectManagement"
- **Level 2: Module** — e.g., "Employees", "Timesheet"
- **Level 3: Section** — e.g., "List", "Dashboard", "Approval"
- **Level 4: Resource** — e.g., "Export", "Settings" (optional)

**BLOCKING RULE:** Every module MUST have at least one section. A module without sections produces an incomplete navigation tree, broken seed data, and missing frontend routes.

---

## 4a. Application Validation

If `{app_name}` was NOT clearly inferred from the task description:

```yaml
questions:
  - header: "Application"
    question: "Which application does this module belong to?"
    options:
      - label: "<best guess from task> (Recommended)"
        description: "Inferred from your task description"
      - label: "New application"
        description: "Create a new application"
      - label: "Existing application"
        description: "Add to an existing application (specify in Other)"
    multiSelect: false
```

If "New application": collect `{app_name}`, `{app_code}`, `{app_icon}`, `{app_labels}` (4 langs).
If "Existing application": scan `**/Seeding/Data/**/NavigationApplicationSeedData.cs` and present discovered apps.

---

## 4b. Module Validation

If `{module_code}` was NOT clearly inferred from the task description:

```yaml
questions:
  - header: "Module"
    question: "What is the module code? (kebab-case, e.g., 'order-management', 'employees')"
    options:
      - label: "<inferred module code> (Recommended)"
        description: "Inferred from your task description"
      - label: "<alternative suggestion>"
        description: "Alternative based on keywords"
    multiSelect: false
```

---

## 4c. Section Selection

> **BLOCKING:** This question MUST be asked. `{sections}` MUST contain at least one entry before proceeding.

Infer section suggestions from:
1. Task description (extract nouns/concepts that suggest functional sub-areas)
2. PRD/feature.json if available (module.sections)
3. Common patterns: "list" (default for simple CRUD), "dashboard", "settings", "reports"

```yaml
questions:
  - header: "Sections"
    question: "What sections should the module '{module_code}' contain? (Select at least one — use 'Other' to add custom sections)"
    options:
      - label: "<inferred section 1>"
        description: "Primary functional area based on module purpose"
      - label: "<inferred section 2>"
        description: "Secondary functional area"
      - label: "<inferred section 3>"
        description: "Additional area inferred from context"
    multiSelect: true
```

**Validation (BLOCKING):**
```
IF {sections}.length == 0:
  DISPLAY: "Every module must have at least one section. Please select or define at least one."
  → Re-ask the sections question
  → DO NOT proceed to next step
```

**Store for each section:**
```yaml
sections:
  - code: "section-kebab"
    labels: { fr: "...", en: "...", it: "...", de: "..." }
    icon: "LucideIconName"
    displayOrder: 10
```

---

## 5a. Entity Scope & Relationships

```yaml
questions:
  - header: "Entities"
    question: "What are the main entities this module manages? (e.g., 'Order, OrderLine, OrderStatus')"
    options:
      - label: "<inferred primary entity>"
        description: "Main entity inferred from module name"
      - label: "<inferred primary + secondary>"
        description: "Primary entity plus related entities from context"
      - label: "Only the primary entity"
        description: "Simple module — single entity '{module_code}' with standard CRUD"
    multiSelect: false
  - header: "Complexity"
    question: "What best describes this module's behavior?"
    options:
      - label: "Simple CRUD (Recommended)"
        description: "Standard list/create/edit/delete — no special business logic"
      - label: "CRUD + Business rules"
        description: "CRUD with validations, computed fields, status transitions, or constraints"
      - label: "CRUD + Workflow/Notifications"
        description: "CRUD with automated actions (emails, approvals, webhooks)"
      - label: "Complex module"
        description: "Multiple interrelated entities with specific business logic"
    multiSelect: false
```

---

## 5b. Dependencies & Key Properties

```yaml
questions:
  - header: "Dependencies"
    question: "Does this module reference entities from other existing modules?"
    options:
      - label: "No dependencies"
        description: "Standalone module — no FK relationships to other modules"
      - label: "Yes, has FK references"
        description: "References entities from other modules (specify in Other)"
      - label: "Not sure yet"
        description: "Will determine during analysis — may require EntityLookup components"
    multiSelect: false
  - header: "Key fields"
    question: "Beyond standard fields (Id, TenantId, Audit), what are the key business properties of the main entity?"
    options:
      - label: "<inferred properties from context>"
        description: "Properties inferred from module purpose"
      - label: "Standard fields only"
        description: "I'll define properties later during implementation"
      - label: "I have specific requirements"
        description: "Describe your fields in 'Other'"
    multiSelect: false

---

## Delegate Mode Skip (if -d flag)

When `/ralph-loop` invokes `/apex -d {prd_path}`, ALL hierarchy is extracted from the PRD file:
- Skip sections 4a-5b (no interactive questions)
- Jump directly to MCP verify section
```
