# Template Development Handoff

> **Usage:** Template for /business-analyse-handoff
> **Data source:** index.json (sections: metadata, analysis, specification, handoff)

---

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

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

## DEVELOPER INSTRUCTIONS

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

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

---

## 1. QUICK CONTEXT

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

> **Source:** Read from index.json

## 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/ -> Existing pages
- web/src/components/ -> Reusable components
- web/src/services/api/ -> API calls
```

## 3. FILES TO CREATE

> **Source:** `index.json.handoff.filesToCreate[]`

### 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/{Application}/{Module}/{Entity}Configuration.cs` | Table + indexes + HasData |
| Service Implementation | `Infrastructure/Services/{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:** `index.json.specification.seedDataCore` (generated in step-03)
> **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 | Source |
|---|------|-------|---------|--------|
| 1 | `NavigationModuleConfiguration.cs` | Infrastructure (HasData) | Module entry in `nav_Modules` | index.json.specification.seedDataCore.navigationModules |
| 2 | `NavigationSectionSeedData.cs` | Infrastructure (HasData) | Section entries (list, dashboard, etc.) with full absolute routes. **MANDATORY when sections defined.** | index.json.specification.seedDataCore.navigationSections |
| 3 | `NavigationTranslationConfiguration.cs` | Infrastructure (HasData) | 4 translations (fr, en, it, de) per nav entity | index.json.specification.seedDataCore.navigationTranslations |
| 4 | `PermissionConfiguration.cs` | Infrastructure (HasData) | Wildcard + CRUD permissions in `nav_Permissions` | index.json.specification.seedDataCore.permissions |
| 5 | `Permissions.cs` | Application (code) | Compile-time constants for `[RequirePermission]` | index.json.specification.seedDataCore.permissionConstants |
| 6 | `RolePermissionConfiguration.cs` | Infrastructure (HasData) | Role->Permission for {App} Admin, {App} Manager, {App} Contributor, {App} Viewer | index.json.specification.seedDataCore.rolePermissions |

### 3.3 Frontend

| File | Path Pattern | Description |
|------|-------------|-------------|
| Main Page | `pages/{app}/{module}/page.tsx` | List + actions |
| Components | `components/{app}/{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 index.json sections: `analysis.entities[]`, `specification.apiEndpoints[]`, `analysis.businessRules[]`, `specification.sections[]`, `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: `index.json.specification.seedDataCore` and `index.json.specification.permissionMatrix`

> **IMPORTANT :** Les données des 6 fichiers SeedData Core doivent être dérivées de `index.json.specification.seedDataCore` :
> - `navigationModules` → NavigationModuleConfiguration.cs
> - `navigationSections` → NavigationSectionSeedData.cs
> - `navigationTranslations` → NavigationTranslationConfiguration.cs
> - `permissions` → PermissionConfiguration.cs (module-level: `{app}.{module}.{action}`, section-level: `{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/{Application}/{Module}/`
- [ ] Infrastructure services in `Services/{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
/business-analyse-develop
```
```
