@jeffrey2423/coding-standards 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -174
- package/bin/cli.js +373 -20
- package/package.json +13 -3
- package/standards/backend/architecture/event-driven.md +112 -0
- package/standards/backend/architecture/microservice-anatomy.md +106 -0
- package/standards/backend/architecture/multitenancy.md +112 -0
- package/standards/backend/architecture/public-api-facade.md +112 -0
- package/standards/backend/architecture/shared-vs-owned.md +62 -0
- package/standards/{backend-standards.md → backend/backend-standards.md} +8 -1
- package/standards/{database-conventions.md → backend/database-conventions.md} +7 -0
- package/standards/backend/technology-stack.md +73 -0
- package/standards/core/ai-collaboration.md +64 -0
- package/standards/core/clean-architecture-ddd.md +69 -0
- package/standards/core/coding-conventions.md +66 -0
- package/standards/core/testing-strategy.md +46 -0
- package/standards/{mobile-flutter-standards.md → mobile/flutter/flutter-standards.md} +9 -1
- package/standards/{mobile-react-native-standards.md → mobile/react-native/react-native-standards.md} +9 -1
- package/standards/{technical-preferences-ux.md → web/_base/design-system-ux.md} +8 -1
- package/standards/web/_base/frontend-architecture.md +75 -0
- package/standards/{frontend-standards.md → web/_base/frontend-standards.md} +7 -0
- package/standards/web/_base/technology-stack.md +40 -0
- package/standards/web/microfrontends/module-federation-standard.md +216 -0
- package/standards/web/single-spa/single-spa-standard.md +196 -0
- package/standards/web/spa/spa-standard.md +53 -0
- package/standards/architecture-patterns.md +0 -444
- package/standards/technology-stack.md +0 -294
- package/standards/vite-config-standard.md +0 -531
|
@@ -1,444 +0,0 @@
|
|
|
1
|
-
# Architecture Patterns & Design Decisions
|
|
2
|
-
|
|
3
|
-
## Frontend Architecture
|
|
4
|
-
|
|
5
|
-
### Architecture Style
|
|
6
|
-
- **Clean Architecture** + **Domain-Driven Design (DDD)**
|
|
7
|
-
|
|
8
|
-
### Folder Structure
|
|
9
|
-
|
|
10
|
-
Vite + TanStack Router Structure with Clean Architecture + DDD:
|
|
11
|
-
|
|
12
|
-
```
|
|
13
|
-
├── src/
|
|
14
|
-
│ ├── main.tsx # React entry point
|
|
15
|
-
│ ├── router.tsx # TanStack Router config
|
|
16
|
-
│ ├── routeTree.gen.ts # Auto-generated (DO NOT EDIT)
|
|
17
|
-
│ ├── globals.css # Global styles + Tailwind
|
|
18
|
-
│ │
|
|
19
|
-
│ ├── routes/ # TanStack Router file-based routing
|
|
20
|
-
│ │ ├── __root.tsx # Root layout (providers)
|
|
21
|
-
│ │ ├── index.tsx # Home redirect
|
|
22
|
-
│ │ ├── _auth.tsx # Public layout (pathless)
|
|
23
|
-
│ │ ├── _auth/
|
|
24
|
-
│ │ │ └── login.tsx # /login
|
|
25
|
-
│ │ ├── _app.tsx # Protected layout (pathless)
|
|
26
|
-
│ │ └── _app/
|
|
27
|
-
│ │ ├── dashboard.tsx # /dashboard
|
|
28
|
-
│ │ ├── sales/
|
|
29
|
-
│ │ │ ├── quotes.tsx # /sales/quotes
|
|
30
|
-
│ │ │ └── invoices.tsx # /sales/invoices
|
|
31
|
-
│ │ └── inventory/
|
|
32
|
-
│ │ └── products.tsx # /inventory/products
|
|
33
|
-
│ │
|
|
34
|
-
│ ├── modules/ # Business modules following DDD
|
|
35
|
-
│ │ ├── sales/ # Sales module
|
|
36
|
-
│ │ │ ├── quotes/ # Quote domain
|
|
37
|
-
│ │ │ │ ├── cart/ # Shopping cart feature
|
|
38
|
-
│ │ │ │ │ ├── domain/
|
|
39
|
-
│ │ │ │ │ │ ├── entities/
|
|
40
|
-
│ │ │ │ │ │ ├── repositories/
|
|
41
|
-
│ │ │ │ │ │ ├── services/
|
|
42
|
-
│ │ │ │ │ │ └── types/
|
|
43
|
-
│ │ │ │ │ ├── application/
|
|
44
|
-
│ │ │ │ │ │ ├── use-cases/
|
|
45
|
-
│ │ │ │ │ │ ├── hooks/
|
|
46
|
-
│ │ │ │ │ │ └── store/
|
|
47
|
-
│ │ │ │ │ ├── infrastructure/
|
|
48
|
-
│ │ │ │ │ │ ├── repositories/
|
|
49
|
-
│ │ │ │ │ │ ├── api/
|
|
50
|
-
│ │ │ │ │ │ └── adapters/
|
|
51
|
-
│ │ │ │ │ └── presentation/
|
|
52
|
-
│ │ │ │ │ └── components/
|
|
53
|
-
│ │ │ │ └── products/ # Products feature
|
|
54
|
-
│ │ │ └── billing/ # Billing domain
|
|
55
|
-
│ │ ├── inventory/ # Inventory module
|
|
56
|
-
│ │ └── users/ # User module
|
|
57
|
-
│ │
|
|
58
|
-
│ ├── shared/
|
|
59
|
-
│ │ ├── components/ # Reusable UI components
|
|
60
|
-
│ │ │ └── ui/ # shadcn/ui components
|
|
61
|
-
│ │ ├── hooks/ # Shared hooks
|
|
62
|
-
│ │ ├── lib/ # Utilities (utils.ts, api-client.ts)
|
|
63
|
-
│ │ ├── types/ # Common TypeScript types
|
|
64
|
-
│ │ └── constants/ # App constants
|
|
65
|
-
│ │
|
|
66
|
-
│ ├── app/ # Global configuration
|
|
67
|
-
│ │ ├── providers/ # React context providers
|
|
68
|
-
│ │ └── store/ # Global Zustand stores
|
|
69
|
-
│ │
|
|
70
|
-
│ └── infrastructure/ # Global external services
|
|
71
|
-
│ ├── api/ # API configuration
|
|
72
|
-
│ ├── storage/ # IndexedDB, localStorage
|
|
73
|
-
│ └── pwa/ # PWA configuration
|
|
74
|
-
│
|
|
75
|
-
├── public/ # Static assets and PWA manifest
|
|
76
|
-
├── index.html # Vite entry point
|
|
77
|
-
└── vite.config.ts # Vite + TanStack Router plugin config
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### TanStack Router Conventions
|
|
81
|
-
|
|
82
|
-
| Prefix | Effect | Example |
|
|
83
|
-
|--------|--------|---------|
|
|
84
|
-
| `_` | Pathless layout (no URL segment) | `_app.tsx` → layout only |
|
|
85
|
-
| `.` | Flat routing (nested without folders) | `orders.$id.tsx` → `/orders/:id` |
|
|
86
|
-
| `-` | Ignored by router (colocated files) | `-components/` |
|
|
87
|
-
| `$` | Dynamic parameter | `$orderId.tsx` → `:orderId` |
|
|
88
|
-
|
|
89
|
-
### Core Principles
|
|
90
|
-
|
|
91
|
-
#### Clean Architecture First
|
|
92
|
-
Strict separation of:
|
|
93
|
-
- **Domain layer** - Business entities, repositories interfaces, domain services, and types
|
|
94
|
-
- **Application layer** - Use cases, hooks, and state management (Zustand stores)
|
|
95
|
-
- **Infrastructure layer** - Repository implementations, API clients, and adapters
|
|
96
|
-
- **Presentation layer** - UI components in `presentation/`, routes in `routes/`
|
|
97
|
-
|
|
98
|
-
#### Domain-Driven Design
|
|
99
|
-
Business logic drives architecture decisions. Organize by business modules and domains, not technical layers.
|
|
100
|
-
|
|
101
|
-
#### Component Composition
|
|
102
|
-
Build complex UIs from simple, reusable components.
|
|
103
|
-
|
|
104
|
-
#### Type Safety
|
|
105
|
-
Leverage TypeScript for compile-time safety and developer experience.
|
|
106
|
-
|
|
107
|
-
#### Performance by Design
|
|
108
|
-
- Lazy loading (automatic with TanStack Router)
|
|
109
|
-
- Memoization
|
|
110
|
-
- Bundle optimization
|
|
111
|
-
|
|
112
|
-
#### Accessibility as Standard
|
|
113
|
-
WCAG 2.1 AA compliance in all components.
|
|
114
|
-
|
|
115
|
-
#### Test-Driven Development
|
|
116
|
-
Unit tests for all use cases and components.
|
|
117
|
-
|
|
118
|
-
#### Progressive Web App
|
|
119
|
-
Offline-first approach with service workers.
|
|
120
|
-
|
|
121
|
-
#### Minimal and Functional
|
|
122
|
-
Only build what's explicitly requested, nothing more.
|
|
123
|
-
|
|
124
|
-
#### User-Centered Design
|
|
125
|
-
Start with user needs and work backward to implementation.
|
|
126
|
-
|
|
127
|
-
#### MCP Shadcn Available
|
|
128
|
-
Use MCP to install Shadcn components instead of creating manually.
|
|
129
|
-
|
|
130
|
-
### Framework Selection Rules
|
|
131
|
-
|
|
132
|
-
**Default**: Always use Vite + TanStack Router with TypeScript.
|
|
133
|
-
|
|
134
|
-
**Microfrontends**:
|
|
135
|
-
- **DEFAULT**: Vite + Single-SPA (`vite-plugin-single-spa` + `single-spa-react`) para todos los módulos de negocio
|
|
136
|
-
- **EXCEPCIÓN**: Vite + Module Federation SOLO para módulos transversales/compartidos explícitamente marcados por el ingeniero
|
|
137
|
-
|
|
138
|
-
**Reasoning**:
|
|
139
|
-
- Single-SPA proporciona aislamiento completo (CSS, JS, lifecycle), mejor hot reload, y error boundaries built-in
|
|
140
|
-
- Module Federation solo se usa cuando hay necesidad explícita de compartir código entre MFEs
|
|
141
|
-
- Ver `vite-config-standard.md` para configuración detallada
|
|
142
|
-
|
|
143
|
-
## Backend Architecture
|
|
144
|
-
|
|
145
|
-
### Architecture Style
|
|
146
|
-
- **Clean Architecture** + **Domain-Driven Design (DDD)** + **Microservices**
|
|
147
|
-
|
|
148
|
-
### Technology Stack
|
|
149
|
-
- **.NET 10** with **C# Minimal API**
|
|
150
|
-
- **Entity Framework Core** with **PostgreSQL 18+**
|
|
151
|
-
- **UUID (Guid)** primary keys mandatory
|
|
152
|
-
- **linq2db**, **DynamicLinq**, **LinqKit** for advanced queries
|
|
153
|
-
- **FluentValidation** for validation
|
|
154
|
-
- **xUnit** for testing
|
|
155
|
-
- **Scalar** for API documentation (NO Swagger)
|
|
156
|
-
- **QuestPDF** for PDF generation
|
|
157
|
-
|
|
158
|
-
### Folder Structure
|
|
159
|
-
|
|
160
|
-
.NET Solution Structure with Clean Architecture + DDD + Microservices:
|
|
161
|
-
|
|
162
|
-
```
|
|
163
|
-
├── src/
|
|
164
|
-
│ ├── Services/ # Microservices
|
|
165
|
-
│ │ ├── Sales/ # Sales domain microservice
|
|
166
|
-
│ │ │ ├── Sales.API/ # Minimal API project
|
|
167
|
-
│ │ │ │ ├── Program.cs # Application entry point
|
|
168
|
-
│ │ │ │ ├── appsettings.json
|
|
169
|
-
│ │ │ │ ├── Endpoints/ # Minimal API endpoints
|
|
170
|
-
│ │ │ │ │ ├── UserEndpoints.cs
|
|
171
|
-
│ │ │ │ │ └── QuoteEndpoints.cs
|
|
172
|
-
│ │ │ │ ├── Filters/
|
|
173
|
-
│ │ │ │ ├── Middleware/
|
|
174
|
-
│ │ │ │ └── Sales.API.csproj
|
|
175
|
-
│ │ │ │
|
|
176
|
-
│ │ │ ├── Sales.Application/ # Application layer
|
|
177
|
-
│ │ │ │ ├── Quotes/ # Bounded context
|
|
178
|
-
│ │ │ │ │ ├── Commands/
|
|
179
|
-
│ │ │ │ │ │ ├── CreateQuoteCommand.cs
|
|
180
|
-
│ │ │ │ │ │ └── CreateQuoteCommandHandler.cs
|
|
181
|
-
│ │ │ │ │ ├── Queries/
|
|
182
|
-
│ │ │ │ │ │ ├── GetQuoteByIdQuery.cs
|
|
183
|
-
│ │ │ │ │ │ └── GetQuoteByIdQueryHandler.cs
|
|
184
|
-
│ │ │ │ │ ├── DTOs/
|
|
185
|
-
│ │ │ │ │ │ └── QuoteResponseDto.cs
|
|
186
|
-
│ │ │ │ │ ├── Validators/ # FluentValidation
|
|
187
|
-
│ │ │ │ │ │ └── CreateQuoteCommandValidator.cs
|
|
188
|
-
│ │ │ │ │ └── Interfaces/ # Repository interfaces
|
|
189
|
-
│ │ │ │ │ └── IQuoteRepository.cs
|
|
190
|
-
│ │ │ │ └── Sales.Application.csproj
|
|
191
|
-
│ │ │ │
|
|
192
|
-
│ │ │ ├── Sales.Domain/ # Domain layer
|
|
193
|
-
│ │ │ │ ├── Quotes/ # Bounded context
|
|
194
|
-
│ │ │ │ │ ├── Entities/
|
|
195
|
-
│ │ │ │ │ │ └── QuoteEntity.cs
|
|
196
|
-
│ │ │ │ │ ├── ValueObjects/
|
|
197
|
-
│ │ │ │ │ │ ├── QuoteNumber.cs
|
|
198
|
-
│ │ │ │ │ │ └── Money.cs
|
|
199
|
-
│ │ │ │ │ ├── Aggregates/
|
|
200
|
-
│ │ │ │ │ │ └── QuoteAggregate.cs
|
|
201
|
-
│ │ │ │ │ ├── Events/
|
|
202
|
-
│ │ │ │ │ │ └── QuoteCreatedEvent.cs
|
|
203
|
-
│ │ │ │ │ └── Services/ # Domain services
|
|
204
|
-
│ │ │ │ │ └── QuotePricingService.cs
|
|
205
|
-
│ │ │ │ └── Sales.Domain.csproj
|
|
206
|
-
│ │ │ │
|
|
207
|
-
│ │ │ └── Sales.Infrastructure/ # Infrastructure layer
|
|
208
|
-
│ │ │ ├── Data/
|
|
209
|
-
│ │ │ │ ├── ApplicationDbContext.cs
|
|
210
|
-
│ │ │ │ ├── Configurations/ # EF Core configurations
|
|
211
|
-
│ │ │ │ │ ├── QuoteConfiguration.cs
|
|
212
|
-
│ │ │ │ │ └── UserConfiguration.cs
|
|
213
|
-
│ │ │ │ └── Migrations/ # EF Core migrations
|
|
214
|
-
│ │ │ ├── Repositories/ # Repository implementations
|
|
215
|
-
│ │ │ │ └── QuoteRepository.cs
|
|
216
|
-
│ │ │ ├── Services/ # External service adapters
|
|
217
|
-
│ │ │ │ └── EmailService.cs
|
|
218
|
-
│ │ │ └── Sales.Infrastructure.csproj
|
|
219
|
-
│ │ │
|
|
220
|
-
│ │ ├── Inventory/ # Inventory microservice (independent DB)
|
|
221
|
-
│ │ │ ├── Inventory.API/
|
|
222
|
-
│ │ │ ├── Inventory.Application/
|
|
223
|
-
│ │ │ ├── Inventory.Domain/
|
|
224
|
-
│ │ │ └── Inventory.Infrastructure/
|
|
225
|
-
│ │ │ └── Data/ # Separate PostgreSQL DB
|
|
226
|
-
│ │ │ └── InventoryDbContext.cs
|
|
227
|
-
│ │ │
|
|
228
|
-
│ │ └── Users/ # Users microservice (independent DB)
|
|
229
|
-
│ │ ├── Users.API/
|
|
230
|
-
│ │ ├── Users.Application/
|
|
231
|
-
│ │ ├── Users.Domain/
|
|
232
|
-
│ │ └── Users.Infrastructure/
|
|
233
|
-
│ │ └── Data/ # Separate PostgreSQL DB
|
|
234
|
-
│ │ └── UsersDbContext.cs
|
|
235
|
-
│ │
|
|
236
|
-
│ └── Shared/ # Shared libraries
|
|
237
|
-
│ ├── Shared.Domain/ # Shared domain concepts
|
|
238
|
-
│ │ ├── Base/
|
|
239
|
-
│ │ │ ├── AggregateRoot.cs
|
|
240
|
-
│ │ │ ├── Entity.cs
|
|
241
|
-
│ │ │ ├── ValueObject.cs
|
|
242
|
-
│ │ │ └── DomainEvent.cs
|
|
243
|
-
│ │ ├── Interfaces/
|
|
244
|
-
│ │ │ ├── IRepository.cs
|
|
245
|
-
│ │ │ └── IUnitOfWork.cs
|
|
246
|
-
│ │ └── Shared.Domain.csproj
|
|
247
|
-
│ │
|
|
248
|
-
│ ├── Shared.Infrastructure/ # Shared infrastructure
|
|
249
|
-
│ │ ├── Data/
|
|
250
|
-
│ │ │ ├── BaseRepository.cs
|
|
251
|
-
│ │ │ └── UnitOfWork.cs
|
|
252
|
-
│ │ ├── Filters/
|
|
253
|
-
│ │ │ └── ValidationFilter.cs
|
|
254
|
-
│ │ ├── Middleware/
|
|
255
|
-
│ │ │ ├── ExceptionHandlingMiddleware.cs
|
|
256
|
-
│ │ │ └── LoggingMiddleware.cs
|
|
257
|
-
│ │ └── Shared.Infrastructure.csproj
|
|
258
|
-
│ │
|
|
259
|
-
│ └── Shared.Common/ # Common utilities
|
|
260
|
-
│ ├── Extensions/
|
|
261
|
-
│ │ ├── StringExtensions.cs
|
|
262
|
-
│ │ └── GuidExtensions.cs
|
|
263
|
-
│ ├── Helpers/
|
|
264
|
-
│ │ └── DateTimeHelper.cs
|
|
265
|
-
│ ├── Constants/
|
|
266
|
-
│ │ └── ErrorMessages.cs
|
|
267
|
-
│ └── Shared.Common.csproj
|
|
268
|
-
│
|
|
269
|
-
├── tests/ # Test projects
|
|
270
|
-
│ ├── Sales.UnitTests/
|
|
271
|
-
│ │ ├── Domain/
|
|
272
|
-
│ │ ├── Application/
|
|
273
|
-
│ │ └── Sales.UnitTests.csproj
|
|
274
|
-
│ ├── Sales.IntegrationTests/
|
|
275
|
-
│ │ ├── Repositories/
|
|
276
|
-
│ │ ├── API/
|
|
277
|
-
│ │ └── Sales.IntegrationTests.csproj
|
|
278
|
-
│ ├── Inventory.UnitTests/
|
|
279
|
-
│ └── Users.UnitTests/
|
|
280
|
-
│
|
|
281
|
-
├── docker/ # Docker configurations (Production only)
|
|
282
|
-
│ ├── docker-compose.yml
|
|
283
|
-
│ └── Dockerfiles/
|
|
284
|
-
│ ├── Sales.Dockerfile
|
|
285
|
-
│ ├── Inventory.Dockerfile
|
|
286
|
-
│ └── Users.Dockerfile
|
|
287
|
-
│
|
|
288
|
-
└── YourSolution.sln # Solution file
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
### Microservices Communication Patterns
|
|
292
|
-
|
|
293
|
-
#### 1. Synchronous Communication (REST)
|
|
294
|
-
```csharp
|
|
295
|
-
// HTTP client for inter-service communication
|
|
296
|
-
public class InventoryServiceClient
|
|
297
|
-
{
|
|
298
|
-
private readonly HttpClient _httpClient;
|
|
299
|
-
|
|
300
|
-
public InventoryServiceClient(HttpClient httpClient)
|
|
301
|
-
{
|
|
302
|
-
_httpClient = httpClient;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
public async Task<ProductAvailabilityDto> CheckProductAvailabilityAsync(
|
|
306
|
-
Guid productId,
|
|
307
|
-
CancellationToken cancellationToken)
|
|
308
|
-
{
|
|
309
|
-
var response = await _httpClient.GetAsync(
|
|
310
|
-
$"/api/products/{productId}/availability",
|
|
311
|
-
cancellationToken);
|
|
312
|
-
response.EnsureSuccessStatusCode();
|
|
313
|
-
return await response.Content.ReadFromJsonAsync<ProductAvailabilityDto>(cancellationToken);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
#### 2. Asynchronous Communication (Message Broker)
|
|
319
|
-
- **RabbitMQ** or **Azure Service Bus** for event-driven architecture
|
|
320
|
-
- Each microservice publishes domain events
|
|
321
|
-
- Other services subscribe to relevant events
|
|
322
|
-
|
|
323
|
-
#### 3. gRPC for High-Performance Communication
|
|
324
|
-
- Use for internal high-throughput service-to-service calls
|
|
325
|
-
- Protocol Buffers for efficient serialization
|
|
326
|
-
|
|
327
|
-
### Database per Microservice Pattern
|
|
328
|
-
|
|
329
|
-
**Key Principles:**
|
|
330
|
-
- Each microservice has its own PostgreSQL database (v18+)
|
|
331
|
-
- No direct database access between services
|
|
332
|
-
- Data consistency via eventual consistency and sagas
|
|
333
|
-
- Each database uses UUID (Guid) primary keys
|
|
334
|
-
|
|
335
|
-
**Connection String Pattern:**
|
|
336
|
-
```json
|
|
337
|
-
{
|
|
338
|
-
"ConnectionStrings": {
|
|
339
|
-
"SalesDb": "Host=localhost;Database=sales_db;Username=admin;Password=***",
|
|
340
|
-
"InventoryDb": "Host=localhost;Database=inventory_db;Username=admin;Password=***",
|
|
341
|
-
"UsersDb": "Host=localhost;Database=users_db;Username=admin;Password=***"
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
```
|
|
345
|
-
|
|
346
|
-
### Core Backend Principles
|
|
347
|
-
|
|
348
|
-
#### Clean Architecture Layers
|
|
349
|
-
1. **Domain Layer** - Business entities, value objects, domain services (no dependencies)
|
|
350
|
-
2. **Application Layer** - Commands, queries, validators, interfaces (depends on Domain)
|
|
351
|
-
3. **Infrastructure Layer** - EF Core, repositories, external services (depends on Application)
|
|
352
|
-
4. **Presentation Layer** - Minimal API endpoints (depends on Application)
|
|
353
|
-
|
|
354
|
-
#### UUID Primary Keys
|
|
355
|
-
```csharp
|
|
356
|
-
public abstract class Entity
|
|
357
|
-
{
|
|
358
|
-
public Guid Id { get; protected set; } = Guid.NewGuid();
|
|
359
|
-
}
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
#### Entity Framework Core Configuration
|
|
363
|
-
```csharp
|
|
364
|
-
public class QuoteConfiguration : IEntityTypeConfiguration<QuoteEntity>
|
|
365
|
-
{
|
|
366
|
-
public void Configure(EntityTypeBuilder<QuoteEntity> builder)
|
|
367
|
-
{
|
|
368
|
-
builder.ToTable("Quotes");
|
|
369
|
-
builder.HasKey(q => q.Id);
|
|
370
|
-
|
|
371
|
-
builder.Property(q => q.Id)
|
|
372
|
-
.HasColumnType("uuid")
|
|
373
|
-
.IsRequired();
|
|
374
|
-
|
|
375
|
-
builder.OwnsOne(q => q.QuoteNumber, qn =>
|
|
376
|
-
{
|
|
377
|
-
qn.Property(n => n.Value)
|
|
378
|
-
.HasColumnName("QuoteNumber")
|
|
379
|
-
.HasMaxLength(50)
|
|
380
|
-
.IsRequired();
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
```
|
|
385
|
-
|
|
386
|
-
#### Test-Driven Development
|
|
387
|
-
- Write xUnit tests before or alongside implementation
|
|
388
|
-
- Use EF Core InMemory for fast unit tests
|
|
389
|
-
- Use PostgreSQL 18+ Test Containers for integration tests
|
|
390
|
-
- Mock external dependencies
|
|
391
|
-
|
|
392
|
-
#### FluentValidation Usage
|
|
393
|
-
```csharp
|
|
394
|
-
public class CreateQuoteCommandValidator : AbstractValidator<CreateQuoteCommand>
|
|
395
|
-
{
|
|
396
|
-
public CreateQuoteCommandValidator()
|
|
397
|
-
{
|
|
398
|
-
RuleFor(x => x.CustomerId)
|
|
399
|
-
.NotEmpty()
|
|
400
|
-
.WithMessage("Customer ID is required");
|
|
401
|
-
|
|
402
|
-
RuleFor(x => x.Items)
|
|
403
|
-
.NotEmpty()
|
|
404
|
-
.WithMessage("At least one item is required");
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
```
|
|
408
|
-
|
|
409
|
-
#### Scalar API Documentation
|
|
410
|
-
Register Scalar instead of Swagger in Program.cs:
|
|
411
|
-
```csharp
|
|
412
|
-
app.MapScalarApiReference(); // NOT app.UseSwagger()
|
|
413
|
-
```
|
|
414
|
-
|
|
415
|
-
## Summary
|
|
416
|
-
|
|
417
|
-
### Frontend
|
|
418
|
-
- **Bundler**: Vite 5+
|
|
419
|
-
- **Router**: TanStack Router (file-based, type-safe)
|
|
420
|
-
- **Framework**: React 18+ with TypeScript (strict mode)
|
|
421
|
-
- **Architecture**: Clean Architecture + DDD
|
|
422
|
-
- **State**: Zustand (client) + TanStack Query (server)
|
|
423
|
-
- **UI**: shadcn/ui + Radix UI + TailwindCSS v4
|
|
424
|
-
- **Testing**: Vitest + React Testing Library
|
|
425
|
-
- **Validation**: Zod + React Hook Form
|
|
426
|
-
|
|
427
|
-
### Backend
|
|
428
|
-
- **Framework**: .NET 10 with C# Minimal API
|
|
429
|
-
- **Architecture**: Clean Architecture + DDD + Microservices
|
|
430
|
-
- **Database**: PostgreSQL 18+ (one per microservice)
|
|
431
|
-
- **ORM**: Entity Framework Core + linq2db + DynamicLinq + LinqKit
|
|
432
|
-
- **Validation**: FluentValidation
|
|
433
|
-
- **Testing**: xUnit + EF Core InMemory + PostgreSQL 18+ Test Containers
|
|
434
|
-
- **Documentation**: Scalar (NO Swagger)
|
|
435
|
-
- **Primary Keys**: UUID (Guid) mandatory
|
|
436
|
-
- **PDF Generation**: QuestPDF
|
|
437
|
-
|
|
438
|
-
### Key Principles
|
|
439
|
-
1. **Clean Architecture** - Strict layer separation in both frontend and backend
|
|
440
|
-
2. **Domain-Driven Design** - Business logic drives all decisions
|
|
441
|
-
3. **Test-Driven Development** - Tests before/alongside implementation
|
|
442
|
-
4. **Database per Microservice** - Complete isolation between services
|
|
443
|
-
5. **Type Safety** - TypeScript (frontend) and C# (backend) strong typing
|
|
444
|
-
6. **Docker for Production** - Local development without containers
|