@qazuor/claude-code-config 0.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.
- package/LICENSE +21 -0
- package/README.md +1248 -0
- package/dist/bin.cjs +11886 -0
- package/dist/bin.cjs.map +1 -0
- package/dist/bin.d.cts +1 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +11869 -0
- package/dist/bin.js.map +1 -0
- package/dist/index.cjs +3887 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1325 -0
- package/dist/index.d.ts +1325 -0
- package/dist/index.js +3835 -0
- package/dist/index.js.map +1 -0
- package/package.json +86 -0
- package/templates/.log/notifications.log +1775 -0
- package/templates/agents/README.md +164 -0
- package/templates/agents/_registry.json +443 -0
- package/templates/agents/design/content-writer.md +353 -0
- package/templates/agents/design/ux-ui-designer.md +382 -0
- package/templates/agents/engineering/astro-engineer.md +293 -0
- package/templates/agents/engineering/db-drizzle-engineer.md +360 -0
- package/templates/agents/engineering/express-engineer.md +316 -0
- package/templates/agents/engineering/fastify-engineer.md +399 -0
- package/templates/agents/engineering/hono-engineer.md +263 -0
- package/templates/agents/engineering/mongoose-engineer.md +473 -0
- package/templates/agents/engineering/nestjs-engineer.md +429 -0
- package/templates/agents/engineering/nextjs-engineer.md +451 -0
- package/templates/agents/engineering/node-typescript-engineer.md +347 -0
- package/templates/agents/engineering/prisma-engineer.md +432 -0
- package/templates/agents/engineering/react-senior-dev.md +394 -0
- package/templates/agents/engineering/tanstack-start-engineer.md +447 -0
- package/templates/agents/engineering/tech-lead.md +269 -0
- package/templates/agents/product/product-functional.md +329 -0
- package/templates/agents/product/product-technical.md +578 -0
- package/templates/agents/quality/debugger.md +514 -0
- package/templates/agents/quality/qa-engineer.md +390 -0
- package/templates/agents/specialized/enrichment-agent.md +277 -0
- package/templates/agents/specialized/i18n-specialist.md +322 -0
- package/templates/agents/specialized/seo-ai-specialist.md +387 -0
- package/templates/agents/specialized/tech-writer.md +300 -0
- package/templates/code-style/.editorconfig +27 -0
- package/templates/code-style/.prettierignore +25 -0
- package/templates/code-style/.prettierrc +12 -0
- package/templates/code-style/biome.json +78 -0
- package/templates/code-style/commitlint.config.js +44 -0
- package/templates/commands/README.md +175 -0
- package/templates/commands/_registry.json +420 -0
- package/templates/commands/add-new-entity.md +211 -0
- package/templates/commands/audit/accessibility-audit.md +360 -0
- package/templates/commands/audit/performance-audit.md +290 -0
- package/templates/commands/audit/security-audit.md +231 -0
- package/templates/commands/code-check.md +127 -0
- package/templates/commands/five-why.md +225 -0
- package/templates/commands/formatting/format-markdown.md +197 -0
- package/templates/commands/git/commit.md +247 -0
- package/templates/commands/meta/create-agent.md +257 -0
- package/templates/commands/meta/create-command.md +312 -0
- package/templates/commands/meta/create-skill.md +321 -0
- package/templates/commands/meta/help.md +318 -0
- package/templates/commands/planning/check-completed-tasks.md +224 -0
- package/templates/commands/planning/cleanup-issues.md +248 -0
- package/templates/commands/planning/planning-cleanup.md +251 -0
- package/templates/commands/planning/sync-planning-github.md +133 -0
- package/templates/commands/planning/sync-todos-github.md +203 -0
- package/templates/commands/quality-check.md +211 -0
- package/templates/commands/run-tests.md +159 -0
- package/templates/commands/start-feature-plan.md +232 -0
- package/templates/commands/start-refactor-plan.md +244 -0
- package/templates/commands/sync-planning.md +176 -0
- package/templates/commands/update-docs.md +242 -0
- package/templates/docs/CHECKPOINT-SYSTEM.md +504 -0
- package/templates/docs/INDEX.md +677 -0
- package/templates/docs/RECOMMENDED-HOOKS.md +415 -0
- package/templates/docs/_registry.json +329 -0
- package/templates/docs/diagrams/README.md +220 -0
- package/templates/docs/diagrams/agent-hierarchy.mmd +55 -0
- package/templates/docs/diagrams/documentation-map.mmd +61 -0
- package/templates/docs/diagrams/tools-relationship.mmd +55 -0
- package/templates/docs/diagrams/workflow-decision-tree.mmd +38 -0
- package/templates/docs/doc-sync.md +533 -0
- package/templates/docs/examples/end-to-end-workflow.md +1505 -0
- package/templates/docs/glossary.md +495 -0
- package/templates/docs/guides/mockup-prompt-engineering.md +644 -0
- package/templates/docs/guides/mockup-setup.md +737 -0
- package/templates/docs/learnings/README.md +250 -0
- package/templates/docs/learnings/common-architectural-patterns.md +123 -0
- package/templates/docs/learnings/common-mistakes-to-avoid.md +149 -0
- package/templates/docs/learnings/markdown-formatting-standards.md +104 -0
- package/templates/docs/learnings/monorepo-command-execution.md +64 -0
- package/templates/docs/learnings/optimization-tips.md +146 -0
- package/templates/docs/learnings/planning-linear-sync-workflow.md +70 -0
- package/templates/docs/learnings/shell-compatibility-fish.md +46 -0
- package/templates/docs/learnings/test-organization-structure.md +68 -0
- package/templates/docs/mcp-installation.md +613 -0
- package/templates/docs/mcp-servers.md +989 -0
- package/templates/docs/notification-installation.md +570 -0
- package/templates/docs/quick-start.md +354 -0
- package/templates/docs/standards/architecture-patterns.md +1064 -0
- package/templates/docs/standards/atomic-commits.md +513 -0
- package/templates/docs/standards/code-standards.md +993 -0
- package/templates/docs/standards/design-standards.md +656 -0
- package/templates/docs/standards/documentation-standards.md +1160 -0
- package/templates/docs/standards/testing-standards.md +969 -0
- package/templates/docs/system-maintenance.md +604 -0
- package/templates/docs/templates/PDR-template.md +561 -0
- package/templates/docs/templates/TODOs-template.md +534 -0
- package/templates/docs/templates/tech-analysis-template.md +800 -0
- package/templates/docs/workflows/README.md +519 -0
- package/templates/docs/workflows/atomic-task-protocol.md +955 -0
- package/templates/docs/workflows/decision-tree.md +482 -0
- package/templates/docs/workflows/edge-cases.md +856 -0
- package/templates/docs/workflows/phase-1-planning.md +957 -0
- package/templates/docs/workflows/phase-2-implementation.md +896 -0
- package/templates/docs/workflows/phase-3-validation.md +792 -0
- package/templates/docs/workflows/phase-4-finalization.md +927 -0
- package/templates/docs/workflows/quick-fix-protocol.md +505 -0
- package/templates/docs/workflows/task-atomization.md +537 -0
- package/templates/docs/workflows/task-completion-protocol.md +448 -0
- package/templates/hooks/on-notification.sh +28 -0
- package/templates/schemas/checkpoint.schema.json +97 -0
- package/templates/schemas/code-registry.schema.json +84 -0
- package/templates/schemas/pdr.schema.json +314 -0
- package/templates/schemas/problems.schema.json +55 -0
- package/templates/schemas/tech-analysis.schema.json +404 -0
- package/templates/schemas/telemetry.schema.json +298 -0
- package/templates/schemas/todos.schema.json +234 -0
- package/templates/schemas/workflows.schema.json +69 -0
- package/templates/scripts/add-changelogs.sh +105 -0
- package/templates/scripts/generate-code-registry.ts +270 -0
- package/templates/scripts/health-check.sh +343 -0
- package/templates/scripts/sync-registry.sh +40 -0
- package/templates/scripts/telemetry-report.ts +36 -0
- package/templates/scripts/validate-docs.sh +224 -0
- package/templates/scripts/validate-registry.sh +225 -0
- package/templates/scripts/validate-schemas.ts +283 -0
- package/templates/scripts/validate-structure.sh +165 -0
- package/templates/scripts/worktree-cleanup.sh +81 -0
- package/templates/scripts/worktree-create.sh +63 -0
- package/templates/sessions/planning/.gitkeep +0 -0
- package/templates/sessions/planning/archived/.gitkeep +0 -0
- package/templates/settings.json +202 -0
- package/templates/settings.local.json +138 -0
- package/templates/skills/README.md +197 -0
- package/templates/skills/_registry.json +473 -0
- package/templates/skills/audit/accessibility-audit.md +309 -0
- package/templates/skills/audit/performance-audit.md +257 -0
- package/templates/skills/audit/security-audit.md +217 -0
- package/templates/skills/auth/nextauth-patterns.md +308 -0
- package/templates/skills/brand-guidelines.md +240 -0
- package/templates/skills/documentation/markdown-formatter.md +302 -0
- package/templates/skills/git/git-commit-helper.md +321 -0
- package/templates/skills/i18n/i18n-patterns.md +251 -0
- package/templates/skills/patterns/error-handling-patterns.md +242 -0
- package/templates/skills/patterns/tdd-methodology.md +342 -0
- package/templates/skills/qa/qa-criteria-validator.md +383 -0
- package/templates/skills/qa/web-app-testing.md +398 -0
- package/templates/skills/react/react-hook-form-patterns.md +359 -0
- package/templates/skills/state/redux-toolkit-patterns.md +272 -0
- package/templates/skills/state/tanstack-query-patterns.md +299 -0
- package/templates/skills/state/zustand-patterns.md +301 -0
- package/templates/skills/tech/mermaid-diagram-specialist.md +195 -0
- package/templates/skills/tech/shadcn-specialist.md +252 -0
- package/templates/skills/tech/vercel-specialist.md +297 -0
- package/templates/skills/testing/api-app-testing.md +254 -0
- package/templates/skills/testing/performance-testing.md +275 -0
- package/templates/skills/testing/security-testing.md +348 -0
- package/templates/skills/utils/add-memory.md +295 -0
- package/templates/skills/utils/json-data-auditor.md +283 -0
- package/templates/skills/utils/pdf-creator-editor.md +342 -0
- package/templates/tools/format-markdown.sh +185 -0
|
@@ -0,0 +1,1160 @@
|
|
|
1
|
+
# Documentation Standards
|
|
2
|
+
|
|
3
|
+
This document defines the documentation standards.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
|
|
9
|
+
<!-- markdownlint-disable MD051 -->
|
|
10
|
+
|
|
11
|
+
1. [Documentation Philosophy](#documentation-philosophy)
|
|
12
|
+
2. [JSDoc Standards](#jsdoc-standards)
|
|
13
|
+
3. [API Documentation](#api-documentation)
|
|
14
|
+
4. [Component Documentation](#component-documentation)
|
|
15
|
+
5. [Architecture Documentation](#architecture-documentation)
|
|
16
|
+
6. [README Files](#readme-files)
|
|
17
|
+
7. [Code Comments](#code-comments)
|
|
18
|
+
8. [Diagrams](#diagrams)
|
|
19
|
+
9. [Changelog](#changelog)
|
|
20
|
+
10. [Documentation Structure](#documentation-structure)
|
|
21
|
+
|
|
22
|
+
<!-- markdownlint-enable MD051 -->
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Documentation Philosophy
|
|
27
|
+
|
|
28
|
+
### Core Principles
|
|
29
|
+
|
|
30
|
+
**Code is Documentation:**
|
|
31
|
+
|
|
32
|
+
- Self-explanatory code > extensive comments
|
|
33
|
+
- Good naming > explaining what code does
|
|
34
|
+
- Tests document expected behavior
|
|
35
|
+
|
|
36
|
+
**Documentation is Code:**
|
|
37
|
+
|
|
38
|
+
- Keep docs close to code
|
|
39
|
+
- Update docs with code changes
|
|
40
|
+
- Review docs in code reviews
|
|
41
|
+
|
|
42
|
+
**Audience-First:**
|
|
43
|
+
|
|
44
|
+
- Write for future developers
|
|
45
|
+
- Write for external users
|
|
46
|
+
- Write for your future self
|
|
47
|
+
|
|
48
|
+
**Language:**
|
|
49
|
+
|
|
50
|
+
- ALL documentation in English
|
|
51
|
+
- Technical precision
|
|
52
|
+
- Clear and concise
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## JSDoc Standards
|
|
57
|
+
|
|
58
|
+
### Required for All Exports
|
|
59
|
+
|
|
60
|
+
**Every exported function, class, and type MUST have JSDoc.**
|
|
61
|
+
|
|
62
|
+
### Complete Function Documentation
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
/**
|
|
66
|
+
|
|
67
|
+
* Creates a new user account with validation and authorization checks
|
|
68
|
+
|
|
69
|
+
*
|
|
70
|
+
|
|
71
|
+
* This function performs several operations:
|
|
72
|
+
* 1. Validates the input data against business rules
|
|
73
|
+
* 2. Checks if the email is already in use
|
|
74
|
+
* 3. Hashes the password using bcrypt
|
|
75
|
+
* 4. Creates the user record in the database
|
|
76
|
+
* 5. Sends a welcome email to the new user
|
|
77
|
+
|
|
78
|
+
*
|
|
79
|
+
|
|
80
|
+
* @param {Object} params - Input parameters object
|
|
81
|
+
* @param {CreateUserInput} params.input - User data to create
|
|
82
|
+
* @param {string} params.input.name - User's full name (1-200 characters)
|
|
83
|
+
* @param {string} params.input.email - User's email (must be unique, valid format)
|
|
84
|
+
* @param {string} params.input.password - User's password (min 8 characters)
|
|
85
|
+
* @param {UserRole} params.input.role - User's role (admin, host, or guest)
|
|
86
|
+
* @param {User} params.currentUser - The authenticated user performing this action
|
|
87
|
+
|
|
88
|
+
*
|
|
89
|
+
|
|
90
|
+
* @returns {Promise<CreateUserOutput>} Object containing the created user and auth token
|
|
91
|
+
* @returns {User} result.user - The newly created user object
|
|
92
|
+
* @returns {string} result.token - JWT authentication token for the new user
|
|
93
|
+
|
|
94
|
+
*
|
|
95
|
+
|
|
96
|
+
* @throws {ServiceError} VALIDATION_ERROR - When input validation fails
|
|
97
|
+
* @throws {ServiceError} CONFLICT - When email already exists in database
|
|
98
|
+
* @throws {ServiceError} FORBIDDEN - When current user lacks create permissions
|
|
99
|
+
* @throws {ServiceError} INTERNAL_ERROR - When database operation fails
|
|
100
|
+
|
|
101
|
+
*
|
|
102
|
+
|
|
103
|
+
* @example Basic usage
|
|
104
|
+
* ```typescript
|
|
105
|
+
* import { UserService } from '@repo/service-core';
|
|
106
|
+
* import type { CreateUserInput } from '@repo/schemas';
|
|
107
|
+
|
|
108
|
+
*
|
|
109
|
+
|
|
110
|
+
* const service = new UserService(ctx);
|
|
111
|
+
* const result = await service.createUser({
|
|
112
|
+
* input: {
|
|
113
|
+
* name: 'John Doe',
|
|
114
|
+
* email: 'john@example.com',
|
|
115
|
+
* password: 'SecureP@ssw0rd',
|
|
116
|
+
* role: 'host'
|
|
117
|
+
* },
|
|
118
|
+
* currentUser: adminUser
|
|
119
|
+
* });
|
|
120
|
+
|
|
121
|
+
*
|
|
122
|
+
|
|
123
|
+
* console.log(result.user.id); // '123e4567-e89b-12d3-a456-426614174000'
|
|
124
|
+
* console.log(result.token); // 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
|
|
125
|
+
* ```
|
|
126
|
+
|
|
127
|
+
*
|
|
128
|
+
|
|
129
|
+
* @example With error handling
|
|
130
|
+
* ```typescript
|
|
131
|
+
* try {
|
|
132
|
+
* const result = await service.createUser({ input, currentUser });
|
|
133
|
+
* console.log('User created:', result.user.id);
|
|
134
|
+
* } catch (error) {
|
|
135
|
+
* if (error instanceof ServiceError) {
|
|
136
|
+
* if (error.code === ServiceErrorCode.CONFLICT) {
|
|
137
|
+
* console.log('Email already exists');
|
|
138
|
+
* }
|
|
139
|
+
* }
|
|
140
|
+
* }
|
|
141
|
+
* ```
|
|
142
|
+
|
|
143
|
+
*
|
|
144
|
+
|
|
145
|
+
* @complexity
|
|
146
|
+
* - Time: O(1) for database insert + O(1) for hash operation
|
|
147
|
+
* - Space: O(1) constant space usage
|
|
148
|
+
|
|
149
|
+
*
|
|
150
|
+
|
|
151
|
+
* @sideEffects
|
|
152
|
+
* - Creates a new record in the users table
|
|
153
|
+
* - Sends a welcome email to the user's email address
|
|
154
|
+
* - Logs user creation event to audit log
|
|
155
|
+
* - May trigger webhook notifications if configured
|
|
156
|
+
|
|
157
|
+
*
|
|
158
|
+
|
|
159
|
+
* @see {@link UserService} for other user management operations
|
|
160
|
+
* @see {@link validateUserInput} for detailed validation rules
|
|
161
|
+
* @see {@link hashPassword} for password hashing implementation
|
|
162
|
+
* @see {@link sendWelcomeEmail} for email sending logic
|
|
163
|
+
|
|
164
|
+
*
|
|
165
|
+
|
|
166
|
+
* @since 1.0.0 - Initial implementation
|
|
167
|
+
* @version 1.2.0 - Added webhook support
|
|
168
|
+
|
|
169
|
+
*
|
|
170
|
+
|
|
171
|
+
* @author Engineering Team
|
|
172
|
+
* @lastModified 2024-01-15
|
|
173
|
+
|
|
174
|
+
*/
|
|
175
|
+
export const createUser = async ({
|
|
176
|
+
input,
|
|
177
|
+
currentUser,
|
|
178
|
+
}: CreateUserParams): Promise<CreateUserOutput> => {
|
|
179
|
+
// implementation
|
|
180
|
+
};
|
|
181
|
+
```text
|
|
182
|
+
|
|
183
|
+
### Class Documentation
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
/**
|
|
187
|
+
|
|
188
|
+
* Service for managing entity listings in the platform
|
|
189
|
+
|
|
190
|
+
*
|
|
191
|
+
|
|
192
|
+
* This service handles all entity-related operations including:
|
|
193
|
+
* - Creating and updating entity listings
|
|
194
|
+
* - Search and filtering entitys
|
|
195
|
+
* - Managing availability and pricing
|
|
196
|
+
* - Handling images and amenities
|
|
197
|
+
* - Enforcing business rules for hosts
|
|
198
|
+
|
|
199
|
+
*
|
|
200
|
+
|
|
201
|
+
* The service extends BaseCrudService and adds entity-specific
|
|
202
|
+
* business logic such as validation of capacity limits, price ranges,
|
|
203
|
+
* and host permissions.
|
|
204
|
+
|
|
205
|
+
*
|
|
206
|
+
|
|
207
|
+
* @extends BaseCrudService
|
|
208
|
+
* @implements IEntityService
|
|
209
|
+
|
|
210
|
+
*
|
|
211
|
+
|
|
212
|
+
* @example Creating the service
|
|
213
|
+
* ```typescript
|
|
214
|
+
* import { EntityService } from '@repo/service-core';
|
|
215
|
+
|
|
216
|
+
*
|
|
217
|
+
|
|
218
|
+
* const service = new EntityService(ctx);
|
|
219
|
+
* ```
|
|
220
|
+
|
|
221
|
+
*
|
|
222
|
+
|
|
223
|
+
* @example Using the service
|
|
224
|
+
* ```typescript
|
|
225
|
+
* // Create entity
|
|
226
|
+
* const result = await service.create({
|
|
227
|
+
* input: {
|
|
228
|
+
* name: 'Beach House',
|
|
229
|
+
* type: 'house',
|
|
230
|
+
* capacity: 6,
|
|
231
|
+
* pricePerNight: 150
|
|
232
|
+
* },
|
|
233
|
+
* user: hostUser
|
|
234
|
+
* });
|
|
235
|
+
|
|
236
|
+
*
|
|
237
|
+
|
|
238
|
+
* // Search entitys
|
|
239
|
+
* const entitys = await service.findAll({
|
|
240
|
+
* search: { q: 'beach', type: 'house' },
|
|
241
|
+
* page: 1,
|
|
242
|
+
* pageSize: 20
|
|
243
|
+
* });
|
|
244
|
+
* ```
|
|
245
|
+
|
|
246
|
+
*
|
|
247
|
+
|
|
248
|
+
* @see {@link BaseCrudService} for inherited CRUD operations
|
|
249
|
+
* @see {@link EntityModel} for data access layer
|
|
250
|
+
|
|
251
|
+
*
|
|
252
|
+
|
|
253
|
+
* @since 1.0.0
|
|
254
|
+
|
|
255
|
+
*/
|
|
256
|
+
export class EntityService extends BaseCrudService<
|
|
257
|
+
Entity,
|
|
258
|
+
EntityModel,
|
|
259
|
+
CreateEntityInput,
|
|
260
|
+
UpdateEntityInput,
|
|
261
|
+
SearchEntityInput
|
|
262
|
+
> {
|
|
263
|
+
/**
|
|
264
|
+
|
|
265
|
+
* Creates a new EntityService instance
|
|
266
|
+
|
|
267
|
+
*
|
|
268
|
+
|
|
269
|
+
* @param {ServiceContext} ctx - Service context with database and logger
|
|
270
|
+
* @param {EntityModel} [model] - Optional custom model instance (for testing)
|
|
271
|
+
|
|
272
|
+
*
|
|
273
|
+
|
|
274
|
+
* @example
|
|
275
|
+
* ```typescript
|
|
276
|
+
* const service = new EntityService(ctx);
|
|
277
|
+
* ```
|
|
278
|
+
|
|
279
|
+
*/
|
|
280
|
+
constructor(ctx: ServiceContext, model?: EntityModel) {
|
|
281
|
+
super(ctx, model ?? new EntityModel(ctx.db));
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
```text
|
|
285
|
+
|
|
286
|
+
### Type Documentation
|
|
287
|
+
|
|
288
|
+
```typescript
|
|
289
|
+
/**
|
|
290
|
+
|
|
291
|
+
* Represents a user account in the the project platform
|
|
292
|
+
|
|
293
|
+
*
|
|
294
|
+
|
|
295
|
+
* Users can have one of three roles:
|
|
296
|
+
* - **admin**: Full system access, can manage all resources
|
|
297
|
+
* - **host**: Can create and manage their own entitys
|
|
298
|
+
* - **guest**: Can search and book entitys
|
|
299
|
+
|
|
300
|
+
*
|
|
301
|
+
|
|
302
|
+
* User accounts support soft deletion, meaning deleted users are marked
|
|
303
|
+
* with a deletedAt timestamp but not removed from the database.
|
|
304
|
+
|
|
305
|
+
*
|
|
306
|
+
|
|
307
|
+
* @property {string} id - Unique identifier (UUID v4 format)
|
|
308
|
+
* @property {string} name - User's full name (1-200 characters)
|
|
309
|
+
* @property {string} email - User's email address (unique, valid format)
|
|
310
|
+
* @property {UserRole} role - User's role (admin | host | guest)
|
|
311
|
+
* @property {string} [phone] - Optional phone number
|
|
312
|
+
* @property {string} [avatar] - Optional avatar URL
|
|
313
|
+
* @property {Date} createdAt - Account creation timestamp (UTC)
|
|
314
|
+
* @property {Date} updatedAt - Last modification timestamp (UTC)
|
|
315
|
+
* @property {Date | null} deletedAt - Soft deletion timestamp (null if active)
|
|
316
|
+
|
|
317
|
+
*
|
|
318
|
+
|
|
319
|
+
* @example
|
|
320
|
+
* ```typescript
|
|
321
|
+
* const user: User = {
|
|
322
|
+
* id: '123e4567-e89b-12d3-a456-426614174000',
|
|
323
|
+
* name: 'John Doe',
|
|
324
|
+
* email: 'john@example.com',
|
|
325
|
+
* role: 'host',
|
|
326
|
+
* phone: '+54 9 11 1234-5678',
|
|
327
|
+
* avatar: 'https://example.com/avatars/john.jpg',
|
|
328
|
+
* createdAt: new Date('2024-01-01T00:00:00Z'),
|
|
329
|
+
* updatedAt: new Date('2024-01-15T10:30:00Z'),
|
|
330
|
+
* deletedAt: null
|
|
331
|
+
* };
|
|
332
|
+
* ```
|
|
333
|
+
|
|
334
|
+
*
|
|
335
|
+
|
|
336
|
+
* @see {@link UserRole} for role definitions
|
|
337
|
+
* @see {@link createUserSchema} for validation schema
|
|
338
|
+
|
|
339
|
+
*/
|
|
340
|
+
export type User = {
|
|
341
|
+
id: string;
|
|
342
|
+
name: string;
|
|
343
|
+
email: string;
|
|
344
|
+
role: UserRole;
|
|
345
|
+
phone?: string;
|
|
346
|
+
avatar?: string;
|
|
347
|
+
createdAt: Date;
|
|
348
|
+
updatedAt: Date;
|
|
349
|
+
deletedAt: Date | null;
|
|
350
|
+
};
|
|
351
|
+
```text
|
|
352
|
+
|
|
353
|
+
### Essential JSDoc Tags
|
|
354
|
+
|
|
355
|
+
**Required:**
|
|
356
|
+
|
|
357
|
+
- `@param` - Function parameters (with types)
|
|
358
|
+
- `@returns` - Return value (with type)
|
|
359
|
+
- `@throws` - Possible errors
|
|
360
|
+
|
|
361
|
+
**Highly Recommended:**
|
|
362
|
+
|
|
363
|
+
- `@example` - Working code examples (at least 1)
|
|
364
|
+
- `@complexity` - Time/space complexity
|
|
365
|
+
- `@sideEffects` - Side effects (database, email, logs, etc.)
|
|
366
|
+
- `@see` - Related code/documentation
|
|
367
|
+
|
|
368
|
+
**Optional:**
|
|
369
|
+
|
|
370
|
+
- `@since` - Version introduced
|
|
371
|
+
- `@version` - Current version
|
|
372
|
+
- `@deprecated` - Deprecation info
|
|
373
|
+
- `@author` - Author name
|
|
374
|
+
- `@lastModified` - Last modification date
|
|
375
|
+
|
|
376
|
+
---
|
|
377
|
+
|
|
378
|
+
## API Documentation
|
|
379
|
+
|
|
380
|
+
### OpenAPI (Swagger) Documentation
|
|
381
|
+
|
|
382
|
+
**All API endpoints MUST have OpenAPI documentation.**
|
|
383
|
+
|
|
384
|
+
```typescript
|
|
385
|
+
/**
|
|
386
|
+
|
|
387
|
+
* @openapi
|
|
388
|
+
* /api/entitys:
|
|
389
|
+
* post:
|
|
390
|
+
* summary: Create a new entity listing
|
|
391
|
+
* description: |
|
|
392
|
+
* Creates a new entity listing for the authenticated host user.
|
|
393
|
+
* The host must have the 'host' role and 'entity:write' permission.
|
|
394
|
+
|
|
395
|
+
*
|
|
396
|
+
|
|
397
|
+
* Business rules:
|
|
398
|
+
* - Name must be unique per host
|
|
399
|
+
* - Capacity must be between 1 and 50
|
|
400
|
+
* - Price must be positive
|
|
401
|
+
* - Host ID is automatically set to the authenticated user
|
|
402
|
+
|
|
403
|
+
*
|
|
404
|
+
|
|
405
|
+
* tags:
|
|
406
|
+
* - Entitys
|
|
407
|
+
|
|
408
|
+
*
|
|
409
|
+
|
|
410
|
+
* security:
|
|
411
|
+
* - bearerAuth: []
|
|
412
|
+
|
|
413
|
+
*
|
|
414
|
+
|
|
415
|
+
* requestBody:
|
|
416
|
+
* required: true
|
|
417
|
+
* content:
|
|
418
|
+
* application/json:
|
|
419
|
+
* schema:
|
|
420
|
+
* $ref: '#/components/schemas/CreateEntityInput'
|
|
421
|
+
* examples:
|
|
422
|
+
* basic:
|
|
423
|
+
* summary: Basic entity
|
|
424
|
+
* value:
|
|
425
|
+
* name: Beach House
|
|
426
|
+
* type: house
|
|
427
|
+
* capacity: 6
|
|
428
|
+
* pricePerNight: 150
|
|
429
|
+
* detailed:
|
|
430
|
+
* summary: Detailed entity
|
|
431
|
+
* value:
|
|
432
|
+
* name: Luxury Beach Villa
|
|
433
|
+
* type: house
|
|
434
|
+
* capacity: 10
|
|
435
|
+
* pricePerNight: 500
|
|
436
|
+
* description: Stunning ocean view villa
|
|
437
|
+
* amenities: [wifi, pool, parking]
|
|
438
|
+
|
|
439
|
+
*
|
|
440
|
+
|
|
441
|
+
* responses:
|
|
442
|
+
* 201:
|
|
443
|
+
* description: Entity created successfully
|
|
444
|
+
* content:
|
|
445
|
+
* application/json:
|
|
446
|
+
* schema:
|
|
447
|
+
* type: object
|
|
448
|
+
* properties:
|
|
449
|
+
* success:
|
|
450
|
+
* type: boolean
|
|
451
|
+
* example: true
|
|
452
|
+
* data:
|
|
453
|
+
* $ref: '#/components/schemas/Entity'
|
|
454
|
+
* 400:
|
|
455
|
+
* description: Validation error
|
|
456
|
+
* content:
|
|
457
|
+
* application/json:
|
|
458
|
+
* schema:
|
|
459
|
+
* $ref: '#/components/schemas/ErrorResponse'
|
|
460
|
+
* examples:
|
|
461
|
+
* validation:
|
|
462
|
+
* value:
|
|
463
|
+
* success: false
|
|
464
|
+
* error:
|
|
465
|
+
* code: VALIDATION_ERROR
|
|
466
|
+
* message: Invalid input data
|
|
467
|
+
* 401:
|
|
468
|
+
* description: Not authenticated
|
|
469
|
+
* content:
|
|
470
|
+
* application/json:
|
|
471
|
+
* schema:
|
|
472
|
+
* $ref: '#/components/schemas/ErrorResponse'
|
|
473
|
+
* 403:
|
|
474
|
+
* description: Forbidden - User is not a host
|
|
475
|
+
* content:
|
|
476
|
+
* application/json:
|
|
477
|
+
* schema:
|
|
478
|
+
* $ref: '#/components/schemas/ErrorResponse'
|
|
479
|
+
* 409:
|
|
480
|
+
* description: Conflict - Entity name already exists
|
|
481
|
+
* content:
|
|
482
|
+
* application/json:
|
|
483
|
+
* schema:
|
|
484
|
+
* $ref: '#/components/schemas/ErrorResponse'
|
|
485
|
+
|
|
486
|
+
*/
|
|
487
|
+
app.post('/entitys', ...);
|
|
488
|
+
```text
|
|
489
|
+
|
|
490
|
+
### API Endpoint Documentation File
|
|
491
|
+
|
|
492
|
+
**Create separate markdown files for complex APIs:**
|
|
493
|
+
|
|
494
|
+
```markdown
|
|
495
|
+
|
|
496
|
+
# Entitys API
|
|
497
|
+
|
|
498
|
+
## Overview
|
|
499
|
+
|
|
500
|
+
The Entitys API allows hosts to create, manage, and list entity properties.
|
|
501
|
+
|
|
502
|
+
Base URL: `/api/entitys`
|
|
503
|
+
|
|
504
|
+
## Authentication
|
|
505
|
+
|
|
506
|
+
All write operations require authentication with a valid JWT token.
|
|
507
|
+
|
|
508
|
+
```http
|
|
509
|
+
|
|
510
|
+
Authorization: Bearer <token>
|
|
511
|
+
|
|
512
|
+
```text
|
|
513
|
+
|
|
514
|
+
## Endpoints
|
|
515
|
+
|
|
516
|
+
### List Entitys
|
|
517
|
+
|
|
518
|
+
`GET /api/entitys`
|
|
519
|
+
|
|
520
|
+
**Query Parameters:**
|
|
521
|
+
|
|
522
|
+
| Parameter | Type | Required | Default | Description |
|
|
523
|
+
|-----------|------|----------|---------|-------------|
|
|
524
|
+
| q | string | No | - | Search query (searches name and description) |
|
|
525
|
+
| type | string | No | - | Filter by type (house, apartment, room) |
|
|
526
|
+
| minCapacity | number | No | - | Minimum capacity |
|
|
527
|
+
| maxPrice | number | No | - | Maximum price per night |
|
|
528
|
+
| page | number | No | 1 | Page number |
|
|
529
|
+
| pageSize | number | No | 20 | Items per page (max 100) |
|
|
530
|
+
|
|
531
|
+
**Response:**
|
|
532
|
+
|
|
533
|
+
```json
|
|
534
|
+
|
|
535
|
+
{
|
|
536
|
+
"success": true,
|
|
537
|
+
"data": {
|
|
538
|
+
"items": [...],
|
|
539
|
+
"pagination": {
|
|
540
|
+
"page": 1,
|
|
541
|
+
"pageSize": 20,
|
|
542
|
+
"total": 45,
|
|
543
|
+
"totalPages": 3
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
```text
|
|
549
|
+
|
|
550
|
+
### Create Entity
|
|
551
|
+
|
|
552
|
+
`POST /api/entitys`
|
|
553
|
+
|
|
554
|
+
**Authentication:** Required (Host role)
|
|
555
|
+
|
|
556
|
+
**Request Body:**
|
|
557
|
+
|
|
558
|
+
```json
|
|
559
|
+
|
|
560
|
+
{
|
|
561
|
+
"name": "Beach House",
|
|
562
|
+
"type": "house",
|
|
563
|
+
"capacity": 6,
|
|
564
|
+
"pricePerNight": 150,
|
|
565
|
+
"description": "Beautiful beach house...",
|
|
566
|
+
"amenities": ["wifi", "pool", "parking"]
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
```text
|
|
570
|
+
|
|
571
|
+
**Response:** `201 Created`
|
|
572
|
+
|
|
573
|
+
```json
|
|
574
|
+
|
|
575
|
+
{
|
|
576
|
+
"success": true,
|
|
577
|
+
"data": {
|
|
578
|
+
"entity": {
|
|
579
|
+
"id": "...",
|
|
580
|
+
"name": "Beach House",
|
|
581
|
+
...
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
```text
|
|
587
|
+
|
|
588
|
+
**Error Responses:**
|
|
589
|
+
|
|
590
|
+
- `400` - Validation error
|
|
591
|
+
- `401` - Not authenticated
|
|
592
|
+
- `403` - Not authorized (must be host)
|
|
593
|
+
- `409` - Name already exists
|
|
594
|
+
|
|
595
|
+
## Rate Limiting
|
|
596
|
+
|
|
597
|
+
- **Authenticated**: 100 requests per minute
|
|
598
|
+
- **Anonymous**: 20 requests per minute
|
|
599
|
+
|
|
600
|
+
## Error Codes
|
|
601
|
+
|
|
602
|
+
| Code | Description |
|
|
603
|
+
|------|-------------|
|
|
604
|
+
| VALIDATION_ERROR | Input validation failed |
|
|
605
|
+
| NOT_FOUND | Resource not found |
|
|
606
|
+
| CONFLICT | Resource already exists |
|
|
607
|
+
| FORBIDDEN | Permission denied |
|
|
608
|
+
|
|
609
|
+
## Examples
|
|
610
|
+
|
|
611
|
+
### Search for beach houses
|
|
612
|
+
|
|
613
|
+
```bash
|
|
614
|
+
|
|
615
|
+
curl -X GET "https://api.example.com/api/entitys?q=beach&type=house"
|
|
616
|
+
|
|
617
|
+
```text
|
|
618
|
+
|
|
619
|
+
### Create entity
|
|
620
|
+
|
|
621
|
+
```bash
|
|
622
|
+
|
|
623
|
+
curl -X POST https://api.example.com/api/entitys \
|
|
624
|
+
-H "Authorization: Bearer <token>" \
|
|
625
|
+
-H "Content-Type: application/json" \
|
|
626
|
+
-d '{
|
|
627
|
+
"name": "Beach House",
|
|
628
|
+
"type": "house",
|
|
629
|
+
"capacity": 6,
|
|
630
|
+
"pricePerNight": 150
|
|
631
|
+
}'
|
|
632
|
+
|
|
633
|
+
```text
|
|
634
|
+
```text
|
|
635
|
+
|
|
636
|
+
---
|
|
637
|
+
|
|
638
|
+
## Component Documentation
|
|
639
|
+
|
|
640
|
+
### Component README
|
|
641
|
+
|
|
642
|
+
**Create README.md for complex components:**
|
|
643
|
+
|
|
644
|
+
```markdown
|
|
645
|
+
|
|
646
|
+
# EntityCard
|
|
647
|
+
|
|
648
|
+
Displays entity information in a card format with image, title, price, and key details.
|
|
649
|
+
|
|
650
|
+
## Usage
|
|
651
|
+
|
|
652
|
+
\`\`\`tsx
|
|
653
|
+
import { EntityCard } from '@/components/entity';
|
|
654
|
+
|
|
655
|
+
<EntityCard
|
|
656
|
+
entity={entity}
|
|
657
|
+
onSelect={handleSelect}
|
|
658
|
+
variant="detailed"
|
|
659
|
+
/>
|
|
660
|
+
\`\`\`
|
|
661
|
+
|
|
662
|
+
## Props
|
|
663
|
+
|
|
664
|
+
| Prop | Type | Required | Default | Description |
|
|
665
|
+
|------|------|----------|---------|-------------|
|
|
666
|
+
| entity | Entity | Yes | - | Entity data to display |
|
|
667
|
+
| onSelect | (id: string) => void | No | - | Callback when card is clicked |
|
|
668
|
+
| variant | "compact" \| "detailed" | No | "compact" | Display variant |
|
|
669
|
+
| showPrice | boolean | No | true | Whether to show price |
|
|
670
|
+
| loading | boolean | No | false | Show loading state |
|
|
671
|
+
|
|
672
|
+
## Variants
|
|
673
|
+
|
|
674
|
+
### Compact
|
|
675
|
+
|
|
676
|
+
Shows essential info: image, name, type, capacity, price
|
|
677
|
+
|
|
678
|
+
\`\`\`tsx
|
|
679
|
+
<EntityCard entity={data} variant="compact" />
|
|
680
|
+
\`\`\`
|
|
681
|
+
|
|
682
|
+
### Detailed
|
|
683
|
+
|
|
684
|
+
Shows full info: all compact info + description, amenities, rating
|
|
685
|
+
|
|
686
|
+
\`\`\`tsx
|
|
687
|
+
<EntityCard entity={data} variant="detailed" />
|
|
688
|
+
\`\`\`
|
|
689
|
+
|
|
690
|
+
## Accessibility
|
|
691
|
+
|
|
692
|
+
- ✅ Keyboard navigable (Tab, Enter)
|
|
693
|
+
- ✅ Screen reader friendly with ARIA labels
|
|
694
|
+
- ✅ Focus visible with ring
|
|
695
|
+
- ✅ Semantic HTML (article, heading, etc.)
|
|
696
|
+
- ✅ Alt text for images
|
|
697
|
+
|
|
698
|
+
## Styling
|
|
699
|
+
|
|
700
|
+
Uses Tailwind CSS and Shadcn UI components. Brand guidelines are applied automatically.
|
|
701
|
+
|
|
702
|
+
**Customization:**
|
|
703
|
+
|
|
704
|
+
\`\`\`tsx
|
|
705
|
+
<EntityCard
|
|
706
|
+
entity={data}
|
|
707
|
+
className="custom-card-styles"
|
|
708
|
+
/>
|
|
709
|
+
\`\`\`
|
|
710
|
+
|
|
711
|
+
## Examples
|
|
712
|
+
|
|
713
|
+
### Basic usage
|
|
714
|
+
|
|
715
|
+
\`\`\`tsx
|
|
716
|
+
<EntityCard entity={entity} />
|
|
717
|
+
\`\`\`
|
|
718
|
+
|
|
719
|
+
### With selection handler
|
|
720
|
+
|
|
721
|
+
\`\`\`tsx
|
|
722
|
+
<EntityCard
|
|
723
|
+
entity={entity}
|
|
724
|
+
onSelect={(id) => navigate(\`/entity/\${id}\`)}
|
|
725
|
+
/>
|
|
726
|
+
\`\`\`
|
|
727
|
+
|
|
728
|
+
### Loading state
|
|
729
|
+
|
|
730
|
+
\`\`\`tsx
|
|
731
|
+
<EntityCard
|
|
732
|
+
entity={entity}
|
|
733
|
+
loading={isLoading}
|
|
734
|
+
/>
|
|
735
|
+
\`\`\`
|
|
736
|
+
|
|
737
|
+
## Dependencies
|
|
738
|
+
|
|
739
|
+
- React 19
|
|
740
|
+
- Tailwind CSS
|
|
741
|
+
- Shadcn UI (Card, Badge, Button)
|
|
742
|
+
- Lucide icons
|
|
743
|
+
|
|
744
|
+
## Related Components
|
|
745
|
+
|
|
746
|
+
- `EntityList` - List of cards
|
|
747
|
+
- `EntityDetail` - Full detail view
|
|
748
|
+
- `EntityForm` - Create/edit form
|
|
749
|
+
|
|
750
|
+
```text
|
|
751
|
+
|
|
752
|
+
---
|
|
753
|
+
|
|
754
|
+
## Architecture Documentation
|
|
755
|
+
|
|
756
|
+
### Architecture Decision Records (ADRs)
|
|
757
|
+
|
|
758
|
+
**Document important architectural decisions:**
|
|
759
|
+
|
|
760
|
+
```markdown
|
|
761
|
+
|
|
762
|
+
# ADR-001: Use Drizzle ORM over Prisma
|
|
763
|
+
|
|
764
|
+
## Status
|
|
765
|
+
|
|
766
|
+
Accepted
|
|
767
|
+
|
|
768
|
+
## Context
|
|
769
|
+
|
|
770
|
+
We need an ORM for PostgreSQL that provides:
|
|
771
|
+
|
|
772
|
+
- Type safety
|
|
773
|
+
- Good performance
|
|
774
|
+
- Developer experience
|
|
775
|
+
- Flexibility for complex queries
|
|
776
|
+
|
|
777
|
+
## Decision
|
|
778
|
+
|
|
779
|
+
Use Drizzle ORM instead of Prisma.
|
|
780
|
+
|
|
781
|
+
## Rationale
|
|
782
|
+
|
|
783
|
+
**Why Drizzle:**
|
|
784
|
+
|
|
785
|
+
- Better TypeScript integration (types match database exactly)
|
|
786
|
+
- More control over queries (closer to SQL)
|
|
787
|
+
- Lighter bundle size (~15KB vs ~300KB for Prisma)
|
|
788
|
+
- Better performance for complex queries
|
|
789
|
+
- More flexible migrations
|
|
790
|
+
|
|
791
|
+
**Why not Prisma:**
|
|
792
|
+
|
|
793
|
+
- Less control over generated queries
|
|
794
|
+
- Heavier runtime
|
|
795
|
+
- Some limitations with complex relationships
|
|
796
|
+
- Migration system can be opinionated
|
|
797
|
+
|
|
798
|
+
## Consequences
|
|
799
|
+
|
|
800
|
+
### Positive
|
|
801
|
+
|
|
802
|
+
- Excellent type safety
|
|
803
|
+
- Better performance
|
|
804
|
+
- More control
|
|
805
|
+
- Smaller bundle
|
|
806
|
+
|
|
807
|
+
### Negative
|
|
808
|
+
|
|
809
|
+
- Smaller community
|
|
810
|
+
- Fewer third-party tools
|
|
811
|
+
- Team needs to learn Drizzle syntax
|
|
812
|
+
- Less mature ecosystem
|
|
813
|
+
|
|
814
|
+
### Neutral
|
|
815
|
+
|
|
816
|
+
- Need to build some utilities ourselves
|
|
817
|
+
- More SQL knowledge required
|
|
818
|
+
|
|
819
|
+
## Alternatives Considered
|
|
820
|
+
|
|
821
|
+
1. **Prisma**
|
|
822
|
+
- Pros: Mature, large ecosystem, great DX
|
|
823
|
+
- Cons: Less control, heavier, performance concerns
|
|
824
|
+
|
|
825
|
+
2. **TypeORM**
|
|
826
|
+
- Pros: Mature, feature-rich
|
|
827
|
+
- Cons: Decorator-heavy, less type-safe, heavier
|
|
828
|
+
|
|
829
|
+
3. **Kysely**
|
|
830
|
+
- Pros: Excellent type safety, lightweight
|
|
831
|
+
- Cons: More verbose, lower-level
|
|
832
|
+
|
|
833
|
+
## References
|
|
834
|
+
|
|
835
|
+
- [Drizzle Documentation](https://orm.drizzle.team)
|
|
836
|
+
- [Performance Comparison](https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-vs-prisma.md)
|
|
837
|
+
|
|
838
|
+
## Review
|
|
839
|
+
|
|
840
|
+
- **Date**: 2024-01-01
|
|
841
|
+
- **Reviewers**: Engineering Team
|
|
842
|
+
- **Next Review**: 2024-07-01 (or when pain points arise)
|
|
843
|
+
|
|
844
|
+
```text
|
|
845
|
+
|
|
846
|
+
---
|
|
847
|
+
|
|
848
|
+
## README Files
|
|
849
|
+
|
|
850
|
+
### Package README Template
|
|
851
|
+
|
|
852
|
+
```markdown
|
|
853
|
+
|
|
854
|
+
# @repo/service-core
|
|
855
|
+
|
|
856
|
+
Business logic layer for the project platform.
|
|
857
|
+
|
|
858
|
+
## Overview
|
|
859
|
+
|
|
860
|
+
This package contains all service classes that implement business logic and coordinate between models (data layer) and API routes.
|
|
861
|
+
|
|
862
|
+
## Installation
|
|
863
|
+
|
|
864
|
+
\`\`\`bash
|
|
865
|
+
pnpm add @repo/service-core
|
|
866
|
+
\`\`\`
|
|
867
|
+
|
|
868
|
+
## Usage
|
|
869
|
+
|
|
870
|
+
\`\`\`typescript
|
|
871
|
+
import { UserService } from '@repo/service-core';
|
|
872
|
+
|
|
873
|
+
const service = new UserService(ctx);
|
|
874
|
+
const result = await service.create({ input, user });
|
|
875
|
+
\`\`\`
|
|
876
|
+
|
|
877
|
+
## Architecture
|
|
878
|
+
|
|
879
|
+
All services extend `BaseCrudService` which provides:
|
|
880
|
+
|
|
881
|
+
- `findById` - Get single record
|
|
882
|
+
- `findAll` - List with pagination
|
|
883
|
+
- `create` - Create record
|
|
884
|
+
- `update` - Update record
|
|
885
|
+
- `delete` - Soft delete record
|
|
886
|
+
|
|
887
|
+
## Available Services
|
|
888
|
+
|
|
889
|
+
- `UserService` - User management
|
|
890
|
+
- `EntityService` - Entity listings
|
|
891
|
+
- `BookingService` - Booking management
|
|
892
|
+
- `PaymentService` - Payment processing
|
|
893
|
+
|
|
894
|
+
## Development
|
|
895
|
+
|
|
896
|
+
\`\`\`bash
|
|
897
|
+
|
|
898
|
+
# Run tests
|
|
899
|
+
|
|
900
|
+
pnpm test
|
|
901
|
+
|
|
902
|
+
# Type check
|
|
903
|
+
|
|
904
|
+
pnpm typecheck
|
|
905
|
+
|
|
906
|
+
# Lint
|
|
907
|
+
|
|
908
|
+
pnpm lint
|
|
909
|
+
\`\`\`
|
|
910
|
+
|
|
911
|
+
## Documentation
|
|
912
|
+
|
|
913
|
+
See [Service Layer Documentation](../../docs/architecture/service-layer.md)
|
|
914
|
+
```text
|
|
915
|
+
|
|
916
|
+
---
|
|
917
|
+
|
|
918
|
+
## Code Comments
|
|
919
|
+
|
|
920
|
+
### When to Comment
|
|
921
|
+
|
|
922
|
+
**DO comment:**
|
|
923
|
+
|
|
924
|
+
```typescript
|
|
925
|
+
// Use exponential backoff to avoid overwhelming API during high traffic
|
|
926
|
+
const delay = Math.min(1000 * Math.pow(2, retryCount), 10000);
|
|
927
|
+
|
|
928
|
+
// PostgreSQL full-text search with Spanish stemming
|
|
929
|
+
const results = await db.execute(sql`
|
|
930
|
+
SELECT * FROM entitys
|
|
931
|
+
WHERE to_tsvector('spanish', name || ' ' || description)
|
|
932
|
+
@@ plainto_tsquery('spanish', ${query})
|
|
933
|
+
`);
|
|
934
|
+
|
|
935
|
+
// TODO: Optimize with index on (userId, createdAt)
|
|
936
|
+
// Current: ~500ms for 10k records, Target: <50ms
|
|
937
|
+
const bookings = await db.query.bookings.findMany({
|
|
938
|
+
where: eq(bookings.userId, userId),
|
|
939
|
+
orderBy: desc(bookings.createdAt),
|
|
940
|
+
});
|
|
941
|
+
```text
|
|
942
|
+
|
|
943
|
+
**DON'T comment:**
|
|
944
|
+
|
|
945
|
+
```typescript
|
|
946
|
+
// ❌ BAD: Obvious
|
|
947
|
+
// Set user name
|
|
948
|
+
const userName = 'John';
|
|
949
|
+
|
|
950
|
+
// ❌ BAD: Redundant
|
|
951
|
+
// Loop through users
|
|
952
|
+
users.forEach(user => processUser(user));
|
|
953
|
+
```text
|
|
954
|
+
|
|
955
|
+
---
|
|
956
|
+
|
|
957
|
+
## Diagrams
|
|
958
|
+
|
|
959
|
+
### Use Mermaid
|
|
960
|
+
|
|
961
|
+
**Entity Relationships:**
|
|
962
|
+
|
|
963
|
+
```mermaid
|
|
964
|
+
erDiagram
|
|
965
|
+
USER ||--o{ ACCOMMODATION : owns
|
|
966
|
+
ACCOMMODATION ||--o{ BOOKING : has
|
|
967
|
+
BOOKING ||--|| PAYMENT : requires
|
|
968
|
+
USER ||--o{ BOOKING : makes
|
|
969
|
+
|
|
970
|
+
USER {
|
|
971
|
+
uuid id PK
|
|
972
|
+
string name
|
|
973
|
+
string email
|
|
974
|
+
string role
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
ACCOMMODATION {
|
|
978
|
+
uuid id PK
|
|
979
|
+
uuid hostId FK
|
|
980
|
+
string name
|
|
981
|
+
string type
|
|
982
|
+
int capacity
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
BOOKING {
|
|
986
|
+
uuid id PK
|
|
987
|
+
uuid entityId FK
|
|
988
|
+
uuid userId FK
|
|
989
|
+
date checkIn
|
|
990
|
+
date checkOut
|
|
991
|
+
}
|
|
992
|
+
```text
|
|
993
|
+
|
|
994
|
+
**Sequence Diagrams:**
|
|
995
|
+
|
|
996
|
+
```mermaid
|
|
997
|
+
sequenceDiagram
|
|
998
|
+
participant User
|
|
999
|
+
participant Frontend
|
|
1000
|
+
participant API
|
|
1001
|
+
participant Service
|
|
1002
|
+
participant Database
|
|
1003
|
+
|
|
1004
|
+
User->>Frontend: Click "Book Now"
|
|
1005
|
+
Frontend->>API: POST /api/bookings
|
|
1006
|
+
API->>Service: create({ input, user })
|
|
1007
|
+
Service->>Database: Check availability
|
|
1008
|
+
Database-->>Service: Available
|
|
1009
|
+
Service->>Database: Create booking
|
|
1010
|
+
Database-->>Service: Booking created
|
|
1011
|
+
Service-->>API: { booking }
|
|
1012
|
+
API-->>Frontend: 201 Created
|
|
1013
|
+
Frontend-->>User: Show confirmation
|
|
1014
|
+
```text
|
|
1015
|
+
|
|
1016
|
+
**Flowcharts:**
|
|
1017
|
+
|
|
1018
|
+
```mermaid
|
|
1019
|
+
flowchart TD
|
|
1020
|
+
A[User Request] --> B{Authenticated?}
|
|
1021
|
+
B -->|No| C[Return 401]
|
|
1022
|
+
B -->|Yes| D{Has Permission?}
|
|
1023
|
+
D -->|No| E[Return 403]
|
|
1024
|
+
D -->|Yes| F[Validate Input]
|
|
1025
|
+
F --> G{Valid?}
|
|
1026
|
+
G -->|No| H[Return 400]
|
|
1027
|
+
G -->|Yes| I[Execute Business Logic]
|
|
1028
|
+
I --> J[Return 200]
|
|
1029
|
+
```text
|
|
1030
|
+
|
|
1031
|
+
---
|
|
1032
|
+
|
|
1033
|
+
## Changelog
|
|
1034
|
+
|
|
1035
|
+
### Keep a CHANGELOG.md
|
|
1036
|
+
|
|
1037
|
+
```markdown
|
|
1038
|
+
|
|
1039
|
+
# Changelog
|
|
1040
|
+
|
|
1041
|
+
All notable changes to this project will be documented in this file.
|
|
1042
|
+
|
|
1043
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
1044
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
1045
|
+
|
|
1046
|
+
## [Unreleased]
|
|
1047
|
+
|
|
1048
|
+
### Added
|
|
1049
|
+
|
|
1050
|
+
- Search functionality for entitys
|
|
1051
|
+
|
|
1052
|
+
### Changed
|
|
1053
|
+
|
|
1054
|
+
- Improved performance of booking queries
|
|
1055
|
+
|
|
1056
|
+
## [1.2.0] - 2024-01-15
|
|
1057
|
+
|
|
1058
|
+
### Added
|
|
1059
|
+
|
|
1060
|
+
- Webhook support for booking notifications
|
|
1061
|
+
- Email templates for confirmations
|
|
1062
|
+
- Rate limiting on API endpoints
|
|
1063
|
+
|
|
1064
|
+
### Changed
|
|
1065
|
+
|
|
1066
|
+
- Updated Drizzle to v0.29.0
|
|
1067
|
+
- Improved error messages
|
|
1068
|
+
|
|
1069
|
+
### Fixed
|
|
1070
|
+
|
|
1071
|
+
- Fixed pagination bug in entity list
|
|
1072
|
+
- Fixed timezone handling in bookings
|
|
1073
|
+
|
|
1074
|
+
### Security
|
|
1075
|
+
|
|
1076
|
+
- Updated dependencies with security patches
|
|
1077
|
+
|
|
1078
|
+
## [1.1.0] - 2024-01-01
|
|
1079
|
+
|
|
1080
|
+
### Added
|
|
1081
|
+
|
|
1082
|
+
- Payment processing with Mercado Pago
|
|
1083
|
+
- Admin dashboard
|
|
1084
|
+
|
|
1085
|
+
### Changed
|
|
1086
|
+
|
|
1087
|
+
- Migrated from Prisma to Drizzle ORM
|
|
1088
|
+
|
|
1089
|
+
## [1.0.0] - 2023-12-15
|
|
1090
|
+
|
|
1091
|
+
### Added
|
|
1092
|
+
|
|
1093
|
+
- Initial release
|
|
1094
|
+
- User management
|
|
1095
|
+
- Entity listings
|
|
1096
|
+
- Booking system
|
|
1097
|
+
|
|
1098
|
+
```text
|
|
1099
|
+
|
|
1100
|
+
---
|
|
1101
|
+
|
|
1102
|
+
## Documentation Structure
|
|
1103
|
+
|
|
1104
|
+
```text
|
|
1105
|
+
docs/
|
|
1106
|
+
├── README.md # Overview and navigation
|
|
1107
|
+
├── api/
|
|
1108
|
+
│ ├── README.md # API overview
|
|
1109
|
+
│ ├── entitys.md # Entitys API
|
|
1110
|
+
│ ├── bookings.md # Bookings API
|
|
1111
|
+
│ └── users.md # Users API
|
|
1112
|
+
├── architecture/
|
|
1113
|
+
│ ├── README.md # Architecture overview
|
|
1114
|
+
│ ├── decisions/
|
|
1115
|
+
│ │ ├── ADR-001-drizzle-orm.md
|
|
1116
|
+
│ │ └── ADR-002-monorepo.md
|
|
1117
|
+
│ ├── diagrams/
|
|
1118
|
+
│ │ ├── system-architecture.md
|
|
1119
|
+
│ │ └── data-flow.md
|
|
1120
|
+
│ └── layers/
|
|
1121
|
+
│ ├── database-layer.md
|
|
1122
|
+
│ ├── service-layer.md
|
|
1123
|
+
│ ├── api-layer.md
|
|
1124
|
+
│ └── frontend-layer.md
|
|
1125
|
+
├── components/
|
|
1126
|
+
│ ├── README.md # Component library overview
|
|
1127
|
+
│ ├── EntityCard.md
|
|
1128
|
+
│ └── BookingForm.md
|
|
1129
|
+
├── deployment/
|
|
1130
|
+
│ ├── README.md # Deployment overview
|
|
1131
|
+
│ ├── vercel.md # Vercel deployment
|
|
1132
|
+
│ ├── database.md # Database setup
|
|
1133
|
+
│ └── environment.md # Environment variables
|
|
1134
|
+
└── guides/
|
|
1135
|
+
├── getting-started.md # Setup guide
|
|
1136
|
+
├── adding-entity.md # How to add entities
|
|
1137
|
+
├── testing.md # Testing guide
|
|
1138
|
+
└── contributing.md # Contribution guide
|
|
1139
|
+
```text
|
|
1140
|
+
|
|
1141
|
+
---
|
|
1142
|
+
|
|
1143
|
+
## Summary Checklist
|
|
1144
|
+
|
|
1145
|
+
Before considering documentation complete:
|
|
1146
|
+
|
|
1147
|
+
- [ ] All exports have comprehensive JSDoc
|
|
1148
|
+
- [ ] API endpoints have OpenAPI documentation
|
|
1149
|
+
- [ ] Complex components have README files
|
|
1150
|
+
- [ ] Architecture decisions documented (ADRs)
|
|
1151
|
+
- [ ] Diagrams for complex flows
|
|
1152
|
+
- [ ] CHANGELOG updated
|
|
1153
|
+
- [ ] All examples work and are tested
|
|
1154
|
+
- [ ] All documentation in English
|
|
1155
|
+
- [ ] No broken links
|
|
1156
|
+
|
|
1157
|
+
---
|
|
1158
|
+
|
|
1159
|
+
**Documentation is not optional. Undocumented code will be rejected in code review.**
|
|
1160
|
+
|