@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
package/README.md
CHANGED
|
@@ -1,204 +1,125 @@
|
|
|
1
1
|
# Coding Standards & Architecture Guide
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
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.
|
|
4
|
+
|
|
5
|
+
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
6
|
|
|
5
7
|
## Quick Start
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
Pick exactly the standards your project needs — interactively:
|
|
8
10
|
|
|
9
11
|
```bash
|
|
10
12
|
npx @jeffrey2423/coding-standards
|
|
11
13
|
```
|
|
12
14
|
|
|
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
15
|
```
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
↑
|
|
80
|
-
Presentation Layer → UI Components, Routes, Pages, Endpoints
|
|
16
|
+
? What are you building? ◉ Backend / API (.NET) ◉ Frontend Web ◯ Mobile
|
|
17
|
+
? Web architecture: ● Microfrontends (Module Federation)
|
|
18
|
+
? Backend — distributed arch: ◉ Multi-tenancy ◉ Event-driven ◉ Public API facade ...
|
|
19
|
+
✓ Copied 14 files to coding-standards/
|
|
20
|
+
✓ Generated coding-standards/INDEX.md
|
|
81
21
|
```
|
|
82
22
|
|
|
83
|
-
|
|
23
|
+
Or non-interactively (great for CI and AI agents):
|
|
84
24
|
|
|
25
|
+
```bash
|
|
26
|
+
npx @jeffrey2423/coding-standards --backend --web=microfrontends # selective
|
|
27
|
+
npx @jeffrey2423/coding-standards --mobile=flutter,react-native --yes # mobile only
|
|
28
|
+
npx @jeffrey2423/coding-standards --all # everything
|
|
29
|
+
npx @jeffrey2423/coding-standards --help
|
|
85
30
|
```
|
|
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
31
|
|
|
129
|
-
|
|
32
|
+
Only the selected standards are copied into `coding-standards/`, plus an `INDEX.md` that lists them with load triggers and precedence rules.
|
|
130
33
|
|
|
131
|
-
|
|
34
|
+
### Updating
|
|
132
35
|
|
|
133
|
-
|
|
36
|
+
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
37
|
|
|
135
|
-
|
|
38
|
+
## How it works
|
|
136
39
|
|
|
137
|
-
|
|
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` |
|
|
40
|
+
Standards are organized into **independent packs** selected at install time:
|
|
146
41
|
|
|
147
|
-
|
|
42
|
+
| Pack | Selection | What you get |
|
|
43
|
+
|---|---|---|
|
|
44
|
+
| **core** | always | Clean Architecture + DDD, coding conventions, testing strategy, AI collaboration |
|
|
45
|
+
| **backend** | `--backend` | .NET standards, tech stack, DB conventions + opt-in architecture docs |
|
|
46
|
+
| **web** | `--web=<track>` | shared web standards + **one** track: `spa` · `single-spa` · `microfrontends` |
|
|
47
|
+
| **mobile** | `--mobile=<fw,...>` | `flutter` and/or `react-native` |
|
|
148
48
|
|
|
149
|
-
|
|
49
|
+
**Single-SPA and Module Federation microfrontends are separate, mutually-exclusive tracks** — pick by need, no forced default.
|
|
150
50
|
|
|
151
|
-
|
|
51
|
+
## Repository structure
|
|
152
52
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
-
|
|
163
|
-
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
53
|
+
```
|
|
54
|
+
standards/
|
|
55
|
+
├── core/ # always installed
|
|
56
|
+
│ ├── clean-architecture-ddd.md
|
|
57
|
+
│ ├── coding-conventions.md
|
|
58
|
+
│ ├── testing-strategy.md
|
|
59
|
+
│ └── ai-collaboration.md
|
|
60
|
+
├── backend/
|
|
61
|
+
│ ├── backend-standards.md
|
|
62
|
+
│ ├── technology-stack.md
|
|
63
|
+
│ ├── database-conventions.md
|
|
64
|
+
│ └── architecture/ # opt-in distributed-architecture docs
|
|
65
|
+
│ ├── microservice-anatomy.md
|
|
66
|
+
│ ├── multitenancy.md
|
|
67
|
+
│ ├── event-driven.md
|
|
68
|
+
│ ├── public-api-facade.md
|
|
69
|
+
│ └── shared-vs-owned.md
|
|
70
|
+
├── web/
|
|
71
|
+
│ ├── _base/ # frontend architecture, stack, design system
|
|
72
|
+
│ ├── spa/ # ── pick one web track ──
|
|
73
|
+
│ ├── single-spa/
|
|
74
|
+
│ └── microfrontends/
|
|
75
|
+
└── mobile/
|
|
76
|
+
├── flutter/
|
|
77
|
+
└── react-native/
|
|
78
|
+
```
|
|
173
79
|
|
|
174
|
-
|
|
80
|
+
## Technology stack (2026)
|
|
175
81
|
|
|
176
|
-
|
|
177
|
-
-
|
|
178
|
-
- Loading states: `react-loading-skeleton` v3.4.0
|
|
82
|
+
### Backend
|
|
83
|
+
.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
84
|
|
|
180
|
-
|
|
85
|
+
> **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
86
|
|
|
182
|
-
|
|
183
|
-
|
|
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
|
|
87
|
+
### Web
|
|
88
|
+
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
89
|
|
|
192
|
-
|
|
90
|
+
### Mobile
|
|
91
|
+
Flutter (Riverpod 3 · GoRouter · Material 3) · React Native (Expo SDK 53+ · Zustand · Expo Router · NativeWind 4).
|
|
92
|
+
|
|
93
|
+
## Architecture highlights
|
|
94
|
+
|
|
95
|
+
- **Clean Architecture + DDD** everywhere; strict inward dependency rule.
|
|
96
|
+
- **Multi-tenancy**: hybrid bridge model — pooled + PostgreSQL RLS by default, selective silo, central tenant catalog.
|
|
97
|
+
- **Event-driven**: transactional Outbox, idempotent consumers, sagas with compensation, correlation IDs.
|
|
98
|
+
- **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.
|
|
99
|
+
- **Microfrontends**: products as router layouts, capabilities as remote MFEs, enabled per license without redeploy.
|
|
100
|
+
|
|
101
|
+
## Key principles
|
|
102
|
+
|
|
103
|
+
1. **Clean Architecture** — strict layer separation with dependency inversion.
|
|
104
|
+
2. **Domain-Driven Design** — bounded contexts drive the architecture.
|
|
105
|
+
3. **Test-Driven Development** — tests alongside implementation, ≥80% on domain/application.
|
|
106
|
+
4. **Type safety** — TypeScript strict, C#, sound Dart null safety.
|
|
107
|
+
5. **Database per microservice** — complete data isolation.
|
|
108
|
+
6. **UUID (uuidv7) primary keys** — distributed-system friendly.
|
|
109
|
+
7. **Spanish UI / English code** — user-facing text in Spanish, codebase in English.
|
|
110
|
+
8. **Contracts are the product** — public, versioned, backward-compatible.
|
|
111
|
+
9. **Accessibility first** — WCAG 2.1 AA.
|
|
112
|
+
10. **AI-ready** — every standard is loadable on demand via `INDEX.md` and `load_when` front-matter.
|
|
113
|
+
11. **Open source only** — every dependency uses a permissive OSS license; no commercial or revenue-gated libraries.
|
|
114
|
+
|
|
115
|
+
## Using with AI agents
|
|
116
|
+
|
|
117
|
+
Add a root `AGENTS.md` pointing your agent at the installed index:
|
|
118
|
+
|
|
119
|
+
```md
|
|
120
|
+
# Project agent instructions
|
|
121
|
+
Coding standards live in `coding-standards/`. Read `coding-standards/INDEX.md`
|
|
122
|
+
first, then load standards on demand per their `load_when` triggers.
|
|
123
|
+
```
|
|
193
124
|
|
|
194
|
-
|
|
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 |
|
|
125
|
+
See `core/ai-collaboration.md` for the full agent protocol.
|