@corbat-tech/coding-standards-mcp 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/LICENSE +21 -0
- package/README.md +371 -0
- package/assets/demo.gif +0 -0
- package/dist/agent.d.ts +53 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +629 -0
- package/dist/agent.js.map +1 -0
- package/dist/cli/init.d.ts +3 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +651 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/config.d.ts +73 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +105 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/profiles.d.ts +39 -0
- package/dist/profiles.d.ts.map +1 -0
- package/dist/profiles.js +526 -0
- package/dist/profiles.js.map +1 -0
- package/dist/prompts-legacy.d.ts +25 -0
- package/dist/prompts-legacy.d.ts.map +1 -0
- package/dist/prompts-legacy.js +600 -0
- package/dist/prompts-legacy.js.map +1 -0
- package/dist/prompts-v2.d.ts +30 -0
- package/dist/prompts-v2.d.ts.map +1 -0
- package/dist/prompts-v2.js +310 -0
- package/dist/prompts-v2.js.map +1 -0
- package/dist/prompts.d.ts +30 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +310 -0
- package/dist/prompts.js.map +1 -0
- package/dist/resources.d.ts +18 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +95 -0
- package/dist/resources.js.map +1 -0
- package/dist/tools-legacy.d.ts +196 -0
- package/dist/tools-legacy.d.ts.map +1 -0
- package/dist/tools-legacy.js +1230 -0
- package/dist/tools-legacy.js.map +1 -0
- package/dist/tools-v2.d.ts +92 -0
- package/dist/tools-v2.d.ts.map +1 -0
- package/dist/tools-v2.js +410 -0
- package/dist/tools-v2.js.map +1 -0
- package/dist/tools.d.ts +92 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +410 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +3054 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +515 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/retry.d.ts +44 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +74 -0
- package/dist/utils/retry.js.map +1 -0
- package/package.json +79 -0
- package/profiles/README.md +199 -0
- package/profiles/custom/.gitkeep +2 -0
- package/profiles/templates/_template.yaml +159 -0
- package/profiles/templates/angular.yaml +494 -0
- package/profiles/templates/java-spring-backend.yaml +512 -0
- package/profiles/templates/minimal.yaml +102 -0
- package/profiles/templates/nodejs.yaml +338 -0
- package/profiles/templates/python.yaml +340 -0
- package/profiles/templates/react.yaml +331 -0
- package/profiles/templates/vue.yaml +598 -0
- package/standards/architecture/ddd.md +173 -0
- package/standards/architecture/hexagonal.md +97 -0
- package/standards/cicd/github-actions.md +567 -0
- package/standards/clean-code/naming.md +175 -0
- package/standards/clean-code/principles.md +179 -0
- package/standards/containerization/dockerfile.md +419 -0
- package/standards/database/selection-guide.md +443 -0
- package/standards/documentation/guidelines.md +189 -0
- package/standards/event-driven/domain-events.md +527 -0
- package/standards/kubernetes/deployment.md +518 -0
- package/standards/observability/guidelines.md +665 -0
- package/standards/project-setup/initialization-checklist.md +650 -0
- package/standards/spring-boot/best-practices.md +598 -0
- package/standards/testing/guidelines.md +559 -0
- package/standards/workflow/llm-development-workflow.md +542 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
# ============================================================================
|
|
2
|
+
# CORBAT MCP - Node.js/TypeScript Profile
|
|
3
|
+
# ============================================================================
|
|
4
|
+
# Production-ready standards for Node.js backend applications with TypeScript.
|
|
5
|
+
# Covers Express/Fastify, Prisma/TypeORM, and modern Node.js practices.
|
|
6
|
+
# ============================================================================
|
|
7
|
+
|
|
8
|
+
name: "Node.js TypeScript Standards"
|
|
9
|
+
description: "Production-ready standards for Node.js backend with TypeScript, focusing on type safety, clean architecture, and modern practices"
|
|
10
|
+
|
|
11
|
+
# ----------------------------------------------------------------------------
|
|
12
|
+
# ARCHITECTURE
|
|
13
|
+
# ----------------------------------------------------------------------------
|
|
14
|
+
architecture:
|
|
15
|
+
type: hexagonal
|
|
16
|
+
enforceLayerDependencies: true
|
|
17
|
+
layers:
|
|
18
|
+
- name: domain
|
|
19
|
+
description: "Core business logic. Pure TypeScript, no external dependencies. Contains entities, value objects, and domain services."
|
|
20
|
+
allowedDependencies: []
|
|
21
|
+
packages:
|
|
22
|
+
- "src/domain"
|
|
23
|
+
- "src/domain/entities"
|
|
24
|
+
- "src/domain/value-objects"
|
|
25
|
+
- "src/domain/services"
|
|
26
|
+
- "src/domain/errors"
|
|
27
|
+
|
|
28
|
+
- name: application
|
|
29
|
+
description: "Use cases and application services. Orchestrates domain objects. Contains commands, queries, and handlers."
|
|
30
|
+
allowedDependencies:
|
|
31
|
+
- domain
|
|
32
|
+
packages:
|
|
33
|
+
- "src/application"
|
|
34
|
+
- "src/application/use-cases"
|
|
35
|
+
- "src/application/services"
|
|
36
|
+
- "src/application/ports"
|
|
37
|
+
|
|
38
|
+
- name: infrastructure
|
|
39
|
+
description: "External adapters: HTTP controllers, database repositories, external APIs, messaging."
|
|
40
|
+
allowedDependencies:
|
|
41
|
+
- domain
|
|
42
|
+
- application
|
|
43
|
+
packages:
|
|
44
|
+
- "src/infrastructure"
|
|
45
|
+
- "src/infrastructure/http"
|
|
46
|
+
- "src/infrastructure/database"
|
|
47
|
+
- "src/infrastructure/messaging"
|
|
48
|
+
- "src/infrastructure/external"
|
|
49
|
+
|
|
50
|
+
# ----------------------------------------------------------------------------
|
|
51
|
+
# CODE QUALITY
|
|
52
|
+
# ----------------------------------------------------------------------------
|
|
53
|
+
codeQuality:
|
|
54
|
+
maxMethodLines: 25
|
|
55
|
+
maxClassLines: 250
|
|
56
|
+
maxFileLines: 350
|
|
57
|
+
maxMethodParameters: 4
|
|
58
|
+
maxCyclomaticComplexity: 10
|
|
59
|
+
requireDocumentation: true
|
|
60
|
+
requireTests: true
|
|
61
|
+
minimumTestCoverage: 80
|
|
62
|
+
|
|
63
|
+
principles:
|
|
64
|
+
- "SOLID principles"
|
|
65
|
+
- "Favor composition over inheritance"
|
|
66
|
+
- "Explicit over implicit"
|
|
67
|
+
- "Fail fast, fail loud"
|
|
68
|
+
- "Immutability by default"
|
|
69
|
+
|
|
70
|
+
# ----------------------------------------------------------------------------
|
|
71
|
+
# NAMING CONVENTIONS
|
|
72
|
+
# ----------------------------------------------------------------------------
|
|
73
|
+
naming:
|
|
74
|
+
general:
|
|
75
|
+
class: PascalCase
|
|
76
|
+
interface: PascalCase # No 'I' prefix
|
|
77
|
+
type: PascalCase
|
|
78
|
+
method: camelCase
|
|
79
|
+
variable: camelCase
|
|
80
|
+
constant: SCREAMING_SNAKE_CASE
|
|
81
|
+
file: kebab-case
|
|
82
|
+
folder: kebab-case
|
|
83
|
+
enum: PascalCase
|
|
84
|
+
enumValue: PascalCase
|
|
85
|
+
|
|
86
|
+
suffixes:
|
|
87
|
+
controller: "Controller"
|
|
88
|
+
service: "Service"
|
|
89
|
+
repository: "Repository"
|
|
90
|
+
useCase: "UseCase"
|
|
91
|
+
handler: "Handler"
|
|
92
|
+
middleware: "Middleware"
|
|
93
|
+
validator: "Validator"
|
|
94
|
+
mapper: "Mapper"
|
|
95
|
+
factory: "Factory"
|
|
96
|
+
dto: "Dto"
|
|
97
|
+
error: "Error"
|
|
98
|
+
|
|
99
|
+
testing:
|
|
100
|
+
unitTest: ".test.ts"
|
|
101
|
+
integrationTest: ".integration.test.ts"
|
|
102
|
+
e2eTest: ".e2e.test.ts"
|
|
103
|
+
testMethod: "should_ExpectedBehavior_when_Condition"
|
|
104
|
+
fixture: "fixtures"
|
|
105
|
+
mock: ".mock.ts"
|
|
106
|
+
|
|
107
|
+
# ----------------------------------------------------------------------------
|
|
108
|
+
# TYPESCRIPT CONFIGURATION
|
|
109
|
+
# ----------------------------------------------------------------------------
|
|
110
|
+
technologies:
|
|
111
|
+
- name: typescript
|
|
112
|
+
version: "5.x"
|
|
113
|
+
specificRules:
|
|
114
|
+
strict: true
|
|
115
|
+
noImplicitAny: true
|
|
116
|
+
strictNullChecks: true
|
|
117
|
+
noUnusedLocals: true
|
|
118
|
+
noUnusedParameters: true
|
|
119
|
+
exactOptionalPropertyTypes: true
|
|
120
|
+
noUncheckedIndexedAccess: true
|
|
121
|
+
preferConst: true
|
|
122
|
+
useUnknownInCatchVariables: true
|
|
123
|
+
|
|
124
|
+
- name: node
|
|
125
|
+
version: "20+"
|
|
126
|
+
specificRules:
|
|
127
|
+
useESModules: true
|
|
128
|
+
topLevelAwait: true
|
|
129
|
+
avoidCallbackHell: true
|
|
130
|
+
|
|
131
|
+
- name: runtime
|
|
132
|
+
tool: "Node.js"
|
|
133
|
+
specificRules:
|
|
134
|
+
useAsyncAwait: true
|
|
135
|
+
handlePromiseRejections: true
|
|
136
|
+
useStreamsForLargeData: true
|
|
137
|
+
|
|
138
|
+
# ----------------------------------------------------------------------------
|
|
139
|
+
# TESTING
|
|
140
|
+
# ----------------------------------------------------------------------------
|
|
141
|
+
testing:
|
|
142
|
+
framework: "Vitest"
|
|
143
|
+
assertionLibrary: "Vitest"
|
|
144
|
+
mockingLibrary: "Vitest"
|
|
145
|
+
|
|
146
|
+
types:
|
|
147
|
+
unit:
|
|
148
|
+
suffix: ".test.ts"
|
|
149
|
+
location: "src/**/*.test.ts"
|
|
150
|
+
coverage: 80
|
|
151
|
+
fastExecution: true
|
|
152
|
+
|
|
153
|
+
integration:
|
|
154
|
+
suffix: ".integration.test.ts"
|
|
155
|
+
location: "tests/integration"
|
|
156
|
+
useTestcontainers: true
|
|
157
|
+
|
|
158
|
+
e2e:
|
|
159
|
+
suffix: ".e2e.test.ts"
|
|
160
|
+
location: "tests/e2e"
|
|
161
|
+
|
|
162
|
+
patterns:
|
|
163
|
+
arrange_act_assert: true
|
|
164
|
+
given_when_then: true
|
|
165
|
+
testDataBuilders: true
|
|
166
|
+
|
|
167
|
+
testcontainers:
|
|
168
|
+
enabled: true
|
|
169
|
+
containers:
|
|
170
|
+
- "PostgreSQLContainer"
|
|
171
|
+
- "RedisContainer"
|
|
172
|
+
- "KafkaContainer"
|
|
173
|
+
- "LocalStackContainer"
|
|
174
|
+
|
|
175
|
+
# ----------------------------------------------------------------------------
|
|
176
|
+
# HTTP FRAMEWORK
|
|
177
|
+
# ----------------------------------------------------------------------------
|
|
178
|
+
httpClients:
|
|
179
|
+
simple:
|
|
180
|
+
tool: "fetch"
|
|
181
|
+
description: "Native fetch API for simple HTTP calls"
|
|
182
|
+
useWhen:
|
|
183
|
+
- "Simple GET/POST requests"
|
|
184
|
+
- "No complex error handling needed"
|
|
185
|
+
- "Browser compatibility required"
|
|
186
|
+
|
|
187
|
+
complex:
|
|
188
|
+
tool: "axios or ky"
|
|
189
|
+
description: "HTTP client library for complex scenarios"
|
|
190
|
+
useWhen:
|
|
191
|
+
- "Request/response interceptors needed"
|
|
192
|
+
- "Automatic retries"
|
|
193
|
+
- "Request cancellation"
|
|
194
|
+
- "Progress tracking"
|
|
195
|
+
|
|
196
|
+
# ----------------------------------------------------------------------------
|
|
197
|
+
# DATABASE
|
|
198
|
+
# ----------------------------------------------------------------------------
|
|
199
|
+
database:
|
|
200
|
+
migrations:
|
|
201
|
+
tool: "Prisma Migrate"
|
|
202
|
+
location: "prisma/migrations"
|
|
203
|
+
naming: "YYYYMMDDHHMMSS_description"
|
|
204
|
+
|
|
205
|
+
auditing:
|
|
206
|
+
enabled: true
|
|
207
|
+
fields:
|
|
208
|
+
- "createdAt"
|
|
209
|
+
- "updatedAt"
|
|
210
|
+
|
|
211
|
+
orm:
|
|
212
|
+
tool: "Prisma"
|
|
213
|
+
patterns:
|
|
214
|
+
- "Use transactions for multi-table operations"
|
|
215
|
+
- "Prefer findFirst over findUnique when appropriate"
|
|
216
|
+
- "Use select to limit returned fields"
|
|
217
|
+
- "Avoid N+1 queries with include"
|
|
218
|
+
|
|
219
|
+
# ----------------------------------------------------------------------------
|
|
220
|
+
# ERROR HANDLING
|
|
221
|
+
# ----------------------------------------------------------------------------
|
|
222
|
+
errorHandling:
|
|
223
|
+
format: "Custom Error Classes"
|
|
224
|
+
globalHandler: "ErrorMiddleware"
|
|
225
|
+
|
|
226
|
+
customExceptions:
|
|
227
|
+
domain:
|
|
228
|
+
- "DomainError (base)"
|
|
229
|
+
- "EntityNotFoundError"
|
|
230
|
+
- "ValidationError"
|
|
231
|
+
- "BusinessRuleViolationError"
|
|
232
|
+
application:
|
|
233
|
+
- "ApplicationError"
|
|
234
|
+
- "UnauthorizedError"
|
|
235
|
+
- "ForbiddenError"
|
|
236
|
+
infrastructure:
|
|
237
|
+
- "DatabaseError"
|
|
238
|
+
- "ExternalServiceError"
|
|
239
|
+
|
|
240
|
+
structure:
|
|
241
|
+
- "name: Error class name"
|
|
242
|
+
- "message: Human-readable message"
|
|
243
|
+
- "code: Machine-readable code"
|
|
244
|
+
- "statusCode: HTTP status code"
|
|
245
|
+
- "details: Additional context (optional)"
|
|
246
|
+
|
|
247
|
+
# ----------------------------------------------------------------------------
|
|
248
|
+
# OBSERVABILITY
|
|
249
|
+
# ----------------------------------------------------------------------------
|
|
250
|
+
observability:
|
|
251
|
+
enabled: true
|
|
252
|
+
|
|
253
|
+
logging:
|
|
254
|
+
framework: "Pino"
|
|
255
|
+
format: "JSON"
|
|
256
|
+
structuredLogging: true
|
|
257
|
+
correlationId: true
|
|
258
|
+
levels:
|
|
259
|
+
production: "info"
|
|
260
|
+
development: "debug"
|
|
261
|
+
avoid:
|
|
262
|
+
- "console.log in production code"
|
|
263
|
+
- "Logging sensitive data"
|
|
264
|
+
- "Synchronous logging"
|
|
265
|
+
|
|
266
|
+
metrics:
|
|
267
|
+
framework: "prom-client"
|
|
268
|
+
customMetrics:
|
|
269
|
+
- type: "counter"
|
|
270
|
+
examples: ["requests_total", "errors_total"]
|
|
271
|
+
- type: "histogram"
|
|
272
|
+
examples: ["request_duration_seconds", "db_query_duration_seconds"]
|
|
273
|
+
- type: "gauge"
|
|
274
|
+
examples: ["active_connections", "queue_size"]
|
|
275
|
+
|
|
276
|
+
tracing:
|
|
277
|
+
framework: "OpenTelemetry"
|
|
278
|
+
exporters:
|
|
279
|
+
- "Jaeger"
|
|
280
|
+
- "OTLP"
|
|
281
|
+
|
|
282
|
+
healthChecks:
|
|
283
|
+
endpoints:
|
|
284
|
+
- "/health"
|
|
285
|
+
- "/health/live"
|
|
286
|
+
- "/health/ready"
|
|
287
|
+
|
|
288
|
+
# ----------------------------------------------------------------------------
|
|
289
|
+
# SECURITY
|
|
290
|
+
# ----------------------------------------------------------------------------
|
|
291
|
+
security:
|
|
292
|
+
authentication:
|
|
293
|
+
method: "JWT"
|
|
294
|
+
storage: "HTTP-only cookies preferred"
|
|
295
|
+
|
|
296
|
+
practices:
|
|
297
|
+
- "Validate all input with Zod"
|
|
298
|
+
- "Use parameterized queries (Prisma handles this)"
|
|
299
|
+
- "Sanitize user-generated content"
|
|
300
|
+
- "Use helmet for HTTP headers"
|
|
301
|
+
- "Implement rate limiting"
|
|
302
|
+
- "Use CORS appropriately"
|
|
303
|
+
- "Never store secrets in code"
|
|
304
|
+
- "Use environment variables"
|
|
305
|
+
|
|
306
|
+
# ----------------------------------------------------------------------------
|
|
307
|
+
# PROJECT STRUCTURE
|
|
308
|
+
# ----------------------------------------------------------------------------
|
|
309
|
+
# Recommended folder structure:
|
|
310
|
+
#
|
|
311
|
+
# src/
|
|
312
|
+
# ├── domain/
|
|
313
|
+
# │ ├── entities/
|
|
314
|
+
# │ ├── value-objects/
|
|
315
|
+
# │ ├── services/
|
|
316
|
+
# │ └── errors/
|
|
317
|
+
# ├── application/
|
|
318
|
+
# │ ├── use-cases/
|
|
319
|
+
# │ ├── services/
|
|
320
|
+
# │ └── ports/
|
|
321
|
+
# ├── infrastructure/
|
|
322
|
+
# │ ├── http/
|
|
323
|
+
# │ │ ├── controllers/
|
|
324
|
+
# │ │ ├── middlewares/
|
|
325
|
+
# │ │ └── routes/
|
|
326
|
+
# │ ├── database/
|
|
327
|
+
# │ │ ├── repositories/
|
|
328
|
+
# │ │ └── mappers/
|
|
329
|
+
# │ └── config/
|
|
330
|
+
# ├── shared/
|
|
331
|
+
# │ ├── utils/
|
|
332
|
+
# │ └── types/
|
|
333
|
+
# └── index.ts
|
|
334
|
+
#
|
|
335
|
+
# tests/
|
|
336
|
+
# ├── integration/
|
|
337
|
+
# ├── e2e/
|
|
338
|
+
# └── fixtures/
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
# ============================================================================
|
|
2
|
+
# CORBAT MCP - Python Profile
|
|
3
|
+
# ============================================================================
|
|
4
|
+
# Production-ready standards for Python backend applications.
|
|
5
|
+
# Covers FastAPI/Django, SQLAlchemy, and modern Python practices.
|
|
6
|
+
# ============================================================================
|
|
7
|
+
|
|
8
|
+
name: "Python Backend Standards"
|
|
9
|
+
description: "Production-ready standards for Python backend with FastAPI or Django, focusing on type hints, clean architecture, and Pythonic code"
|
|
10
|
+
|
|
11
|
+
# ----------------------------------------------------------------------------
|
|
12
|
+
# ARCHITECTURE
|
|
13
|
+
# ----------------------------------------------------------------------------
|
|
14
|
+
architecture:
|
|
15
|
+
type: hexagonal
|
|
16
|
+
enforceLayerDependencies: true
|
|
17
|
+
layers:
|
|
18
|
+
- name: domain
|
|
19
|
+
description: "Core business logic. Pure Python, no framework dependencies. Contains entities, value objects, and domain services."
|
|
20
|
+
allowedDependencies: []
|
|
21
|
+
packages:
|
|
22
|
+
- "src/domain"
|
|
23
|
+
- "src/domain/entities"
|
|
24
|
+
- "src/domain/value_objects"
|
|
25
|
+
- "src/domain/services"
|
|
26
|
+
- "src/domain/exceptions"
|
|
27
|
+
|
|
28
|
+
- name: application
|
|
29
|
+
description: "Use cases and application services. Orchestrates domain objects."
|
|
30
|
+
allowedDependencies:
|
|
31
|
+
- domain
|
|
32
|
+
packages:
|
|
33
|
+
- "src/application"
|
|
34
|
+
- "src/application/use_cases"
|
|
35
|
+
- "src/application/services"
|
|
36
|
+
- "src/application/ports"
|
|
37
|
+
|
|
38
|
+
- name: infrastructure
|
|
39
|
+
description: "External adapters: API routes, database repositories, external services."
|
|
40
|
+
allowedDependencies:
|
|
41
|
+
- domain
|
|
42
|
+
- application
|
|
43
|
+
packages:
|
|
44
|
+
- "src/infrastructure"
|
|
45
|
+
- "src/infrastructure/api"
|
|
46
|
+
- "src/infrastructure/database"
|
|
47
|
+
- "src/infrastructure/external"
|
|
48
|
+
|
|
49
|
+
# ----------------------------------------------------------------------------
|
|
50
|
+
# CODE QUALITY
|
|
51
|
+
# ----------------------------------------------------------------------------
|
|
52
|
+
codeQuality:
|
|
53
|
+
maxMethodLines: 25
|
|
54
|
+
maxClassLines: 200
|
|
55
|
+
maxFileLines: 400
|
|
56
|
+
maxMethodParameters: 5
|
|
57
|
+
maxCyclomaticComplexity: 10
|
|
58
|
+
requireDocumentation: true
|
|
59
|
+
requireTests: true
|
|
60
|
+
minimumTestCoverage: 80
|
|
61
|
+
|
|
62
|
+
principles:
|
|
63
|
+
- "The Zen of Python"
|
|
64
|
+
- "Explicit is better than implicit"
|
|
65
|
+
- "Simple is better than complex"
|
|
66
|
+
- "Readability counts"
|
|
67
|
+
- "SOLID principles"
|
|
68
|
+
|
|
69
|
+
# ----------------------------------------------------------------------------
|
|
70
|
+
# NAMING CONVENTIONS
|
|
71
|
+
# ----------------------------------------------------------------------------
|
|
72
|
+
naming:
|
|
73
|
+
general:
|
|
74
|
+
class: PascalCase
|
|
75
|
+
function: snake_case
|
|
76
|
+
method: snake_case
|
|
77
|
+
variable: snake_case
|
|
78
|
+
constant: SCREAMING_SNAKE_CASE
|
|
79
|
+
module: snake_case
|
|
80
|
+
package: snake_case
|
|
81
|
+
privateAttribute: _leading_underscore
|
|
82
|
+
protectedAttribute: _single_underscore
|
|
83
|
+
privateMethod: __double_underscore
|
|
84
|
+
|
|
85
|
+
suffixes:
|
|
86
|
+
router: "_router"
|
|
87
|
+
service: "Service"
|
|
88
|
+
repository: "Repository"
|
|
89
|
+
useCase: "UseCase"
|
|
90
|
+
schema: "Schema"
|
|
91
|
+
model: "Model"
|
|
92
|
+
exception: "Error"
|
|
93
|
+
|
|
94
|
+
testing:
|
|
95
|
+
testFile: "test_*.py"
|
|
96
|
+
testClass: "Test*"
|
|
97
|
+
testMethod: "test_should_expected_when_condition"
|
|
98
|
+
fixture: "conftest.py"
|
|
99
|
+
|
|
100
|
+
# ----------------------------------------------------------------------------
|
|
101
|
+
# PYTHON CONFIGURATION
|
|
102
|
+
# ----------------------------------------------------------------------------
|
|
103
|
+
technologies:
|
|
104
|
+
- name: python
|
|
105
|
+
version: "3.11+"
|
|
106
|
+
specificRules:
|
|
107
|
+
useTypeHints: true
|
|
108
|
+
useDataclasses: true
|
|
109
|
+
usePydantic: true
|
|
110
|
+
useAsyncAwait: true
|
|
111
|
+
useContextManagers: true
|
|
112
|
+
useGenerators: true
|
|
113
|
+
useWalrus: false # := operator - use sparingly
|
|
114
|
+
preferFStrings: true
|
|
115
|
+
usePathlib: true
|
|
116
|
+
|
|
117
|
+
- name: fastapi
|
|
118
|
+
version: "0.100+"
|
|
119
|
+
specificRules:
|
|
120
|
+
useDependencyInjection: true
|
|
121
|
+
useAsyncEndpoints: true
|
|
122
|
+
usePydanticV2: true
|
|
123
|
+
useResponseModel: true
|
|
124
|
+
useStatusCodes: true
|
|
125
|
+
|
|
126
|
+
- name: linting
|
|
127
|
+
tools:
|
|
128
|
+
- "ruff"
|
|
129
|
+
- "mypy"
|
|
130
|
+
- "black"
|
|
131
|
+
specificRules:
|
|
132
|
+
lineLength: 88
|
|
133
|
+
sortImports: true
|
|
134
|
+
strictMypy: true
|
|
135
|
+
|
|
136
|
+
# ----------------------------------------------------------------------------
|
|
137
|
+
# TESTING
|
|
138
|
+
# ----------------------------------------------------------------------------
|
|
139
|
+
testing:
|
|
140
|
+
framework: "pytest"
|
|
141
|
+
assertionLibrary: "pytest"
|
|
142
|
+
mockingLibrary: "pytest-mock"
|
|
143
|
+
|
|
144
|
+
types:
|
|
145
|
+
unit:
|
|
146
|
+
pattern: "test_*.py"
|
|
147
|
+
location: "tests/unit"
|
|
148
|
+
coverage: 80
|
|
149
|
+
markers: ["unit"]
|
|
150
|
+
|
|
151
|
+
integration:
|
|
152
|
+
pattern: "test_*_integration.py"
|
|
153
|
+
location: "tests/integration"
|
|
154
|
+
markers: ["integration"]
|
|
155
|
+
useTestcontainers: true
|
|
156
|
+
|
|
157
|
+
e2e:
|
|
158
|
+
pattern: "test_*_e2e.py"
|
|
159
|
+
location: "tests/e2e"
|
|
160
|
+
markers: ["e2e"]
|
|
161
|
+
|
|
162
|
+
patterns:
|
|
163
|
+
arrange_act_assert: true
|
|
164
|
+
given_when_then: true
|
|
165
|
+
fixtures: true
|
|
166
|
+
|
|
167
|
+
plugins:
|
|
168
|
+
- "pytest-asyncio"
|
|
169
|
+
- "pytest-cov"
|
|
170
|
+
- "pytest-mock"
|
|
171
|
+
- "pytest-env"
|
|
172
|
+
- "httpx" # For async test client
|
|
173
|
+
|
|
174
|
+
testcontainers:
|
|
175
|
+
enabled: true
|
|
176
|
+
containers:
|
|
177
|
+
- "PostgreSQLContainer"
|
|
178
|
+
- "RedisContainer"
|
|
179
|
+
- "KafkaContainer"
|
|
180
|
+
|
|
181
|
+
# ----------------------------------------------------------------------------
|
|
182
|
+
# DATABASE
|
|
183
|
+
# ----------------------------------------------------------------------------
|
|
184
|
+
database:
|
|
185
|
+
migrations:
|
|
186
|
+
tool: "Alembic"
|
|
187
|
+
location: "alembic/versions"
|
|
188
|
+
naming: "YYYY_MM_DD_HHMM_description"
|
|
189
|
+
|
|
190
|
+
auditing:
|
|
191
|
+
enabled: true
|
|
192
|
+
fields:
|
|
193
|
+
- "created_at"
|
|
194
|
+
- "updated_at"
|
|
195
|
+
|
|
196
|
+
orm:
|
|
197
|
+
tool: "SQLAlchemy 2.0"
|
|
198
|
+
patterns:
|
|
199
|
+
- "Use async sessions"
|
|
200
|
+
- "Use repository pattern"
|
|
201
|
+
- "Prefer select() over query()"
|
|
202
|
+
- "Use relationship lazy loading appropriately"
|
|
203
|
+
|
|
204
|
+
# ----------------------------------------------------------------------------
|
|
205
|
+
# ERROR HANDLING
|
|
206
|
+
# ----------------------------------------------------------------------------
|
|
207
|
+
errorHandling:
|
|
208
|
+
format: "RFC 7807 Problem Details"
|
|
209
|
+
globalHandler: "exception_handlers.py"
|
|
210
|
+
|
|
211
|
+
customExceptions:
|
|
212
|
+
domain:
|
|
213
|
+
- "DomainError (base)"
|
|
214
|
+
- "EntityNotFoundError"
|
|
215
|
+
- "ValidationError"
|
|
216
|
+
- "BusinessRuleViolationError"
|
|
217
|
+
application:
|
|
218
|
+
- "ApplicationError"
|
|
219
|
+
- "UnauthorizedError"
|
|
220
|
+
- "ForbiddenError"
|
|
221
|
+
infrastructure:
|
|
222
|
+
- "DatabaseError"
|
|
223
|
+
- "ExternalServiceError"
|
|
224
|
+
|
|
225
|
+
structure:
|
|
226
|
+
- "type: Error type URI"
|
|
227
|
+
- "title: Short description"
|
|
228
|
+
- "status: HTTP status code"
|
|
229
|
+
- "detail: Detailed message"
|
|
230
|
+
- "instance: Request path"
|
|
231
|
+
|
|
232
|
+
# ----------------------------------------------------------------------------
|
|
233
|
+
# OBSERVABILITY
|
|
234
|
+
# ----------------------------------------------------------------------------
|
|
235
|
+
observability:
|
|
236
|
+
enabled: true
|
|
237
|
+
|
|
238
|
+
logging:
|
|
239
|
+
framework: "structlog"
|
|
240
|
+
format: "JSON"
|
|
241
|
+
structuredLogging: true
|
|
242
|
+
correlationId: true
|
|
243
|
+
levels:
|
|
244
|
+
production: "INFO"
|
|
245
|
+
development: "DEBUG"
|
|
246
|
+
avoid:
|
|
247
|
+
- "print() statements"
|
|
248
|
+
- "Logging sensitive data"
|
|
249
|
+
- "f-strings in log messages (use structlog binding)"
|
|
250
|
+
|
|
251
|
+
metrics:
|
|
252
|
+
framework: "prometheus-client"
|
|
253
|
+
customMetrics:
|
|
254
|
+
- type: "counter"
|
|
255
|
+
examples: ["requests_total", "errors_total"]
|
|
256
|
+
- type: "histogram"
|
|
257
|
+
examples: ["request_duration_seconds"]
|
|
258
|
+
- type: "gauge"
|
|
259
|
+
examples: ["active_connections"]
|
|
260
|
+
|
|
261
|
+
tracing:
|
|
262
|
+
framework: "OpenTelemetry"
|
|
263
|
+
exporters:
|
|
264
|
+
- "Jaeger"
|
|
265
|
+
- "OTLP"
|
|
266
|
+
|
|
267
|
+
healthChecks:
|
|
268
|
+
endpoints:
|
|
269
|
+
- "/health"
|
|
270
|
+
- "/health/live"
|
|
271
|
+
- "/health/ready"
|
|
272
|
+
|
|
273
|
+
# ----------------------------------------------------------------------------
|
|
274
|
+
# SECURITY
|
|
275
|
+
# ----------------------------------------------------------------------------
|
|
276
|
+
security:
|
|
277
|
+
authentication:
|
|
278
|
+
method: "JWT or OAuth2"
|
|
279
|
+
library: "python-jose or authlib"
|
|
280
|
+
|
|
281
|
+
practices:
|
|
282
|
+
- "Validate input with Pydantic"
|
|
283
|
+
- "Use parameterized queries"
|
|
284
|
+
- "Sanitize user content"
|
|
285
|
+
- "Use secrets module for tokens"
|
|
286
|
+
- "Implement rate limiting"
|
|
287
|
+
- "Use CORS middleware"
|
|
288
|
+
- "Never commit secrets"
|
|
289
|
+
- "Use environment variables"
|
|
290
|
+
- "Hash passwords with bcrypt"
|
|
291
|
+
|
|
292
|
+
# ----------------------------------------------------------------------------
|
|
293
|
+
# DEPENDENCY MANAGEMENT
|
|
294
|
+
# ----------------------------------------------------------------------------
|
|
295
|
+
dependencies:
|
|
296
|
+
tool: "Poetry or uv"
|
|
297
|
+
lockFile: true
|
|
298
|
+
separateDevDependencies: true
|
|
299
|
+
pinVersions: true
|
|
300
|
+
|
|
301
|
+
# ----------------------------------------------------------------------------
|
|
302
|
+
# PROJECT STRUCTURE
|
|
303
|
+
# ----------------------------------------------------------------------------
|
|
304
|
+
# Recommended folder structure:
|
|
305
|
+
#
|
|
306
|
+
# src/
|
|
307
|
+
# ├── domain/
|
|
308
|
+
# │ ├── entities/
|
|
309
|
+
# │ ├── value_objects/
|
|
310
|
+
# │ ├── services/
|
|
311
|
+
# │ └── exceptions/
|
|
312
|
+
# ├── application/
|
|
313
|
+
# │ ├── use_cases/
|
|
314
|
+
# │ ├── services/
|
|
315
|
+
# │ └── ports/
|
|
316
|
+
# ├── infrastructure/
|
|
317
|
+
# │ ├── api/
|
|
318
|
+
# │ │ ├── routes/
|
|
319
|
+
# │ │ ├── dependencies/
|
|
320
|
+
# │ │ └── middleware/
|
|
321
|
+
# │ ├── database/
|
|
322
|
+
# │ │ ├── repositories/
|
|
323
|
+
# │ │ ├── models/
|
|
324
|
+
# │ │ └── mappers/
|
|
325
|
+
# │ └── config/
|
|
326
|
+
# ├── shared/
|
|
327
|
+
# │ ├── utils/
|
|
328
|
+
# │ └── types/
|
|
329
|
+
# └── main.py
|
|
330
|
+
#
|
|
331
|
+
# tests/
|
|
332
|
+
# ├── unit/
|
|
333
|
+
# ├── integration/
|
|
334
|
+
# ├── e2e/
|
|
335
|
+
# ├── fixtures/
|
|
336
|
+
# └── conftest.py
|
|
337
|
+
#
|
|
338
|
+
# pyproject.toml
|
|
339
|
+
# alembic.ini
|
|
340
|
+
# Dockerfile
|