phos 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.
Files changed (116) hide show
  1. package/.eslintignore +3 -0
  2. package/AGENTS.md +172 -0
  3. package/CHANGELOG.md +184 -0
  4. package/LICENSE +21 -0
  5. package/README.md +279 -0
  6. package/bun.lock +125 -0
  7. package/dist/cli.d.ts +3 -0
  8. package/dist/cli.d.ts.map +1 -0
  9. package/dist/cli.js +255 -0
  10. package/dist/cli.js.map +1 -0
  11. package/dist/generators/backends/elysia.d.ts +3 -0
  12. package/dist/generators/backends/elysia.d.ts.map +1 -0
  13. package/dist/generators/backends/elysia.js +135 -0
  14. package/dist/generators/backends/elysia.js.map +1 -0
  15. package/dist/generators/backends/fastapi.d.ts +3 -0
  16. package/dist/generators/backends/fastapi.d.ts.map +1 -0
  17. package/dist/generators/backends/fastapi.js +158 -0
  18. package/dist/generators/backends/fastapi.js.map +1 -0
  19. package/dist/generators/frontends/astro.d.ts +3 -0
  20. package/dist/generators/frontends/astro.d.ts.map +1 -0
  21. package/dist/generators/frontends/astro.js +303 -0
  22. package/dist/generators/frontends/astro.js.map +1 -0
  23. package/dist/generators/frontends/nextjs.d.ts +3 -0
  24. package/dist/generators/frontends/nextjs.d.ts.map +1 -0
  25. package/dist/generators/frontends/nextjs.js +274 -0
  26. package/dist/generators/frontends/nextjs.js.map +1 -0
  27. package/dist/generators/frontends/svelte.d.ts +3 -0
  28. package/dist/generators/frontends/svelte.d.ts.map +1 -0
  29. package/dist/generators/frontends/svelte.js +324 -0
  30. package/dist/generators/frontends/svelte.js.map +1 -0
  31. package/dist/generators/monorepo.d.ts +3 -0
  32. package/dist/generators/monorepo.d.ts.map +1 -0
  33. package/dist/generators/monorepo.js +320 -0
  34. package/dist/generators/monorepo.js.map +1 -0
  35. package/dist/generators/single.d.ts +3 -0
  36. package/dist/generators/single.d.ts.map +1 -0
  37. package/dist/generators/single.js +229 -0
  38. package/dist/generators/single.js.map +1 -0
  39. package/dist/utils/helpers.d.ts +38 -0
  40. package/dist/utils/helpers.d.ts.map +1 -0
  41. package/dist/utils/helpers.js +109 -0
  42. package/dist/utils/helpers.js.map +1 -0
  43. package/package.json +46 -0
  44. package/src/cli.ts +500 -0
  45. package/src/generators/backends/elysia.ts +45 -0
  46. package/src/generators/backends/fastapi.ts +71 -0
  47. package/src/generators/frontends/astro.ts +37 -0
  48. package/src/generators/frontends/nextjs.ts +37 -0
  49. package/src/generators/frontends/svelte.ts +38 -0
  50. package/src/generators/monorepo.ts +529 -0
  51. package/src/generators/single.ts +465 -0
  52. package/src/templates/backend/elysia/README.md +15 -0
  53. package/src/templates/backend/elysia/package.json +26 -0
  54. package/src/templates/backend/elysia/src/api/user_api.ts +0 -0
  55. package/src/templates/backend/elysia/src/db.ts +17 -0
  56. package/src/templates/backend/elysia/src/index.ts +68 -0
  57. package/src/templates/backend/elysia/src/service/user_service.ts +0 -0
  58. package/src/templates/backend/elysia/src/sql/user_sql.ts +0 -0
  59. package/src/templates/backend/elysia/src/types/user_type.ts +0 -0
  60. package/src/templates/backend/elysia/tsconfig.json +103 -0
  61. package/src/templates/backend/fastapi/.pylintrc +2 -0
  62. package/src/templates/backend/fastapi/README.md +33 -0
  63. package/src/templates/backend/fastapi/pyproject.toml +9 -0
  64. package/src/templates/backend/fastapi/pyproject_prettier.toml +20 -0
  65. package/src/templates/backend/fastapi/requirements.txt +15 -0
  66. package/src/templates/backend/fastapi/setup.sh +23 -0
  67. package/src/templates/backend/fastapi/src/api/user_api.py +0 -0
  68. package/src/templates/backend/fastapi/src/db.py +31 -0
  69. package/src/templates/backend/fastapi/src/main.py +53 -0
  70. package/src/templates/backend/fastapi/src/service/user_service.py +0 -0
  71. package/src/templates/backend/fastapi/src/sql/user_sql.py +0 -0
  72. package/src/templates/backend/fastapi/src/types/user_type.py +0 -0
  73. package/src/templates/frontend/astro/README.md +46 -0
  74. package/src/templates/frontend/astro/astro.config.mjs +5 -0
  75. package/src/templates/frontend/astro/package.json +28 -0
  76. package/src/templates/frontend/astro/public/favicon.ico +0 -0
  77. package/src/templates/frontend/astro/public/favicon.svg +9 -0
  78. package/src/templates/frontend/astro/src/assets/astro.svg +1 -0
  79. package/src/templates/frontend/astro/src/assets/background.svg +1 -0
  80. package/src/templates/frontend/astro/src/components/Welcome.astro +5 -0
  81. package/src/templates/frontend/astro/src/layouts/Layout.astro +23 -0
  82. package/src/templates/frontend/astro/src/pages/index.astro +8 -0
  83. package/src/templates/frontend/astro/tsconfig.json +5 -0
  84. package/src/templates/frontend/nextjs/README.md +36 -0
  85. package/src/templates/frontend/nextjs/app/favicon.ico +0 -0
  86. package/src/templates/frontend/nextjs/app/globals.css +26 -0
  87. package/src/templates/frontend/nextjs/app/layout.tsx +34 -0
  88. package/src/templates/frontend/nextjs/app/page.tsx +16 -0
  89. package/src/templates/frontend/nextjs/eslint.config.mjs +18 -0
  90. package/src/templates/frontend/nextjs/next.config.ts +7 -0
  91. package/src/templates/frontend/nextjs/package.json +28 -0
  92. package/src/templates/frontend/nextjs/postcss.config.mjs +7 -0
  93. package/src/templates/frontend/nextjs/public/file.svg +1 -0
  94. package/src/templates/frontend/nextjs/public/globe.svg +1 -0
  95. package/src/templates/frontend/nextjs/public/next.svg +1 -0
  96. package/src/templates/frontend/nextjs/public/vercel.svg +1 -0
  97. package/src/templates/frontend/nextjs/public/window.svg +1 -0
  98. package/src/templates/frontend/nextjs/tsconfig.json +34 -0
  99. package/src/templates/frontend/svelte/.prettierignore +9 -0
  100. package/src/templates/frontend/svelte/.prettierrc +19 -0
  101. package/src/templates/frontend/svelte/README.md +42 -0
  102. package/src/templates/frontend/svelte/eslint.config.js +39 -0
  103. package/src/templates/frontend/svelte/package.json +39 -0
  104. package/src/templates/frontend/svelte/src/app.d.ts +13 -0
  105. package/src/templates/frontend/svelte/src/app.html +11 -0
  106. package/src/templates/frontend/svelte/src/lib/assets/favicon.svg +1 -0
  107. package/src/templates/frontend/svelte/src/lib/index.ts +1 -0
  108. package/src/templates/frontend/svelte/src/routes/+layout.svelte +9 -0
  109. package/src/templates/frontend/svelte/src/routes/+page.svelte +2 -0
  110. package/src/templates/frontend/svelte/src/routes/layout.css +2 -0
  111. package/src/templates/frontend/svelte/static/robots.txt +3 -0
  112. package/src/templates/frontend/svelte/svelte.config.js +13 -0
  113. package/src/templates/frontend/svelte/tsconfig.json +20 -0
  114. package/src/templates/frontend/svelte/vite.config.ts +5 -0
  115. package/src/utils/helpers.ts +198 -0
  116. package/tsconfig.json +24 -0
@@ -0,0 +1,529 @@
1
+ import {
2
+ createDirectory,
3
+ writeFile,
4
+ getProjectPath,
5
+ logStep,
6
+ logSuccess,
7
+ logInfo,
8
+ initializeGit,
9
+ capitalize,
10
+ getPackageManagerRunCmd,
11
+ getPackageManagerInstallCmd,
12
+ type GeneratorConfig,
13
+ } from "@/utils/helpers.js";
14
+ import { generateElysiaBackend } from "@/generators/backends/elysia.js";
15
+ import { generateFastAPIBackend } from "@/generators/backends/fastapi.js";
16
+ import { generateAstroFrontend } from "@/generators/frontends/astro.js";
17
+ import { generateSvelteFrontend } from "@/generators/frontends/svelte.js";
18
+ import { generateNextJSFrontend } from "@/generators/frontends/nextjs.js";
19
+
20
+ export async function generateMonorepo(config: GeneratorConfig): Promise<void> {
21
+ const projectPath = getProjectPath(config.projectName);
22
+
23
+ logStep(`Creating monorepo at ${projectPath}`);
24
+ await createDirectory(projectPath);
25
+
26
+ const backendPath = `${projectPath}/${capitalize(config.projectName)}_Backend`;
27
+ const frontendPath = `${projectPath}/${capitalize(config.projectName)}_Frontend`;
28
+ const docsPath = `${projectPath}/Docs`;
29
+
30
+ await createDirectory(backendPath);
31
+ await createDirectory(frontendPath);
32
+ await createDirectory(docsPath);
33
+
34
+ await generateGitIgnore(projectPath);
35
+ await generateReadme(projectPath, config);
36
+ await generateAgentsMd(projectPath, config);
37
+ await generateLicense(projectPath, config);
38
+ await generateEnvExample(projectPath);
39
+
40
+ switch (config.backend?.framework) {
41
+ case "elysia":
42
+ await generateElysiaBackend(backendPath, config);
43
+ break;
44
+ case "fastapi":
45
+ await generateFastAPIBackend(backendPath, config);
46
+ break;
47
+ }
48
+
49
+ switch (config.frontend?.framework) {
50
+ case "astro":
51
+ await generateAstroFrontend(frontendPath, config);
52
+ break;
53
+ case "svelte":
54
+ await generateSvelteFrontend(frontendPath, config);
55
+ break;
56
+ case "nextjs":
57
+ await generateNextJSFrontend(frontendPath, config);
58
+ break;
59
+ }
60
+
61
+ await createDirectory(`${docsPath}/Feature`);
62
+ await createDirectory(`${docsPath}/DatabaseSetup`);
63
+ await generateSchemaDocs(docsPath, config);
64
+
65
+ const backendName = `${capitalize(config.projectName)}_Backend`;
66
+ const frontendName = `${capitalize(config.projectName)}_Frontend`;
67
+
68
+ logSuccess(`Backend created at ${backendName}`);
69
+ logSuccess(`Frontend created at ${frontendName}`);
70
+ logSuccess("Docs folder created");
71
+
72
+ if (config.git) {
73
+ await initializeGit(projectPath);
74
+ }
75
+
76
+ const backendInstallCmd = getPackageManagerInstallCmd(config.backend?.packageManager || "npm");
77
+ const backendRunCmd = getPackageManagerRunCmd(config.backend?.packageManager || "npm", "dev");
78
+ const frontendInstallCmd = getPackageManagerInstallCmd(config.frontend?.packageManager || "npm");
79
+ const frontendRunCmd = getPackageManagerRunCmd(config.frontend?.packageManager || "npm", "dev");
80
+
81
+ logInfo("\n📦 Next steps:");
82
+ logInfo(` cd ${config.projectName}`);
83
+ logInfo(` # Backend`);
84
+ logInfo(` cd ${backendName} && ${backendInstallCmd} && ${backendRunCmd}`);
85
+ logInfo(` # Frontend`);
86
+ logInfo(` cd ${frontendName} && ${frontendInstallCmd} && ${frontendRunCmd}`);
87
+ }
88
+
89
+ async function generateGitIgnore(projectPath: string): Promise<void> {
90
+ const content = `# Dependencies
91
+ node_modules/
92
+ .pnp
93
+ .pnp.js
94
+
95
+ # Testing
96
+ coverage/
97
+ *.lcov
98
+
99
+ # Next.js
100
+ .next/
101
+ out/
102
+
103
+ # Production
104
+ build/
105
+ dist/
106
+
107
+ # Misc
108
+ .DS_Store
109
+ *.pem
110
+
111
+ # Debug
112
+ npm-debug.log*
113
+ yarn-debug.log*
114
+ yarn-error.log*
115
+
116
+ # Local env files
117
+ .env
118
+ .env.local
119
+ .env.development.local
120
+ .env.test.local
121
+ .env.production.local
122
+
123
+ # Vercel
124
+ .vercel
125
+
126
+ # TypeScript
127
+ *.tsbuildinfo
128
+
129
+ # IDE
130
+ .idea/
131
+ .vscode/
132
+ *.swp
133
+ *.swo
134
+ *~
135
+ `;
136
+
137
+ await writeFile(`${projectPath}/.gitignore`, content);
138
+ logSuccess(".gitignore created");
139
+ }
140
+
141
+ async function generateReadme(projectPath: string, config: GeneratorConfig): Promise<void> {
142
+ const backendName = `${capitalize(config.projectName)}_Backend`;
143
+ const frontendName = `${capitalize(config.projectName)}_Frontend`;
144
+
145
+ const content = `# ${config.projectName}
146
+
147
+ This project was generated by [Phos](https://github.com/yourusername/phos).
148
+
149
+ ## Project Structure
150
+
151
+ \`\`\`
152
+ .
153
+ ├── ${backendName}/ # ${config.backend?.framework} backend
154
+ ├── ${frontendName}/ # ${config.frontend?.framework} frontend
155
+ ├── Docs/ # Documentation
156
+ ├── AGENTS.md # Agent guidelines
157
+ ├── LICENSE # License file
158
+ └── env.example # Environment variables template
159
+ \`\`\`
160
+
161
+ ## Getting Started
162
+
163
+ ### Backend
164
+
165
+ \`\`\`bash
166
+ cd ${backendName}
167
+ ${config.backend?.packageManager} install
168
+ ${config.backend?.packageManager} run dev
169
+ \`\`\`
170
+
171
+ ### Frontend
172
+
173
+ \`\`\`bash
174
+ cd ${frontendName}
175
+ ${config.frontend?.packageManager} install
176
+ ${config.frontend?.packageManager} run dev
177
+ \`\`\`
178
+
179
+ ## Available Scripts
180
+
181
+ - \`${config.frontend?.packageManager} run dev\` - Start development servers
182
+ - \`${config.frontend?.packageManager} run build\` - Build for production
183
+ - \`${config.frontend?.packageManager} run lint\` - Run ESLint
184
+ - \`${config.frontend?.packageManager} run format\` - Format code with Prettier
185
+
186
+ ## Tech Stack
187
+
188
+ ### Backend
189
+ - Framework: ${config.backend?.framework}
190
+ - Package Manager: ${config.backend?.packageManager}
191
+ - TypeScript: ${config.backend?.typescript ? "Yes" : "No"}
192
+ - ESLint: ${config.backend?.eslint ? "Yes" : "No"}
193
+ - Prettier: ${config.backend?.prettier ? "Yes" : "No"}
194
+
195
+ ### Frontend
196
+ - Framework: ${config.frontend?.framework}
197
+ - Package Manager: ${config.frontend?.packageManager}
198
+ - TypeScript: ${config.frontend?.typescript ? "Yes" : "No"}
199
+ - ESLint: ${config.frontend?.eslint ? "Yes" : "No"}
200
+ - Prettier: ${config.frontend?.prettier ? "Yes" : "No"}
201
+ - CSS Framework: ${config.frontend?.cssFramework}
202
+ - UI Components: ${config.frontend?.uiComponents}
203
+ - Testing: ${config.frontend?.testing}
204
+ `;
205
+
206
+ await writeFile(`${projectPath}/README.md`, content);
207
+ logSuccess("README.md created");
208
+ }
209
+
210
+ async function generateAgentsMd(projectPath: string, config: GeneratorConfig): Promise<void> {
211
+ const projectName = config.projectName;
212
+ const capitalizedProjectName = capitalize(config.projectName);
213
+ const backendName = `${capitalizedProjectName}_Backend`;
214
+ const frontendName = `${capitalizedProjectName}_Frontend`;
215
+
216
+ const content = `# AGENTS Guidelines for This Repository
217
+
218
+ ## Project Name: ${projectName}
219
+
220
+ This project was generated by [Phos](https://github.com/yourusername/phos).
221
+
222
+ ### Core Features:
223
+
224
+ 1. **${config.frontend?.framework || "Next.js"} Frontend** - Modern web framework
225
+ 2. **${config.backend?.framework || "Elysia"} Backend** - Server-side application
226
+ 3. **Monorepo Structure** - Organized workspace with separate backend and frontend
227
+
228
+ ### Technology Stack:
229
+
230
+ - **Frontend**: ${config.frontend?.framework || "Next.js"}
231
+ - **Backend**: ${config.backend?.framework || "Elysia"}
232
+ - **Package Manager**: ${config.frontend?.packageManager || "npm"}
233
+ - **TypeScript**: ${config.frontend?.typescript ? "Enabled" : "Disabled"}
234
+ - **ESLint**: ${config.frontend?.eslint ? "Enabled" : "Disabled"}
235
+ - **Prettier**: ${config.frontend?.prettier ? "Enabled" : "Disabled"}
236
+ - **CSS Framework**: ${config.frontend?.cssFramework || "Tailwind CSS"}
237
+
238
+ ## 1. Development Workflow
239
+
240
+ ### Project Structure
241
+
242
+ \`\`\`
243
+ ${projectName}/
244
+ ├── ${backendName}/ # Backend application
245
+ ├── ${frontendName}/ # Frontend application
246
+ ├── Docs/ # Documentation
247
+ ├── AGENTS.md # This file
248
+ ├── LICENSE # License
249
+ ├── README.md # Project README
250
+ └── env.example # Environment variables template
251
+ \`\`\`
252
+
253
+ ### Running the Project
254
+
255
+ #### Backend
256
+ \`\`\`bash
257
+ cd ${backendName}
258
+ ${config.backend?.packageManager || "npm"} install
259
+ ${config.backend?.packageManager || "npm"} run dev
260
+ \`\`\`
261
+
262
+ #### Frontend
263
+ \`\`\`bash
264
+ cd ${frontendName}
265
+ ${config.frontend?.packageManager || "npm"} install
266
+ ${config.frontend?.packageManager || "npm"} run dev
267
+ \`\`\`
268
+
269
+ ## 2. Architecture
270
+
271
+ ### Backend
272
+ - Framework: ${config.backend?.framework || "Elysia"}
273
+ - Language: ${config.backend?.framework === "fastapi" ? "Python" : "TypeScript"}
274
+ - Package Manager: ${config.backend?.packageManager || "npm"}
275
+
276
+ ### Frontend
277
+ - Framework: ${config.frontend?.framework || "Next.js"}
278
+ - Language: JavaScript/TypeScript
279
+ - Package Manager: ${config.frontend?.packageManager || "npm"}
280
+ - CSS Framework: ${config.frontend?.cssFramework || "Tailwind CSS"}
281
+ - UI Components: ${config.frontend?.uiComponents || "None"}
282
+
283
+ ## 3. Coding Conventions
284
+
285
+ ### ${config.frontend?.framework || "Next.js"}
286
+
287
+ ${
288
+ config.frontend?.framework === "astro"
289
+ ? `
290
+ - Use Astro component syntax
291
+ - Follow Astro best practices
292
+ - Use TypeScript if enabled
293
+ `
294
+ : config.frontend?.framework === "svelte"
295
+ ? `
296
+ - Use Svelte component syntax
297
+ - Follow Svelte best practices
298
+ - Use TypeScript if enabled
299
+ `
300
+ : `
301
+ - Use Next.js conventions
302
+ - Use App Router for new features
303
+ - Use TypeScript if enabled
304
+ `
305
+ }
306
+
307
+ ### ${config.backend?.framework || "Elysia"}
308
+
309
+ ${
310
+ config.backend?.framework === "elysia"
311
+ ? `
312
+ - Use Elysia patterns
313
+ - Follow Bun conventions
314
+ - Use TypeScript if enabled
315
+ `
316
+ : `
317
+ - Use FastAPI patterns
318
+ - Follow Python PEP 8 guidelines
319
+ - Use type hints
320
+ `
321
+ }
322
+
323
+ ## 4. Available Scripts
324
+
325
+ ### Root Level
326
+ - \`${config.frontend?.packageManager || "npm"} run dev\` - Start both dev servers
327
+ - \`${config.frontend?.packageManager || "npm"} run build\` - Build both apps
328
+ - \`${config.frontend?.packageManager || "npm"} run lint\` - Run ESLint
329
+ - \`${config.frontend?.packageManager || "npm"} run format\` - Format code
330
+
331
+ ## 5. Documentation
332
+
333
+ Check the \`Docs/\` folder for:
334
+ - Feature documentation
335
+ - Database setup scripts
336
+ - Schema documentation
337
+ - SQL queries
338
+ `;
339
+
340
+ await writeFile(`${projectPath}/AGENTS.md`, content);
341
+ logSuccess("AGENTS.md created");
342
+ }
343
+
344
+ async function generateLicense(projectPath: string, config: GeneratorConfig): Promise<void> {
345
+ const content = `MIT License
346
+
347
+ Copyright (c) ${new Date().getFullYear()} ${config.projectName}
348
+
349
+ Permission is hereby granted, free of charge, to any person obtaining a copy
350
+ of this software and associated documentation files (the "Software"), to deal
351
+ in the Software without restriction, including without limitation the rights
352
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
353
+ copies of the Software, and to permit persons to whom the Software is
354
+ furnished to do so, subject to the following conditions:
355
+
356
+ The above copyright notice and this permission notice shall be included in all
357
+ copies or substantial portions of the Software.
358
+
359
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
360
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
361
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
362
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
363
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
364
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
365
+ SOFTWARE.
366
+ `;
367
+
368
+ await writeFile(`${projectPath}/LICENSE`, content);
369
+ logSuccess("LICENSE created");
370
+ }
371
+
372
+ async function generateEnvExample(projectPath: string): Promise<void> {
373
+ const content = `# Database
374
+ DB_HOST=localhost
375
+ DB_NAME=your_db_name
376
+ DB_USER=postgres
377
+ DB_PASSWORD=postgres
378
+ DB_PORT=5433
379
+
380
+ # URLs
381
+ FRONTEND_BASE_URL=http://localhost:4200
382
+ BACKEND_BASE_URL=http://localhost:4100
383
+
384
+ # JWT Configuration for rest API
385
+ JWT_SECRET=your-super-secret-jwt-key-change-in-production
386
+ JWT_EXPIRES_IN=60m
387
+
388
+ # Encryption
389
+ ENCRYPTION_SALT=your-super-secret-salt-change-in-production
390
+
391
+ # API Keys
392
+ X_API_KEY=1234
393
+ `;
394
+
395
+ await writeFile(`${projectPath}/env.example`, content);
396
+ logSuccess("env.example created");
397
+ }
398
+
399
+ async function generateSchemaDocs(docsPath: string, config: GeneratorConfig): Promise<void> {
400
+ const projectName = config.projectName;
401
+ const content = `# ${projectName} Database Schema
402
+
403
+ ## Table of Contents
404
+
405
+ - [${projectName} Database Schema](#${projectName.toLowerCase()}-database-schema)
406
+ - [Table of Contents](#table-of-contents)
407
+ - [Overview](#overview)
408
+ - [Core Entities](#core-entities)
409
+ - [Entity Name](#entity-name)
410
+ - [Entity Relationships](#entity-relationships)
411
+ - [SQL Schema](#sql-schema)
412
+ - [Create Tables](#create-tables)
413
+ - [Sample Data](#sample-data)
414
+ - [Data Types Notes](#data-types-notes)
415
+ - [Migration Notes](#migration-notes)
416
+
417
+ ---
418
+
419
+ ## Overview
420
+
421
+ This document describes the complete database schema for ${projectName}, including all entities, relationships, and sample data.
422
+
423
+ ---
424
+
425
+ ## Core Entities
426
+
427
+ ### Entity Name
428
+
429
+ | Column | Type | Nullable | Description |
430
+ | ----------- | -------- | -------- | ---------------------------------- |
431
+ | id | int | No | Primary key, auto-incremented ID |
432
+ | uuid | string | No | Unique identifier |
433
+ | column_name | str | Yes/No | Description of column |
434
+ | created_at | datetime | No | Record creation timestamp (UTC) |
435
+ | updated_at | datetime | Yes | Record last update timestamp (UTC) |
436
+
437
+ ---
438
+
439
+ ## Entity Relationships
440
+
441
+ \`\`\`
442
+ table1 (1) ──── (many) table2
443
+ table3 (many) ──── (1) table4
444
+ \`\`\`
445
+
446
+ ---
447
+
448
+ ## SQL Schema
449
+
450
+ ### Create Tables
451
+
452
+ For PostgreSQL deployment, use the following schema:
453
+
454
+ \`\`\`sql
455
+ -- Drop tables if they exist (for clean setup)
456
+ DROP TABLE IF EXISTS child_table;
457
+ DROP TABLE IF EXISTS parent_table;
458
+
459
+ -- Parent table
460
+ CREATE TABLE parent_table (
461
+ id SERIAL PRIMARY KEY,
462
+ uuid TEXT NOT NULL UNIQUE,
463
+ name TEXT NOT NULL,
464
+ description TEXT,
465
+ created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
466
+ updated_at TIMESTAMP
467
+ );
468
+
469
+ -- Child table
470
+ CREATE TABLE child_table (
471
+ id TEXT PRIMARY KEY,
472
+ parent_id TEXT NOT NULL,
473
+ content TEXT NOT NULL,
474
+ created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
475
+ updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
476
+ FOREIGN KEY (parent_id) REFERENCES parent_table(uuid)
477
+ );
478
+
479
+ -- Add foreign key constraints if needed
480
+ ALTER TABLE child_table ADD CONSTRAINT fk_child_parent FOREIGN KEY (parent_id) REFERENCES parent_table(uuid);
481
+
482
+ -- Performance indexes
483
+ CREATE INDEX idx_parent_table_uuid ON parent_table(uuid);
484
+ CREATE INDEX idx_child_table_parent_id ON child_table(parent_id);
485
+ CREATE INDEX idx_child_table_created_at ON child_table(created_at);
486
+ \`\`\`
487
+
488
+ ---
489
+
490
+ ## Sample Data
491
+
492
+ \`\`\`sql
493
+ -- Insert sample data for parent table
494
+ INSERT INTO parent_table (uuid, name, description, created_at)
495
+ VALUES ('550e8400-e29b-41d4-a716-446655440000', 'Sample Name', 'Sample description', CURRENT_TIMESTAMP);
496
+
497
+ -- Insert sample data for child table
498
+ INSERT INTO child_table (id, parent_id, content, created_at, updated_at)
499
+ VALUES ('6ba7b810-9dad-11d1-80b4-00c04fd430c8', '550e8400-e29b-41d4-a716-446655440000', 'Sample content', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
500
+ \`\`\`
501
+
502
+ ---
503
+
504
+ ## Data Types Notes
505
+
506
+ - **UUID**: Stored as TEXT for simplicity
507
+ - **Arrays**: Stored as native PostgreSQL arrays (e.g., text[])
508
+ - **JSON**: Stored as JSONB for PostgreSQL (or TEXT for SQLite)
509
+ - **Boolean**: Stored as BOOLEAN for PostgreSQL (or INTEGER 0/1 for SQLite)
510
+ - **Decimal**: Stored as DECIMAL for precision calculations
511
+ - **Datetime**: Stored as TIMESTAMP with CURRENT_TIMESTAMP defaults
512
+
513
+ ---
514
+
515
+ ## Migration Notes
516
+
517
+ When deploying to production:
518
+
519
+ 1. Consider using PostgreSQL for better JSON support and performance
520
+ 2. Add proper UUID generation in application code
521
+ 3. Implement database migrations for schema changes
522
+ 4. Add database constraints and triggers as needed
523
+ 5. Run \`ALTER TABLE\` statements for schema additions
524
+ 6. Test migrations on staging environment before production
525
+ `;
526
+
527
+ await writeFile(`${docsPath}/Schema.md`, content);
528
+ logSuccess("Schema.md created");
529
+ }