@jeffrey2423/coding-standards 1.0.0 → 2.0.1

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.
Files changed (28) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +101 -174
  3. package/bin/cli.js +373 -20
  4. package/package.json +22 -3
  5. package/standards/backend/architecture/event-driven.md +112 -0
  6. package/standards/backend/architecture/microservice-anatomy.md +106 -0
  7. package/standards/backend/architecture/multitenancy.md +112 -0
  8. package/standards/backend/architecture/public-api-facade.md +112 -0
  9. package/standards/backend/architecture/shared-vs-owned.md +62 -0
  10. package/standards/{backend-standards.md → backend/backend-standards.md} +8 -1
  11. package/standards/{database-conventions.md → backend/database-conventions.md} +7 -0
  12. package/standards/backend/technology-stack.md +73 -0
  13. package/standards/core/ai-collaboration.md +64 -0
  14. package/standards/core/clean-architecture-ddd.md +69 -0
  15. package/standards/core/coding-conventions.md +66 -0
  16. package/standards/core/testing-strategy.md +46 -0
  17. package/standards/{mobile-flutter-standards.md → mobile/flutter/flutter-standards.md} +9 -1
  18. package/standards/{mobile-react-native-standards.md → mobile/react-native/react-native-standards.md} +9 -1
  19. package/standards/{technical-preferences-ux.md → web/_base/design-system-ux.md} +8 -1
  20. package/standards/web/_base/frontend-architecture.md +75 -0
  21. package/standards/{frontend-standards.md → web/_base/frontend-standards.md} +7 -0
  22. package/standards/web/_base/technology-stack.md +40 -0
  23. package/standards/web/microfrontends/module-federation-standard.md +216 -0
  24. package/standards/web/single-spa/single-spa-standard.md +196 -0
  25. package/standards/web/spa/spa-standard.md +53 -0
  26. package/standards/architecture-patterns.md +0 -444
  27. package/standards/technology-stack.md +0 -294
  28. package/standards/vite-config-standard.md +0 -531
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jeffrey Rios
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,204 +1,131 @@
1
1
  # Coding Standards & Architecture Guide
2
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.
3
+ [![npm version](https://img.shields.io/npm/v/@jeffrey2423/coding-standards.svg)](https://www.npmjs.com/package/@jeffrey2423/coding-standards)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@jeffrey2423/coding-standards.svg)](https://www.npmjs.com/package/@jeffrey2423/coding-standards)
5
+ [![CI](https://github.com/jeffrey2423/coding-standards/actions/workflows/ci.yml/badge.svg)](https://github.com/jeffrey2423/coding-standards/actions/workflows/ci.yml)
6
+ [![license: MIT](https://img.shields.io/npm/l/@jeffrey2423/coding-standards.svg)](LICENSE)
7
+ [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md)
8
+
9
+ Modern, **AI-ready** coding standards, architectural patterns and technical conventions for building enterprise-scale, greenfield applications. Enforces **Clean Architecture**, **Domain-Driven Design (DDD)** and modern **microservices / microfrontends** patterns across backend, web and mobile.
10
+
11
+ Designed to be consumed by **AI coding agents** (Claude Code, Cursor, Copilot) as much as by humans: every document carries `load_when` front-matter, and the installer generates an `INDEX.md` telling the agent exactly which standards are active.
4
12
 
5
13
  ## Quick Start
6
14
 
7
- Copy all coding standards into any project:
15
+ Pick exactly the standards your project needs — interactively:
8
16
 
9
17
  ```bash
10
18
  npx @jeffrey2423/coding-standards
11
19
  ```
12
20
 
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
21
  ```
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
22
+ ? What are you building? ◉ Backend / API (.NET) ◉ Frontend Web ◯ Mobile
23
+ ? Web architecture: ● Microfrontends (Module Federation)
24
+ ? Backend distributed arch: ◉ Multi-tenancy ◉ Event-driven ◉ Public API facade ...
25
+ Copied 14 files to coding-standards/
26
+ Generated coding-standards/INDEX.md
97
27
  ```
98
28
 
99
- ### Backend Project Structure (per Microservice)
29
+ Or non-interactively (great for CI and AI agents):
100
30
 
31
+ ```bash
32
+ npx @jeffrey2423/coding-standards --backend --web=microfrontends # selective
33
+ npx @jeffrey2423/coding-standards --mobile=flutter,react-native --yes # mobile only
34
+ npx @jeffrey2423/coding-standards --all # everything
35
+ npx @jeffrey2423/coding-standards --help
101
36
  ```
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
37
 
129
- ### Mobile Standards
38
+ Only the selected standards are copied into `coding-standards/`, plus an `INDEX.md` that lists them with load triggers and precedence rules.
130
39
 
131
- Both Flutter and React Native follow Clean Architecture + DDD + Feature-First organization with platform-specific tooling.
40
+ ### Updating
132
41
 
133
- ## Database Conventions
42
+ Re-run the installer any time — it's idempotent. It tracks the files it created in `coding-standards/.standards-manifest.json` and, on each run, removes its previously-installed files (and any leftovers from the flat **v1** layout) before writing the new selection, then prunes empty folders. Your own files in `coding-standards/` are never touched. So upgrading v1 → v2, or changing your selection, leaves no stale or contradictory standards behind.
134
43
 
135
- **PostgreSQL** is the mandatory database engine. Key conventions:
44
+ ## How it works
136
45
 
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` |
46
+ Standards are organized into **independent packs** selected at install time:
146
47
 
147
- EF Core handles automatic snake_case conversion via `SnakeCaseNamingConvention` — no manual `[Column]` or `[Table]` attributes needed.
48
+ | Pack | Selection | What you get |
49
+ |---|---|---|
50
+ | **core** | always | Clean Architecture + DDD, coding conventions, testing strategy, AI collaboration |
51
+ | **backend** | `--backend` | .NET standards, tech stack, DB conventions + opt-in architecture docs |
52
+ | **web** | `--web=<track>` | shared web standards + **one** track: `spa` · `single-spa` · `microfrontends` |
53
+ | **mobile** | `--mobile=<fw,...>` | `flutter` and/or `react-native` |
148
54
 
149
- ## Design System & UX
55
+ **Single-SPA and Module Federation microfrontends are separate, mutually-exclusive tracks** — pick by need, no forced default.
150
56
 
151
- ### Colors
57
+ ## Repository structure
152
58
 
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 |
59
+ ```
60
+ standards/
61
+ ├── core/ # always installed
62
+ │ ├── clean-architecture-ddd.md
63
+ │ ├── coding-conventions.md
64
+ │ ├── testing-strategy.md
65
+ │ └── ai-collaboration.md
66
+ ├── backend/
67
+ │ ├── backend-standards.md
68
+ │ ├── technology-stack.md
69
+ │ ├── database-conventions.md
70
+ │ └── architecture/ # opt-in distributed-architecture docs
71
+ │ ├── microservice-anatomy.md
72
+ │ ├── multitenancy.md
73
+ │ ├── event-driven.md
74
+ │ ├── public-api-facade.md
75
+ │ └── shared-vs-owned.md
76
+ ├── web/
77
+ │ ├── _base/ # frontend architecture, stack, design system
78
+ │ ├── spa/ # ── pick one web track ──
79
+ │ ├── single-spa/
80
+ │ └── microfrontends/
81
+ └── mobile/
82
+ ├── flutter/
83
+ └── react-native/
84
+ ```
173
85
 
174
- ### Icons & Loading
86
+ ## Technology stack (2026)
175
87
 
176
- - Primary icons: **Heroicons**
177
- - Secondary icons: Font Awesome 6.5+
178
- - Loading states: `react-loading-skeleton` v3.4.0
88
+ ### Backend
89
+ .NET 10 (LTS) · C# 14 Minimal API · EF Core 10 (+ linq2db / Dynamic.Core / LinqKit) · **PostgreSQL 18** (`uuidv7()`, RLS) · FluentValidation · built-in OpenAPI 3.1 + **Scalar** · **.NET Aspire 13** · **YARP** · **Wolverine** · xUnit + Testcontainers · OpenTelemetry · PdfSharp/MigraDoc.
179
90
 
180
- ## Key Principles
91
+ > **100% open source** — permissive licenses only (MIT / Apache-2.0 / BSD / PostgreSQL). The now-commercial **MediatR / MassTransit / AutoMapper** and the revenue-gated **QuestPDF** are **excluded** and replaced by **Wolverine**, **Mapperly** and **PdfSharp/MigraDoc**. See `backend/technology-stack.md`.
181
92
 
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
93
+ ### Web
94
+ Vite 7 · React 19 · TypeScript strict · TanStack Router + Query · Zustand 5 · shadcn/ui + Radix · TailwindCSS v4 · React Hook Form + Zod · Vitest + RTL + MSW. Microfrontends via **Module Federation 2.0** (`@module-federation/enhanced`, dynamic license-gated remotes) or **Single-SPA**.
191
95
 
192
- ## Document Index
96
+ ### Mobile
97
+ Flutter (Riverpod 3 · GoRouter · Material 3) · React Native (Expo SDK 53+ · Zustand · Expo Router · NativeWind 4).
98
+
99
+ ## Architecture highlights
100
+
101
+ - **Clean Architecture + DDD** everywhere; strict inward dependency rule.
102
+ - **Multi-tenancy**: hybrid bridge model — pooled + PostgreSQL RLS by default, selective silo, central tenant catalog.
103
+ - **Event-driven**: transactional Outbox, idempotent consumers, sagas with compensation, correlation IDs.
104
+ - **Public API facade**: contracts as product — OpenAPI 3.1 + AsyncAPI 3.0, Standard Webhooks (HMAC), OAuth 2.1, Problem Details (RFC 9457), rigorous versioning. Your own UI uses the public API — no private APIs.
105
+ - **Microfrontends**: products as router layouts, capabilities as remote MFEs, enabled per license without redeploy.
106
+
107
+ ## Key principles
108
+
109
+ 1. **Clean Architecture** — strict layer separation with dependency inversion.
110
+ 2. **Domain-Driven Design** — bounded contexts drive the architecture.
111
+ 3. **Test-Driven Development** — tests alongside implementation, ≥80% on domain/application.
112
+ 4. **Type safety** — TypeScript strict, C#, sound Dart null safety.
113
+ 5. **Database per microservice** — complete data isolation.
114
+ 6. **UUID (uuidv7) primary keys** — distributed-system friendly.
115
+ 7. **Spanish UI / English code** — user-facing text in Spanish, codebase in English.
116
+ 8. **Contracts are the product** — public, versioned, backward-compatible.
117
+ 9. **Accessibility first** — WCAG 2.1 AA.
118
+ 10. **AI-ready** — every standard is loadable on demand via `INDEX.md` and `load_when` front-matter.
119
+ 11. **Open source only** — every dependency uses a permissive OSS license; no commercial or revenue-gated libraries.
120
+
121
+ ## Using with AI agents
122
+
123
+ Add a root `AGENTS.md` pointing your agent at the installed index:
124
+
125
+ ```md
126
+ # Project agent instructions
127
+ Coding standards live in `coding-standards/`. Read `coding-standards/INDEX.md`
128
+ first, then load standards on demand per their `load_when` triggers.
129
+ ```
193
130
 
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 |
131
+ See `core/ai-collaboration.md` for the full agent protocol.