ln-722-backend-generator
Type: L3 Worker
Category: 7XX Project Bootstrap
Parent: ln-720-structure-migrator
Generates complete .NET backend structure following Clean Architecture principles.
Purpose & Scope
| Aspect |
Description |
| Input |
Project name, entity list, configuration options |
| Output |
Complete .NET solution with layered architecture |
| Target |
.NET 10+, ASP.NET Core |
Scope boundaries:
- Generates project structure and boilerplate code
- Creates MockData for initial development
- Does not implement business logic or database connections
Workflow
| Phase |
Name |
Actions |
Output |
| 1 |
Receive Context |
Get project name, entities, options from coordinator |
Configuration |
| 2 |
Create Solution |
Create .sln and .csproj files |
Empty solution structure |
| 3 |
Generate Domain |
Create entities, enums, base classes |
Domain project files |
| 4 |
Generate API |
Create controllers, DTOs, middleware |
API project files |
| 5 |
Verify |
Build solution, check references |
Build success |
Phase 1: Receive Context
Accept delegation from ln-720-structure-migrator.
| Input |
Type |
Required |
Description |
projectName |
string |
Yes |
Solution and project name prefix |
targetPath |
string |
Yes |
Directory for generated solution |
targetFramework |
string |
Yes |
.NET version (e.g., net10.0) |
entities |
list |
Yes |
Entity names to generate |
features |
list |
Yes |
Feature groupings for MockData |
Options:
| Option |
Default |
Effect |
useSwagger |
true |
Add Swashbuckle for API docs |
useSerilog |
true |
Add structured logging |
useHealthChecks |
true |
Add health endpoints |
createMockData |
true |
Generate mock data classes |
Phase 2: Create Solution
Generate solution file and project structure.
| Step |
Action |
Reference |
| 2.1 |
Create solution directory |
— |
| 2.2 |
Generate .sln file |
— |
| 2.3 |
Create project directories |
layer_structure.md |
| 2.4 |
Generate .csproj files per layer |
layer_structure.md |
| 2.5 |
Add project references |
layer_structure.md |
Generated projects:
| Project |
Purpose |
{Project}.Api |
HTTP endpoints, middleware |
{Project}.Domain |
Entities, enums |
{Project}.Services |
Business logic interfaces |
{Project}.Repositories |
Data access interfaces |
{Project}.Shared |
Cross-cutting utilities |
Phase 3: Generate Domain
Create domain layer files.
| Step |
Action |
Reference |
| 3.1 |
Create BaseEntity class |
entity_patterns.md |
| 3.2 |
Generate entity classes per input |
entity_patterns.md |
| 3.3 |
Generate status enums |
entity_patterns.md |
| 3.4 |
Create folder structure |
layer_structure.md |
Entity generation rules:
| Entity Property |
Generated As |
| Primary key |
public Guid Id { get; set; } |
| String field |
public string Name { get; set; } = string.Empty; |
| Status field |
public {Entity}Status Status { get; set; } |
| Timestamps |
CreatedAt, UpdatedAt from BaseEntity |
Phase 4: Generate API
Create API layer files.
| Step |
Action |
Reference |
| 4.1 |
Generate Program.cs |
program_sections.md |
| 4.2 |
Generate controllers per entity |
controller_patterns.md |
| 4.3 |
Generate DTOs per entity |
controller_patterns.md |
| 4.4 |
Generate middleware classes |
layer_structure.md |
| 4.5 |
Generate extension methods |
program_sections.md |
| 4.6 |
Generate MockData classes (if enabled) |
layer_structure.md |
| 4.7 |
Add NuGet packages |
nuget_packages.md |
Controller endpoints per entity:
| Endpoint |
Method |
Route |
| GetAll |
GET |
/api/{entities} |
| GetById |
GET |
/api/{entities}/{id} |
| Create |
POST |
/api/{entities} |
| Update |
PUT |
/api/{entities}/{id} |
| Delete |
DELETE |
/api/{entities}/{id} |
Phase 5: Verify
Validate generated solution.
| Check |
Command |
Expected |
| Solution builds |
dotnet build |
Success, no errors |
| Project references |
Check .csproj |
All references valid |
| Files created |
Directory listing |
All expected files present |
Generated Structure Summary
| Layer |
Folders |
Files per Entity |
| Api |
Controllers/, DTOs/, Middleware/, MockData/, Extensions/ |
Controller, DTO |
| Domain |
Entities/, Enums/, Common/ |
Entity, Status enum |
| Services |
Interfaces/ |
Interface (stub) |
| Repositories |
Interfaces/ |
Interface (stub) |
| Shared |
— |
Utility classes |
Critical Rules
- Single Responsibility: Generate only backend structure, no frontend
- Idempotent: Can re-run to regenerate (will overwrite)
- Build Verification: Must verify
dotnet build passes
- Clean Architecture: Respect layer dependencies (inner layers independent)
- No Business Logic: Generate structure only, not implementation
- MockData First: Enable immediate API testing without database
Definition of Done
Risk Mitigation
| Risk |
Detection |
Mitigation |
| Build failure |
dotnet build fails |
Check .csproj references, verify SDK version |
| Missing references |
CS0246 errors |
Add missing project references |
| Invalid entity names |
Build or runtime errors |
Validate entity names before generation |
| Path conflicts |
File exists errors |
Check target path, prompt before overwrite |
| Package restore failure |
NuGet errors |
Verify network, check package names |
Reference Files
| File |
Purpose |
references/layer_structure.md |
Project organization, folder structure, dependencies |
references/entity_patterns.md |
Entity generation rules, property patterns |
references/controller_patterns.md |
Controller and DTO generation rules |
references/program_sections.md |
Program.cs structure and service registration |
references/nuget_packages.md |
Required and optional NuGet packages |
Version: 2.0.0
Last Updated: 2026-01-10
1---2name: ln-722-backend-generator3description: Generates .NET Clean Architecture backend structure from entity definitions4---5
6# ln-722-backend-generator
7
8**Type:** L3 Worker
9**Category:** 7XX Project Bootstrap
10**Parent:** ln-720-structure-migrator
11
12Generates complete .NET backend structure following Clean Architecture principles.
13
14---
15
16## Purpose & Scope
17
18| Aspect | Description |
19|--------|-------------|
20| **Input** | Project name, entity list, configuration options |
21| **Output** | Complete .NET solution with layered architecture |
22| **Target** | .NET 10+, ASP.NET Core |
23
24**Scope boundaries:**
25- Generates project structure and boilerplate code
26- Creates MockData for initial development
27- Does not implement business logic or database connections
28
29---
30
31## Workflow
32
33| Phase | Name | Actions | Output |
34|-------|------|---------|--------|
35| 1 | Receive Context | Get project name, entities, options from coordinator | Configuration |
36| 2 | Create Solution | Create .sln and .csproj files | Empty solution structure |
37| 3 | Generate Domain | Create entities, enums, base classes | Domain project files |
38| 4 | Generate API | Create controllers, DTOs, middleware | API project files |
39| 5 | Verify | Build solution, check references | Build success |
40
41---
42
43## Phase 1: Receive Context
44
45Accept delegation from ln-720-structure-migrator.
46
47| Input | Type | Required | Description |
48|-------|------|----------|-------------|
49| `projectName` | string | Yes | Solution and project name prefix |
50| `targetPath` | string | Yes | Directory for generated solution |
51| `targetFramework` | string | Yes | .NET version (e.g., net10.0) |
52| `entities` | list | Yes | Entity names to generate |
53| `features` | list | Yes | Feature groupings for MockData |
54
55**Options:**
56
57| Option | Default | Effect |
58|--------|---------|--------|
59| `useSwagger` | true | Add Swashbuckle for API docs |
60| `useSerilog` | true | Add structured logging |
61| `useHealthChecks` | true | Add health endpoints |
62| `createMockData` | true | Generate mock data classes |
63
64---
65
66## Phase 2: Create Solution
67
68Generate solution file and project structure.
69
70| Step | Action | Reference |
71|------|--------|-----------|
72| 2.1 | Create solution directory | — |
73| 2.2 | Generate .sln file | — |
74| 2.3 | Create project directories | `layer_structure.md` |
75| 2.4 | Generate .csproj files per layer | `layer_structure.md` |
76| 2.5 | Add project references | `layer_structure.md` |
77
78**Generated projects:**
79
80| Project | Purpose |
81|---------|---------|
82| `{Project}.Api` | HTTP endpoints, middleware |
83| `{Project}.Domain` | Entities, enums |
84| `{Project}.Services` | Business logic interfaces |
85| `{Project}.Repositories` | Data access interfaces |
86| `{Project}.Shared` | Cross-cutting utilities |
87
88---
89
90## Phase 3: Generate Domain
91
92Create domain layer files.
93
94| Step | Action | Reference |
95|------|--------|-----------|
96| 3.1 | Create `BaseEntity` class | `entity_patterns.md` |
97| 3.2 | Generate entity classes per input | `entity_patterns.md` |
98| 3.3 | Generate status enums | `entity_patterns.md` |
99| 3.4 | Create folder structure | `layer_structure.md` |
100
101**Entity generation rules:**
102
103| Entity Property | Generated As |
104|-----------------|--------------|
105| Primary key | `public Guid Id { get; set; }` |
106| String field | `public string Name { get; set; } = string.Empty;` |
107| Status field | `public {Entity}Status Status { get; set; }` |
108| Timestamps | `CreatedAt`, `UpdatedAt` from BaseEntity |
109
110---
111
112## Phase 4: Generate API
113
114Create API layer files.
115
116| Step | Action | Reference |
117|------|--------|-----------|
118| 4.1 | Generate Program.cs | `program_sections.md` |
119| 4.2 | Generate controllers per entity | `controller_patterns.md` |
120| 4.3 | Generate DTOs per entity | `controller_patterns.md` |
121| 4.4 | Generate middleware classes | `layer_structure.md` |
122| 4.5 | Generate extension methods | `program_sections.md` |
123| 4.6 | Generate MockData classes (if enabled) | `layer_structure.md` |
124| 4.7 | Add NuGet packages | `nuget_packages.md` |
125
126**Controller endpoints per entity:**
127
128| Endpoint | Method | Route |
129|----------|--------|-------|
130| GetAll | GET | `/api/{entities}` |
131| GetById | GET | `/api/{entities}/{id}` |
132| Create | POST | `/api/{entities}` |
133| Update | PUT | `/api/{entities}/{id}` |
134| Delete | DELETE | `/api/{entities}/{id}` |
135
136---
137
138## Phase 5: Verify
139
140Validate generated solution.
141
142| Check | Command | Expected |
143|-------|---------|----------|
144| Solution builds | `dotnet build` | Success, no errors |
145| Project references | Check .csproj | All references valid |
146| Files created | Directory listing | All expected files present |
147
148---
149
150## Generated Structure Summary
151
152| Layer | Folders | Files per Entity |
153|-------|---------|------------------|
154| Api | Controllers/, DTOs/, Middleware/, MockData/, Extensions/ | Controller, DTO |
155| Domain | Entities/, Enums/, Common/ | Entity, Status enum |
156| Services | Interfaces/ | Interface (stub) |
157| Repositories | Interfaces/ | Interface (stub) |
158| Shared | — | Utility classes |
159
160---
161
162## Critical Rules
163
164- **Single Responsibility:** Generate only backend structure, no frontend
165- **Idempotent:** Can re-run to regenerate (will overwrite)
166- **Build Verification:** Must verify `dotnet build` passes
167- **Clean Architecture:** Respect layer dependencies (inner layers independent)
168- **No Business Logic:** Generate structure only, not implementation
169- **MockData First:** Enable immediate API testing without database
170
171---
172
173## Definition of Done
174
175- [ ] Solution file created with all projects
176- [ ] All project references configured correctly
177- [ ] Domain entities generated for all input entities
178- [ ] Controllers generated with CRUD endpoints
179- [ ] DTOs generated for request/response
180- [ ] MockData classes generated (if enabled)
181- [ ] Program.cs configured with all services
182- [ ] `dotnet build` passes successfully
183- [ ] Swagger UI accessible (if enabled)
184
185---
186
187## Risk Mitigation
188
189| Risk | Detection | Mitigation |
190|------|-----------|------------|
191| Build failure | `dotnet build` fails | Check .csproj references, verify SDK version |
192| Missing references | CS0246 errors | Add missing project references |
193| Invalid entity names | Build or runtime errors | Validate entity names before generation |
194| Path conflicts | File exists errors | Check target path, prompt before overwrite |
195| Package restore failure | NuGet errors | Verify network, check package names |
196
197---
198
199## Reference Files
200
201| File | Purpose |
202|------|---------|
203| `references/layer_structure.md` | Project organization, folder structure, dependencies |
204| `references/entity_patterns.md` | Entity generation rules, property patterns |
205| `references/controller_patterns.md` | Controller and DTO generation rules |
206| `references/program_sections.md` | Program.cs structure and service registration |
207| `references/nuget_packages.md` | Required and optional NuGet packages |
208
209---
210
211**Version:** 2.0.0
212**Last Updated:** 2026-01-10