# Template Development Handoff

> **Usage:** Template for step-04-handoff.md
> **Data source:** feature.json (sections: metadata, analysis, specification, handoff)

---

```markdown
# Development Handoff - {FEAT-XXX} {Feature Name}

> **Module:** business/{application}/{module}
> **Version:** {version}
> **Validated Specs:** feature.json (validation.decision = APPROVED)
> **Source:** `docs/business/{app}/{module}/business-analyse/v{version}/feature.json`
> **Implementation:** `/ralph-loop`

## DEVELOPER INSTRUCTIONS

This document is a self-contained prompt for Claude Code.

**Lancement:**
```
/ralph-loop
```
> Ralph-loop auto-detects BA artifacts and derives PRD task breakdowns.
> Use `/ralph-loop -r` only to resume an interrupted loop.

---

## 1. QUICK CONTEXT

| Attribute | Value |
|----------|--------|
| Feature ID | {feature.id} |
| Module | business/{feature.metadata.application}/{feature.metadata.module} |
| Base Permission | `business.{app}.{module}` |
| Project Namespace | {feature.metadata.projectNamespace} |
| DB Schema | `extensions` (client entities) / `core` (navigation, permissions) |
| Table Prefix | `{prefix}_` |
| Complexity | {feature.handoff.complexity} |

## 2. [EXPLORE] EXISTING PATTERNS

BEFORE coding, explore these files to understand the patterns:

```
BACKEND:
- src/{project_namespace}.Domain/Business/ -> Entity structure + folder hierarchy
- src/{project_namespace}.Application/Business/ -> DTOs + service interfaces
- src/{project_namespace}.Application/Common/Interfaces/ -> Service contracts
- src/{project_namespace}.Infrastructure/Persistence/Configurations/ -> EF Core configs (subfolder per context/app/module)
- src/{project_namespace}.Infrastructure/Services/ -> Service implementations (subfolder per context/app/module)
- src/{project_namespace}.Infrastructure/Persistence/Seeding/Data/ -> SeedData patterns

SEED DATA (CRITICAL):
- NavigationModuleConfiguration.cs -> How modules are seeded (HasData)
- NavigationTranslationConfiguration.cs -> How translations are seeded (4 languages)
- PermissionConfiguration.cs -> How permissions are seeded (HasData)
- RolePermissionConfiguration.cs -> How role-permission mappings are seeded

FRONTEND:
- web/src/pages/business/ -> Existing pages
- web/src/components/ -> Reusable components
- web/src/services/api/ -> API calls
```

## 3. FILES TO CREATE

> **Source:** `feature.handoff.filesToCreate[]` in feature.json

### 3.1 Backend

| File | Path Pattern | Description |
|------|-------------|-------------|
| Domain Entity | `Domain/Business/{Application}/{Module}/{Entity}.cs` | BaseEntity + IAuditableEntity |
| Service Interface | `Application/Common/Interfaces/I{Entity}Service.cs` | Service contract |
| DTOs | `Application/Business/{Application}/{Module}/DTOs/{Entity}Dto.cs` | Response, Create, Update records |
| Mapping | `Application/Business/{Application}/{Module}/DTOs/{Entity}MappingExtensions.cs` | Entity <-> DTO mapping |
| Permission Constants | `Application/Business/{Application}/{Module}/Permissions.cs` | Compile-time constants |
| EF Configuration | `Infrastructure/Persistence/Configurations/{Context}/{Application}/{Module}/{Entity}Configuration.cs` | Table + indexes + HasData |
| Service Implementation | `Infrastructure/Services/{Context}/{Application}/{Module}/{Entity}Service.cs` | Business logic |
| Controller | `Api/Controllers/Business/{Application}/{Module}Controller.cs` | NavRoute + RequirePermission |

### 3.2 SeedData Core (CRITICAL -- without these, module is invisible and returns 403)

> **Source:** `feature.json.specification.seedDataCore` (generated in step-02)
> **5 core files + NavigationSectionSeedData when sections are defined** for every new module.
> Derive content EXACTLY from `specification.seedDataCore` sections (navigationModules, navigationSections, navigationTranslations, permissions, rolePermissions, permissionConstants).

| # | File | Layer | Content |
|---|------|-------|---------|
| 1 | `NavigationModuleConfiguration.cs` | Infrastructure (HasData) | Module entry in `nav_Modules` |
| 2 | `NavigationSectionSeedData.cs` | Infrastructure (HasData) | Section entries (list, dashboard, etc.) with full absolute routes. **MANDATORY when sections defined.** |
| 3 | `NavigationTranslationConfiguration.cs` | Infrastructure (HasData) | 4 translations (fr, en, it, de) per nav entity |
| 4 | `PermissionConfiguration.cs` | Infrastructure (HasData) | Wildcard + CRUD permissions in `nav_Permissions` |
| 5 | `Permissions.cs` | Application (code) | Compile-time constants for `[RequirePermission]` |
| 6 | `RolePermissionConfiguration.cs` | Infrastructure (HasData) | Role->Permission for {App} Admin, {App} Manager, {App} Contributor, {App} Viewer |

### 3.3 Frontend

| File | Path Pattern | Description |
|------|-------------|-------------|
| Main Page | `pages/business/{app}/{module}/page.tsx` | List + actions |
| Components | `components/business/{module}/` | Entity-specific components |
| API Service | `services/api/{module}Api.ts` | Typed Axios calls |
| Translations | `i18n/locales/{lang}/{module}.json` | FR, EN, IT, DE |

## 4. DETAILED SPECIFICATIONS

> **Source:** Read from feature.json sections: `analysis.entities[]`, `specification.apiEndpoints[]`, `analysis.businessRules[]`, `specification.navigation`, `specification.permissionMatrix`

### 4.1 Entity

**Base class:** `BaseEntity` + `IAuditableEntity`
**Table name:** `{prefix}_{EntityPlural}` in schema `extensions`
**Schema:** `extensions` for business entities, `core` for system entities (navigation, permissions)
> DO NOT add Id, TenantId, CreatedAt, UpdatedAt, CreatedBy, UpdatedBy -- these are automatic via BaseEntity + IAuditableEntity.

Attributes from: `feature.analysis.entities[].attributes[]`

### 4.2 API Endpoints

From: `feature.specification.apiEndpoints[]`

### 4.3 Business Rules -> Code

From: `feature.handoff.brToCodeMapping[]`

| BR-ID | Rule | Implementation |
|-------|------|----------------|
| {id} | {rule from analysis.businessRules[]} | {implementation from handoff.brToCodeMapping[]} |

### 4.4 SeedData Specifications

From: `feature.specification.seedDataCore` (5 core files), `feature.specification.navigation` and `feature.specification.permissionMatrix`

> **IMPORTANT :** Les données des 5 fichiers SeedData Core doivent être dérivées de `specification.seedDataCore` :
> - `navigationModules` → NavigationModuleConfiguration.cs
> - `navigationTranslations` → NavigationTranslationConfiguration.cs
> - `permissions` → PermissionConfiguration.cs (module-level: `business.{app}.{module}.{action}`, section-level: `business.{app}.{module}.{section}.{action}`)
> - `rolePermissions` → RolePermissionConfiguration.cs
> - `permissionConstants` → Permissions.cs (PascalCase constants)

## 5. REQUIRED TESTS

- [ ] Unit test: Entity validation
- [ ] Integration test: API endpoints
- [ ] Permission test: 403 denial
- [ ] Postman test: Collection generated

## 6. POST-IMPLEMENTATION CHECKLIST

**Build & Tests:**
- [ ] Backend build OK
- [ ] Frontend build OK
- [ ] Tests passing

**Folder Conventions:**
- [ ] Domain entities in `Domain/Business/{Application}/{Module}/`
- [ ] Application DTOs in `Application/Business/{Application}/{Module}/DTOs/`
- [ ] Infrastructure configs in `Configurations/{Context}/{Application}/{Module}/`
- [ ] Infrastructure services in `Services/{Context}/{Application}/{Module}/`
- [ ] Controller in `Controllers/Business/{Application}/`

**SeedData Core (CRITICAL):**
- [ ] Navigation module entry (HasData in NavigationModuleConfiguration.cs)
- [ ] Navigation section entries (NavigationSectionSeedData.cs — MANDATORY when sections defined, with full absolute routes)
- [ ] Navigation translations (4 languages in NavigationTranslationConfiguration.cs)
- [ ] Permissions (HasData in PermissionConfiguration.cs: wildcard + CRUD + section-level)
- [ ] Permission constants (Permissions.cs in Application layer)
- [ ] Role-Permission assignments (HasData in RolePermissionConfiguration.cs: 4 roles)
- [ ] EF Core migration created (includes all HasData seeds)

**Frontend & i18n:**
- [ ] i18n complete (4 languages)
- [ ] Nested routes (NOT flat)

---

## EXECUTION

**Lancement:**
```bash
/ralph-loop
```
```
