@jeffrey2423/coding-standards 1.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 ADDED
@@ -0,0 +1,204 @@
1
+ # Coding Standards & Architecture Guide
2
+
3
+ Centralized repository of coding standards, architectural patterns, and technical conventions for building enterprise-scale applications. Enforces **Clean Architecture**, **Domain-Driven Design (DDD)**, and **microservices patterns** across all platforms.
4
+
5
+ ## Quick Start
6
+
7
+ Copy all coding standards into any project:
8
+
9
+ ```bash
10
+ npx @jeffrey2423/coding-standards
11
+ ```
12
+
13
+ This creates a `coding-standards/` folder with all standard documents.
14
+
15
+ ## Table of Contents
16
+
17
+ - [Technology Stack](#technology-stack)
18
+ - [Architecture Overview](#architecture-overview)
19
+ - [Standards by Platform](#standards-by-platform)
20
+ - [Database Conventions](#database-conventions)
21
+ - [Design System & UX](#design-system--ux)
22
+ - [Key Principles](#key-principles)
23
+ - [Document Index](#document-index)
24
+
25
+ ## Technology Stack
26
+
27
+ ### Frontend (Web)
28
+
29
+ | Category | Technology | Version |
30
+ |----------|-----------|---------|
31
+ | Bundler | Vite | 7+ |
32
+ | Framework | React | 18+ |
33
+ | Language | TypeScript | 5+ (strict mode) |
34
+ | Routing | TanStack Router | 1+ (file-based) |
35
+ | Client State | Zustand | 5+ |
36
+ | Server State | TanStack Query | 5+ |
37
+ | UI Components | shadcn/ui + Radix UI | Latest |
38
+ | Styling | TailwindCSS | v4 |
39
+ | Forms | React Hook Form + Zod | Latest |
40
+ | Testing | Vitest + React Testing Library + MSW | Latest |
41
+
42
+ ### Backend
43
+
44
+ | Category | Technology | Version |
45
+ |----------|-----------|---------|
46
+ | Runtime | .NET | 10 |
47
+ | Language | C# | Latest (Minimal API) |
48
+ | Primary ORM | Entity Framework Core | 10 |
49
+ | Performance ORM | linq2db | Latest |
50
+ | Database | PostgreSQL | 18+ (mandatory) |
51
+ | Validation | FluentValidation | Latest |
52
+ | Testing | xUnit | Latest |
53
+ | API Docs | Scalar | Latest (NOT Swagger) |
54
+
55
+ ### Mobile
56
+
57
+ | Platform | Framework | State | Navigation | Styling |
58
+ |----------|-----------|-------|------------|---------|
59
+ | Flutter | Flutter SDK | Riverpod 3+ | GoRouter 14+ | Material Design 3 |
60
+ | React Native | Expo SDK 53+ | Zustand | Expo Router 4+ | NativeWind 4+ (Tailwind) |
61
+
62
+ ### Microfrontends
63
+
64
+ | Pattern | Usage |
65
+ |---------|-------|
66
+ | **Single-SPA** | **DEFAULT** for all business modules |
67
+ | Module Federation | ONLY for explicitly shared/transversal modules |
68
+
69
+ ## Architecture Overview
70
+
71
+ All platforms follow **Clean Architecture + DDD** with strict layer separation:
72
+
73
+ ```
74
+ Domain Layer → Entities, Value Objects, Aggregates, Domain Events
75
+
76
+ Application Layer → Commands, Queries, Handlers, DTOs, Validators
77
+
78
+ Infrastructure Layer → Repositories, ORM, External Services, API Clients
79
+
80
+ Presentation Layer → UI Components, Routes, Pages, Endpoints
81
+ ```
82
+
83
+ ### Frontend Folder Structure
84
+
85
+ ```
86
+ src/
87
+ ├── routes/ # TanStack Router (route definitions only)
88
+ ├── modules/ # Business logic (Module/Domain/Feature)
89
+ │ └── sales/ # MODULE
90
+ │ └── quotes/ # DOMAIN
91
+ │ └── cart/ # FEATURE (domain/application/infrastructure/presentation)
92
+ ├── shared/ # Reusable components, hooks, types
93
+ ├── app/ # Global config, providers, stores
94
+ ├── infrastructure/ # External services (API, storage, PWA)
95
+ ├── assets/ # Static resources
96
+ └── styles/ # Global styles
97
+ ```
98
+
99
+ ### Backend Project Structure (per Microservice)
100
+
101
+ ```
102
+ Service.Domain/ # Entities, Value Objects, Domain Events
103
+ Service.Application/ # Use Cases, DTOs, Validators, Interfaces
104
+ Service.Infrastructure/ # EF Core, Repositories, External Services
105
+ Service.API/ # Minimal API Endpoints
106
+ Service.Tests/ # xUnit Tests
107
+ ```
108
+
109
+ ## Standards by Platform
110
+
111
+ ### Frontend Standards
112
+
113
+ - **Language Rule**: ALL user-visible text in **Spanish**, code/logs/comments in English
114
+ - TanStack Router with file-based routing conventions (`_` pathless layouts, `$` dynamic params)
115
+ - State split: Zustand (global client) / TanStack Query (server) / useState (local)
116
+ - Component naming: PascalCase files, kebab-case `data-testid`
117
+ - WCAG 2.1 AA accessibility compliance
118
+ - Testing: Unit (use cases) → Integration (features) → Component (RTL) → E2E (critical paths)
119
+
120
+ ### Backend Standards
121
+
122
+ - **Critical**: Always use `DateTimeOffset` for timestamps (NEVER `DateTime`)
123
+ - Minimal API pattern with endpoint grouping
124
+ - Multi-ORM strategy: EF Core (CRUD) / linq2db (performance) / DynamicLinq (runtime filters)
125
+ - UUID (Guid) primary keys for all entities
126
+ - Database per Microservice pattern
127
+ - TDD with xUnit, InMemory for unit tests, TestContainers for integration
128
+
129
+ ### Mobile Standards
130
+
131
+ Both Flutter and React Native follow Clean Architecture + DDD + Feature-First organization with platform-specific tooling.
132
+
133
+ ## Database Conventions
134
+
135
+ **PostgreSQL** is the mandatory database engine. Key conventions:
136
+
137
+ | Element | C# Convention | PostgreSQL Convention | Example |
138
+ |---------|--------------|----------------------|---------|
139
+ | Tables | PascalCase | snake_case | `OrderItems` → `order_items` |
140
+ | Columns | PascalCase | snake_case | `CreatedAt` → `created_at` |
141
+ | Foreign Keys | `{Entity}ID` | `{entity}_id` | `WarehouseID` → `warehouse_id` |
142
+ | Primary Keys | `Guid` | `uuid` | `DEFAULT uuidv7()` |
143
+ | Indexes | - | `ix_{table}_{cols}` | `ix_orders_created_at` |
144
+ | Unique | - | `uk_{table}_{cols}` | `uk_users_email` |
145
+ | Projections | `{PREFIX}_{Entity}Prj` | `{prefix}_{table}_prj` | `AUTH_UserPrj` → `auth_users_prj` |
146
+
147
+ EF Core handles automatic snake_case conversion via `SnakeCaseNamingConvention` — no manual `[Column]` or `[Table]` attributes needed.
148
+
149
+ ## Design System & UX
150
+
151
+ ### Colors
152
+
153
+ | Role | Value | Usage |
154
+ |------|-------|-------|
155
+ | Primary | `#0E79FD` | Brand blue, main actions |
156
+ | Secondary | `#000000` | Brand elements only (NOT backgrounds) |
157
+ | Tertiary | `#154CA9` | Dark blue accents |
158
+ | Neutrals | Tailwind `slate` scale | Backgrounds, borders, text |
159
+
160
+ ### Typography
161
+
162
+ - **Font**: Inter (Light 300, Regular 400, Bold 700)
163
+ - **Scale**: Tailwind typography utilities (h1–h6, body, interactive)
164
+
165
+ ### Performance Targets
166
+
167
+ | Metric | Target |
168
+ |--------|--------|
169
+ | Initial Bundle | < 500KB gzipped |
170
+ | First Contentful Paint | < 1.5s |
171
+ | Largest Contentful Paint | < 2.5s |
172
+ | Cumulative Layout Shift | < 0.1 |
173
+
174
+ ### Icons & Loading
175
+
176
+ - Primary icons: **Heroicons**
177
+ - Secondary icons: Font Awesome 6.5+
178
+ - Loading states: `react-loading-skeleton` v3.4.0
179
+
180
+ ## Key Principles
181
+
182
+ 1. **Clean Architecture** — Strict layer separation with dependency inversion across all platforms
183
+ 2. **Domain-Driven Design** — Business logic organized by bounded contexts drives architecture
184
+ 3. **Test-Driven Development** — Tests alongside implementation, >80% coverage required
185
+ 4. **Type Safety** — TypeScript strict mode (frontend), C# (backend), Dart (Flutter)
186
+ 5. **Database per Microservice** — Complete data isolation between services
187
+ 6. **UUID Primary Keys** — All entities use UUIDs for distributed system compatibility
188
+ 7. **Spanish UI / English Code** — User-facing content in Spanish, codebase in English
189
+ 8. **Single-SPA Default** — Microfrontends use Single-SPA; Module Federation only for explicit sharing
190
+ 9. **Accessibility First** — WCAG 2.1 AA, 4.5:1 contrast, 44px touch targets, keyboard navigation
191
+
192
+ ## Document Index
193
+
194
+ | Document | Description |
195
+ |----------|-------------|
196
+ | [technology-stack.md](standards/technology-stack.md) | Complete technology stack with versions and rationale |
197
+ | [architecture-patterns.md](standards/architecture-patterns.md) | Frontend and backend architectural patterns |
198
+ | [backend-standards.md](standards/backend-standards.md) | .NET backend development standards and conventions |
199
+ | [frontend-standards.md](standards/frontend-standards.md) | React/TypeScript frontend standards and folder structure |
200
+ | [database-conventions.md](standards/database-conventions.md) | PostgreSQL naming conventions and EF Core mapping |
201
+ | [vite-config-standard.md](standards/vite-config-standard.md) | Microfrontend configuration (Single-SPA & Module Federation) |
202
+ | [technical-preferences-ux.md](standards/technical-preferences-ux.md) | Design system, colors, typography, UX guidelines |
203
+ | [mobile-flutter-standards.md](standards/mobile-flutter-standards.md) | Flutter mobile development standards |
204
+ | [mobile-react-native-standards.md](standards/mobile-react-native-standards.md) | React Native mobile development standards |
package/bin/cli.js ADDED
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+
6
+ const standardsDir = path.join(__dirname, "..", "standards");
7
+ const targetDir = path.join(process.cwd(), "coding-standards");
8
+
9
+ const files = fs
10
+ .readdirSync(standardsDir)
11
+ .filter((f) => f.endsWith(".md"));
12
+
13
+ if (files.length === 0) {
14
+ console.error("No standard files found in package.");
15
+ process.exit(1);
16
+ }
17
+
18
+ const existed = fs.existsSync(targetDir);
19
+ if (existed) {
20
+ console.log("coding-standards/ already exists — overwriting files.\n");
21
+ }
22
+
23
+ fs.mkdirSync(targetDir, { recursive: true });
24
+
25
+ for (const file of files) {
26
+ fs.copyFileSync(path.join(standardsDir, file), path.join(targetDir, file));
27
+ }
28
+
29
+ console.log(
30
+ `Copied ${files.length} coding standard files to coding-standards/:\n`
31
+ );
32
+ for (const file of files) {
33
+ console.log(` - ${file}`);
34
+ }
35
+ console.log("\nDone!");
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@jeffrey2423/coding-standards",
3
+ "version": "1.0.0",
4
+ "description": "Copy coding standards and architecture guides into your project",
5
+ "license": "MIT",
6
+ "bin": {
7
+ "coding-standards": "bin/cli.js"
8
+ },
9
+ "files": [
10
+ "bin/",
11
+ "standards/"
12
+ ],
13
+ "keywords": [
14
+ "coding-standards",
15
+ "architecture",
16
+ "clean-architecture",
17
+ "ddd"
18
+ ]
19
+ }