front-end-dev-standards 1.0.0 → 1.1.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.
@@ -0,0 +1,654 @@
1
+ # Architecture Standards
2
+
3
+ Version: 1.0
4
+ Target: Angular 20+
5
+ Architecture Style: Feature-Based + Domain-Driven Design (DDD)
6
+ Applies To: All HRMS Frontend Applications
7
+
8
+ ---
9
+
10
+ # 1. Architecture Principles
11
+
12
+ ## Core Principles
13
+
14
+ 1. Feature First Organization
15
+ 2. Domain Driven Design
16
+ 3. Standalone Angular Architecture
17
+ 4. Signals First State Management
18
+ 5. Unidirectional Data Flow
19
+ 6. Dependency Rule Enforcement
20
+ 7. Lazy Loading by Default
21
+ 8. Shared Code by Exception
22
+ 9. Security by Design
23
+ 10. Scalability Over Convenience
24
+
25
+ ---
26
+
27
+ # 2. Architecture Overview
28
+
29
+ ```text
30
+ ┌─────────────────────────────────┐
31
+ │ APP SHELL │
32
+ │ Header | Sidebar | Layout │
33
+ └─────────────────────────────────┘
34
+
35
+
36
+ ┌─────────────────────────────────┐
37
+ │ FEATURES │
38
+ │ Employees | Payroll | Leaves │
39
+ │ Attendance | Recruitment │
40
+ └─────────────────────────────────┘
41
+
42
+
43
+ ┌─────────────────────────────────┐
44
+ │ SHARED │
45
+ │ Components | Pipes | Directives │
46
+ └─────────────────────────────────┘
47
+
48
+
49
+ ┌─────────────────────────────────┐
50
+ │ CORE │
51
+ │ Auth | API | Guards | Logging │
52
+ └─────────────────────────────────┘
53
+ ```
54
+
55
+ ---
56
+
57
+ # 3. Folder Structure
58
+
59
+ ```text
60
+ src/
61
+ ├── app/
62
+
63
+ ├── core/
64
+ │ ├── auth/
65
+ │ ├── guards/
66
+ │ ├── interceptors/
67
+ │ ├── services/
68
+ │ ├── config/
69
+ │ └── constants/
70
+
71
+ ├── shared/
72
+ │ ├── ui/
73
+ │ ├── directives/
74
+ │ ├── pipes/
75
+ │ ├── models/
76
+ │ ├── utils/
77
+ │ └── validators/
78
+
79
+ ├── features/
80
+ │ ├── employees/
81
+ │ ├── attendance/
82
+ │ ├── payroll/
83
+ │ ├── recruitment/
84
+ │ ├── leaves/
85
+ │ └── timesheet/
86
+
87
+ ├── layout/
88
+ │ ├── header/
89
+ │ ├── sidebar/
90
+ │ ├── footer/
91
+ │ └── shell/
92
+
93
+ ├── assets/
94
+ ├── environments/
95
+ └── styles/
96
+ ```
97
+
98
+ ---
99
+
100
+ # 4. Feature Structure
101
+
102
+ Each feature is a complete vertical slice.
103
+
104
+ ```text
105
+ features/timesheet/
106
+
107
+ ├── pages/
108
+ │ ├── timesheet-list/
109
+ │ ├── timesheet-detail/
110
+ │ └── timesheet-create/
111
+
112
+ ├── components/
113
+ │ ├── timesheet-calendar/
114
+ │ ├── timesheet-preview/
115
+ │ └── weekly-summary/
116
+
117
+ ├── services/
118
+ │ ├── timesheet.service.ts
119
+ │ └── timesheet-store.service.ts
120
+
121
+ ├── models/
122
+ │ ├── timesheet.model.ts
123
+ │ ├── create-timesheet-request.ts
124
+ │ └── timesheet-filter.ts
125
+
126
+ ├── guards/
127
+
128
+ ├── resolvers/
129
+
130
+ ├── timesheet.routes.ts
131
+ └── index.ts
132
+ ```
133
+
134
+ ---
135
+
136
+ # 5. Dependency Rules
137
+
138
+ ## Allowed
139
+
140
+ ```text
141
+ Feature
142
+ ├── Shared
143
+ ├── Core
144
+ └── Angular Framework
145
+ ```
146
+
147
+ ## Forbidden
148
+
149
+ ```text
150
+ Feature A ───► Feature B
151
+ ```
152
+
153
+ ```text
154
+ Shared ───► Feature
155
+ ```
156
+
157
+ ```text
158
+ Core ───► Feature
159
+ ```
160
+
161
+ ---
162
+
163
+ # 6. Layer Responsibilities
164
+
165
+ ## Core Layer
166
+
167
+ Application-wide infrastructure.
168
+
169
+ Contains:
170
+
171
+ * Authentication
172
+ * Authorization
173
+ * Interceptors
174
+ * Logging
175
+ * Global Configuration
176
+ * Feature Flags
177
+ * Notification Services
178
+
179
+ Never Contains:
180
+
181
+ * Business Logic
182
+ * Feature Components
183
+ * Domain Models
184
+
185
+ ---
186
+
187
+ ## Shared Layer
188
+
189
+ Reusable UI Building Blocks.
190
+
191
+ Contains:
192
+
193
+ * Buttons
194
+ * Tables
195
+ * Dialogs
196
+ * Pipes
197
+ * Validators
198
+ * Utility Functions
199
+
200
+ Must Be:
201
+
202
+ * Stateless
203
+ * Generic
204
+ * Feature Independent
205
+
206
+ Never Contains:
207
+
208
+ * Feature Services
209
+ * API Calls
210
+ * Feature Models
211
+
212
+ ---
213
+
214
+ ## Feature Layer
215
+
216
+ Business functionality.
217
+
218
+ Contains:
219
+
220
+ * Pages
221
+ * Components
222
+ * Services
223
+ * Models
224
+ * Routes
225
+
226
+ Must Own:
227
+
228
+ * Feature State
229
+ * Feature API Logic
230
+ * Feature UI
231
+
232
+ ---
233
+
234
+ # 7. Smart vs Presentational Components
235
+
236
+ ## Smart Components
237
+
238
+ Responsibilities:
239
+
240
+ * Data Fetching
241
+ * Service Interaction
242
+ * State Management
243
+ * Navigation
244
+
245
+ Example:
246
+
247
+ ```typescript
248
+ export class EmployeeListPage {
249
+ private readonly employeeService =
250
+ inject(EmployeeService);
251
+
252
+ readonly employees =
253
+ signal<Employee[]>([]);
254
+ }
255
+ ```
256
+
257
+ Naming:
258
+
259
+ ```text
260
+ employee-list.page.ts
261
+ employee-detail.page.ts
262
+ ```
263
+
264
+ ---
265
+
266
+ ## Presentational Components
267
+
268
+ Responsibilities:
269
+
270
+ * Rendering
271
+ * User Interaction
272
+ * Event Emission
273
+
274
+ Example:
275
+
276
+ ```typescript
277
+ export class EmployeeCardComponent {
278
+ readonly employee =
279
+ input.required<Employee>();
280
+
281
+ readonly selected =
282
+ output<Employee>();
283
+ }
284
+ ```
285
+
286
+ Must Not:
287
+
288
+ * Inject Feature Services
289
+ * Perform API Calls
290
+
291
+ ---
292
+
293
+ # 8. State Management Strategy
294
+
295
+ ## Level 1
296
+
297
+ Component Signals
298
+
299
+ ```typescript
300
+ readonly loading = signal(false);
301
+ readonly employees = signal<Employee[]>([]);
302
+ ```
303
+
304
+ Default choice.
305
+
306
+ ---
307
+
308
+ ## Level 2
309
+
310
+ Feature Store
311
+
312
+ ```typescript
313
+ EmployeeStore
314
+ AttendanceStore
315
+ PayrollStore
316
+ ```
317
+
318
+ Use when state is shared within a feature.
319
+
320
+ ---
321
+
322
+ ## Level 3
323
+
324
+ Global Store
325
+
326
+ Use only when:
327
+
328
+ * Shared across multiple features
329
+ * Complex orchestration required
330
+
331
+ Examples:
332
+
333
+ * User Session
334
+ * Permissions
335
+ * Global Settings
336
+
337
+ ---
338
+
339
+ # 9. Data Flow Rules
340
+
341
+ ```text
342
+ API
343
+
344
+
345
+ Service
346
+
347
+
348
+ Store / Signal
349
+
350
+
351
+ Page Component
352
+
353
+
354
+ Presentational Component
355
+ ```
356
+
357
+ Data Flow:
358
+
359
+ Top Down
360
+
361
+ Events Flow:
362
+
363
+ Bottom Up
364
+
365
+ No Circular Communication.
366
+
367
+ ---
368
+
369
+ # 10. API Layer Architecture
370
+
371
+ ## Service Pattern
372
+
373
+ ```typescript
374
+ EmployeeService
375
+ PayrollService
376
+ AttendanceService
377
+ ```
378
+
379
+ Responsibilities:
380
+
381
+ * API Calls
382
+ * DTO Mapping
383
+ * Response Transformation
384
+
385
+ Never:
386
+
387
+ * UI Logic
388
+ * Component State
389
+
390
+ ---
391
+
392
+ # 11. DTO Strategy
393
+
394
+ Separate Models
395
+
396
+ ```typescript
397
+ Employee
398
+ CreateEmployeeRequest
399
+ UpdateEmployeeRequest
400
+ EmployeeResponse
401
+ EmployeeViewModel
402
+ ```
403
+
404
+ Never reuse API models directly in complex UI.
405
+
406
+ Map API models to ViewModels.
407
+
408
+ ---
409
+
410
+ # 12. Routing Architecture
411
+
412
+ ## Rules
413
+
414
+ Every Feature Owns Routes
415
+
416
+ ```text
417
+ employees.routes.ts
418
+ payroll.routes.ts
419
+ attendance.routes.ts
420
+ ```
421
+
422
+ All Features Lazy Loaded
423
+
424
+ ```typescript
425
+ loadChildren()
426
+ loadComponent()
427
+ ```
428
+
429
+ No Eager Feature Loading.
430
+
431
+ ---
432
+
433
+ # 13. Layout Architecture
434
+
435
+ ```text
436
+ Shell
437
+ ├── Header
438
+ ├── Sidebar
439
+ ├── Content
440
+ └── Footer
441
+ ```
442
+
443
+ Responsibilities:
444
+
445
+ * Navigation
446
+ * User Context
447
+ * Responsive Layout
448
+
449
+ Must Not:
450
+
451
+ * Feature Logic
452
+
453
+ ---
454
+
455
+ # 14. Shared Component Guidelines
456
+
457
+ Promote to Shared only when:
458
+
459
+ Used in 2+ Features
460
+
461
+ Examples:
462
+
463
+ ```text
464
+ DataTable
465
+ PageHeader
466
+ ConfirmDialog
467
+ LoadingSpinner
468
+ ```
469
+
470
+ Not Shared:
471
+
472
+ ```text
473
+ EmployeeCard
474
+ PayrollSummary
475
+ TimesheetCalendar
476
+ ```
477
+
478
+ These belong to features.
479
+
480
+ ---
481
+
482
+ # 15. Scalability Rules
483
+
484
+ Split Feature When:
485
+
486
+ * More than 20 Components
487
+ * Multiple Domains
488
+ * Independent Release Cycle
489
+
490
+ Example:
491
+
492
+ ```text
493
+ Recruitment
494
+ ├── Candidates
495
+ ├── Interviews
496
+ └── Job Openings
497
+ ```
498
+
499
+ Can become separate features.
500
+
501
+ ---
502
+
503
+ # 16. Micro Frontend Readiness
504
+
505
+ Features must be:
506
+
507
+ * Self Contained
508
+ * Independently Deployable
509
+ * Loosely Coupled
510
+
511
+ Avoid direct feature imports.
512
+
513
+ ---
514
+
515
+ # 17. Security Architecture
516
+
517
+ All requests pass through:
518
+
519
+ ```text
520
+ Auth Interceptor
521
+ Error Interceptor
522
+ Audit Interceptor
523
+ ```
524
+
525
+ Responsibilities:
526
+
527
+ * Token Injection
528
+ * Error Handling
529
+ * Logging
530
+
531
+ Never bypass interceptors.
532
+
533
+ ---
534
+
535
+ # 18. Caching Strategy
536
+
537
+ Allowed:
538
+
539
+ ```typescript
540
+ signal()
541
+ computed()
542
+ shareReplay()
543
+ ```
544
+
545
+ Use for:
546
+
547
+ * Reference Data
548
+ * Lookup Lists
549
+ * User Preferences
550
+
551
+ Avoid duplicate API calls.
552
+
553
+ ---
554
+
555
+ # 19. Performance Architecture
556
+
557
+ Mandatory:
558
+
559
+ * Lazy Loaded Features
560
+ * OnPush Components
561
+ * Signals
562
+ * Route Level Code Splitting
563
+ * Track Functions
564
+ * Virtual Scrolling for Large Lists
565
+
566
+ ---
567
+
568
+ # 20. Testing Architecture
569
+
570
+ Co-Locate Tests
571
+
572
+ ```text
573
+ employee.service.ts
574
+ employee.service.spec.ts
575
+ ```
576
+
577
+ Coverage Targets:
578
+
579
+ * Services > 90%
580
+ * Components > 80%
581
+ * Critical Business Logic > 95%
582
+
583
+ ---
584
+
585
+ # 21. Monorepo Readiness
586
+
587
+ Future Structure
588
+
589
+ ```text
590
+ apps/
591
+ hrms/
592
+
593
+ libs/
594
+ shared-ui/
595
+ shared-utils/
596
+ auth/
597
+ employees/
598
+ payroll/
599
+ ```
600
+
601
+ Architecture should support migration to Nx without major refactoring.
602
+
603
+ ---
604
+
605
+ # 22. Architectural Decision Records
606
+
607
+ Major architectural changes require ADRs.
608
+
609
+ ```text
610
+ docs/adr/
611
+
612
+ 001-use-signals.md
613
+ 002-feature-based-architecture.md
614
+ 003-ngrx-adoption.md
615
+ ```
616
+
617
+ Document:
618
+
619
+ * Problem
620
+ * Decision
621
+ * Alternatives
622
+ * Consequences
623
+
624
+ ---
625
+
626
+ # 23. Definition of Architectural Compliance
627
+
628
+ A feature is architecture compliant when:
629
+
630
+ ✓ Standalone Components
631
+
632
+ ✓ Feature-Based Structure
633
+
634
+ ✓ Signals First
635
+
636
+ ✓ Lazy Loaded
637
+
638
+ ✓ No Cross Feature Imports
639
+
640
+ ✓ Shared Components Reusable
641
+
642
+ ✓ API Calls Through Services
643
+
644
+ ✓ OnPush Everywhere
645
+
646
+ ✓ Typed Models
647
+
648
+ ✓ Tests Included
649
+
650
+ ✓ Security Reviewed
651
+
652
+ ✓ Performance Reviewed
653
+
654
+ ✓ Accessibility Verified