@intentsolutionsio/fullstack-starter-pack 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.
@@ -0,0 +1,582 @@
1
+ ---
2
+ name: prisma-schema-gen
3
+ description: Generate Prisma schema from natural language descriptions
4
+ shortcut: psg
5
+ category: database
6
+ difficulty: beginner
7
+ estimated_time: 3-5 minutes
8
+ ---
9
+ # Prisma Schema Generator
10
+
11
+ Generates complete Prisma schema files from natural language descriptions, including models, relationships, indexes, and validation.
12
+
13
+ ## What This Command Does
14
+
15
+ **Generated Schema:**
16
+ - Prisma models with fields
17
+ - Relationships (one-to-one, one-to-many, many-to-many)
18
+ - Indexes and unique constraints
19
+ - Default values and validators
20
+ - Database-specific configuration
21
+ - Example queries
22
+
23
+ **Output:** Complete `schema.prisma` file ready for migration
24
+
25
+ **Time:** 3-5 minutes
26
+
27
+ ---
28
+
29
+ ## Usage
30
+
31
+ ```bash
32
+ # Generate schema from description
33
+ /prisma-schema-gen "Blog with users, posts, and comments"
34
+
35
+ # Shortcut
36
+ /psg "E-commerce with products, orders, and customers"
37
+
38
+ # Specify database
39
+ /psg "Task management app" --database postgresql
40
+
41
+ # With specific relationships
42
+ /psg "Social network with users, posts, likes, and follows"
43
+ ```
44
+
45
+ ---
46
+
47
+ ## Example Output
48
+
49
+ **Input:**
50
+ ```
51
+ /psg "Blog platform with users, posts, comments, and tags"
52
+ ```
53
+
54
+ **Generated schema.prisma:**
55
+
56
+ ```prisma
57
+ // This is your Prisma schema file
58
+
59
+ generator client {
60
+ provider = "prisma-client-js"
61
+ }
62
+
63
+ datasource db {
64
+ provider = "postgresql"
65
+ url = env("DATABASE_URL")
66
+ }
67
+
68
+ model User {
69
+ id String @id @default(uuid())
70
+ email String @unique
71
+ name String
72
+ password String
73
+ bio String?
74
+ avatar String?
75
+ posts Post[]
76
+ comments Comment[]
77
+ createdAt DateTime @default(now())
78
+ updatedAt DateTime @updatedAt
79
+
80
+ @@index([email])
81
+ @@map("users")
82
+ }
83
+
84
+ model Post {
85
+ id String @id @default(uuid())
86
+ title String
87
+ slug String @unique
88
+ content String @db.Text
89
+ excerpt String?
90
+ published Boolean @default(false)
91
+ publishedAt DateTime?
92
+ viewCount Int @default(0)
93
+ authorId String
94
+ author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
95
+ comments Comment[]
96
+ tags PostTag[]
97
+ createdAt DateTime @default(now())
98
+ updatedAt DateTime @updatedAt
99
+
100
+ @@index([authorId])
101
+ @@index([slug])
102
+ @@index([published, publishedAt])
103
+ @@map("posts")
104
+ }
105
+
106
+ model Comment {
107
+ id String @id @default(uuid())
108
+ content String @db.Text
109
+ postId String
110
+ post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
111
+ authorId String
112
+ author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
113
+ createdAt DateTime @default(now())
114
+ updatedAt DateTime @updatedAt
115
+
116
+ @@index([postId])
117
+ @@index([authorId])
118
+ @@map("comments")
119
+ }
120
+
121
+ model Tag {
122
+ id String @id @default(uuid())
123
+ name String @unique
124
+ slug String @unique
125
+ posts PostTag[]
126
+
127
+ @@index([slug])
128
+ @@map("tags")
129
+ }
130
+
131
+ // Junction table for many-to-many
132
+ model PostTag {
133
+ id String @id @default(uuid())
134
+ postId String
135
+ post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
136
+ tagId String
137
+ tag Tag @relation(fields: [tagId], references: [id], onDelete: Cascade)
138
+
139
+ @@unique([postId, tagId])
140
+ @@index([postId])
141
+ @@index([tagId])
142
+ @@map("post_tags")
143
+ }
144
+ ```
145
+
146
+ ---
147
+
148
+ ## Generated Files
149
+
150
+ ### **Migrations**
151
+
152
+ ```bash
153
+ # After generating schema, run:
154
+ npx prisma migrate dev --name init
155
+
156
+ # This creates:
157
+ # - migrations/
158
+ # └── 20250110000000_init/
159
+ # └── migration.sql
160
+ ```
161
+
162
+ ### **Example Queries (TypeScript)**
163
+
164
+ ```typescript
165
+ import { PrismaClient } from '@prisma/client'
166
+
167
+ const prisma = new PrismaClient()
168
+
169
+ // Create user
170
+ async function createUser() {
171
+ const user = await prisma.user.create({
172
+ data: {
173
+ email: '[email protected]',
174
+ name: 'John Doe',
175
+ password: 'hashed_password_here'
176
+ }
177
+ })
178
+ return user
179
+ }
180
+
181
+ // Create post with tags
182
+ async function createPost() {
183
+ const post = await prisma.post.create({
184
+ data: {
185
+ title: 'Getting Started with Prisma',
186
+ slug: 'getting-started-with-prisma',
187
+ content: 'Full blog post content...',
188
+ published: true,
189
+ publishedAt: new Date(),
190
+ authorId: 'user-uuid-here',
191
+ tags: {
192
+ create: [
193
+ {
194
+ tag: {
195
+ connectOrCreate: {
196
+ where: { slug: 'prisma' },
197
+ create: { name: 'Prisma', slug: 'prisma' }
198
+ }
199
+ }
200
+ }
201
+ ]
202
+ }
203
+ },
204
+ include: {
205
+ author: true,
206
+ tags: {
207
+ include: {
208
+ tag: true
209
+ }
210
+ }
211
+ }
212
+ })
213
+ return post
214
+ }
215
+
216
+ // Get posts with related data
217
+ async function getPosts() {
218
+ const posts = await prisma.post.findMany({
219
+ where: {
220
+ published: true
221
+ },
222
+ include: {
223
+ author: {
224
+ select: {
225
+ id: true,
226
+ name: true,
227
+ avatar: true
228
+ }
229
+ },
230
+ tags: {
231
+ include: {
232
+ tag: true
233
+ }
234
+ },
235
+ _count: {
236
+ select: {
237
+ comments: true
238
+ }
239
+ }
240
+ },
241
+ orderBy: {
242
+ publishedAt: 'desc'
243
+ },
244
+ take: 10
245
+ })
246
+ return posts
247
+ }
248
+
249
+ // Create comment
250
+ async function createComment() {
251
+ const comment = await prisma.comment.create({
252
+ data: {
253
+ content: 'Great article!',
254
+ postId: 'post-uuid-here',
255
+ authorId: 'user-uuid-here'
256
+ },
257
+ include: {
258
+ author: {
259
+ select: {
260
+ name: true,
261
+ avatar: true
262
+ }
263
+ }
264
+ }
265
+ })
266
+ return comment
267
+ }
268
+
269
+ // Search posts
270
+ async function searchPosts(query: string) {
271
+ const posts = await prisma.post.findMany({
272
+ where: {
273
+ OR: [
274
+ { title: { contains: query, mode: 'insensitive' } },
275
+ { content: { contains: query, mode: 'insensitive' } }
276
+ ],
277
+ published: true
278
+ },
279
+ include: {
280
+ author: true
281
+ }
282
+ })
283
+ return posts
284
+ }
285
+
286
+ // Get post with comments
287
+ async function getPostWithComments(slug: string) {
288
+ const post = await prisma.post.findUnique({
289
+ where: { slug },
290
+ include: {
291
+ author: true,
292
+ comments: {
293
+ include: {
294
+ author: {
295
+ select: {
296
+ name: true,
297
+ avatar: true
298
+ }
299
+ }
300
+ },
301
+ orderBy: {
302
+ createdAt: 'desc'
303
+ }
304
+ },
305
+ tags: {
306
+ include: {
307
+ tag: true
308
+ }
309
+ }
310
+ }
311
+ })
312
+
313
+ if (!post) {
314
+ throw new Error('Post not found')
315
+ }
316
+
317
+ // Increment view count
318
+ await prisma.post.update({
319
+ where: { id: post.id },
320
+ data: { viewCount: { increment: 1 } }
321
+ })
322
+
323
+ return post
324
+ }
325
+
326
+ // Get posts by tag
327
+ async function getPostsByTag(tagSlug: string) {
328
+ const posts = await prisma.post.findMany({
329
+ where: {
330
+ published: true,
331
+ tags: {
332
+ some: {
333
+ tag: {
334
+ slug: tagSlug
335
+ }
336
+ }
337
+ }
338
+ },
339
+ include: {
340
+ author: true,
341
+ tags: {
342
+ include: {
343
+ tag: true
344
+ }
345
+ }
346
+ },
347
+ orderBy: {
348
+ publishedAt: 'desc'
349
+ }
350
+ })
351
+ return posts
352
+ }
353
+ ```
354
+
355
+ ---
356
+
357
+ ## Common Patterns
358
+
359
+ ### **1. E-commerce Schema**
360
+
361
+ ```prisma
362
+ model Customer {
363
+ id String @id @default(uuid())
364
+ email String @unique
365
+ name String
366
+ phone String?
367
+ orders Order[]
368
+ cart Cart?
369
+ }
370
+
371
+ model Product {
372
+ id String @id @default(uuid())
373
+ name String
374
+ description String?
375
+ price Decimal @db.Decimal(10, 2)
376
+ stock Int @default(0)
377
+ orderItems OrderItem[]
378
+ cartItems CartItem[]
379
+ }
380
+
381
+ model Order {
382
+ id String @id @default(uuid())
383
+ customerId String
384
+ customer Customer @relation(fields: [customerId], references: [id])
385
+ items OrderItem[]
386
+ total Decimal @db.Decimal(10, 2)
387
+ status String // 'pending', 'paid', 'shipped', 'delivered'
388
+ createdAt DateTime @default(now())
389
+ }
390
+
391
+ model OrderItem {
392
+ id String @id @default(uuid())
393
+ orderId String
394
+ order Order @relation(fields: [orderId], references: [id])
395
+ productId String
396
+ product Product @relation(fields: [productId], references: [id])
397
+ quantity Int
398
+ price Decimal @db.Decimal(10, 2)
399
+ }
400
+ ```
401
+
402
+ ### **2. Social Network Schema**
403
+
404
+ ```prisma
405
+ model User {
406
+ id String @id @default(uuid())
407
+ username String @unique
408
+ email String @unique
409
+ posts Post[]
410
+ likes Like[]
411
+ following Follow[] @relation("Following")
412
+ followers Follow[] @relation("Followers")
413
+ }
414
+
415
+ model Post {
416
+ id String @id @default(uuid())
417
+ content String
418
+ authorId String
419
+ author User @relation(fields: [authorId], references: [id])
420
+ likes Like[]
421
+ createdAt DateTime @default(now())
422
+ }
423
+
424
+ model Like {
425
+ id String @id @default(uuid())
426
+ userId String
427
+ user User @relation(fields: [userId], references: [id])
428
+ postId String
429
+ post Post @relation(fields: [postId], references: [id])
430
+
431
+ @@unique([userId, postId])
432
+ }
433
+
434
+ model Follow {
435
+ id String @id @default(uuid())
436
+ followerId String
437
+ followingId String
438
+ follower User @relation("Following", fields: [followerId], references: [id])
439
+ following User @relation("Followers", fields: [followingId], references: [id])
440
+
441
+ @@unique([followerId, followingId])
442
+ }
443
+ ```
444
+
445
+ ### **3. Multi-tenant SaaS Schema**
446
+
447
+ ```prisma
448
+ model Organization {
449
+ id String @id @default(uuid())
450
+ name String
451
+ slug String @unique
452
+ members Member[]
453
+ projects Project[]
454
+ }
455
+
456
+ model User {
457
+ id String @id @default(uuid())
458
+ email String @unique
459
+ memberships Member[]
460
+ }
461
+
462
+ model Member {
463
+ id String @id @default(uuid())
464
+ userId String
465
+ user User @relation(fields: [userId], references: [id])
466
+ orgId String
467
+ org Organization @relation(fields: [orgId], references: [id])
468
+ role String // 'owner', 'admin', 'member'
469
+
470
+ @@unique([userId, orgId])
471
+ }
472
+
473
+ model Project {
474
+ id String @id @default(uuid())
475
+ name String
476
+ orgId String
477
+ org Organization @relation(fields: [orgId], references: [id])
478
+ tasks Task[]
479
+ }
480
+
481
+ model Task {
482
+ id String @id @default(uuid())
483
+ title String
484
+ completed Boolean @default(false)
485
+ projectId String
486
+ project Project @relation(fields: [projectId], references: [id])
487
+ }
488
+ ```
489
+
490
+ ---
491
+
492
+ ## Database Support
493
+
494
+ **PostgreSQL:**
495
+ ```prisma
496
+ datasource db {
497
+ provider = "postgresql"
498
+ url = env("DATABASE_URL")
499
+ }
500
+
501
+ // PostgreSQL-specific types
502
+ model Example {
503
+ jsonData Json
504
+ textData String @db.Text
505
+ amount Decimal @db.Decimal(10, 2)
506
+ }
507
+ ```
508
+
509
+ **MySQL:**
510
+ ```prisma
511
+ datasource db {
512
+ provider = "mysql"
513
+ url = env("DATABASE_URL")
514
+ }
515
+ ```
516
+
517
+ **SQLite (Development):**
518
+ ```prisma
519
+ datasource db {
520
+ provider = "sqlite"
521
+ url = "file:./dev.db"
522
+ }
523
+ ```
524
+
525
+ **MongoDB:**
526
+ ```prisma
527
+ datasource db {
528
+ provider = "mongodb"
529
+ url = env("DATABASE_URL")
530
+ }
531
+
532
+ model User {
533
+ id String @id @default(auto()) @map("_id") @db.ObjectId
534
+ email String @unique
535
+ }
536
+ ```
537
+
538
+ ---
539
+
540
+ ## Getting Started
541
+
542
+ **1. Install Prisma:**
543
+ ```bash
544
+ npm install @prisma/client
545
+ npm install -D prisma
546
+ ```
547
+
548
+ **2. Initialize Prisma:**
549
+ ```bash
550
+ npx prisma init
551
+ ```
552
+
553
+ **3. Use generated schema:**
554
+ - Replace `prisma/schema.prisma` with generated content
555
+ - Set `DATABASE_URL` in `.env`
556
+
557
+ **4. Create migration:**
558
+ ```bash
559
+ npx prisma migrate dev --name init
560
+ ```
561
+
562
+ **5. Generate Prisma Client:**
563
+ ```bash
564
+ npx prisma generate
565
+ ```
566
+
567
+ **6. Use in code:**
568
+ ```typescript
569
+ import { PrismaClient } from '@prisma/client'
570
+ const prisma = new PrismaClient()
571
+ ```
572
+
573
+ ---
574
+
575
+ ## Related Commands
576
+
577
+ - `/sql-query-builder` - Generate SQL queries
578
+ - Database Designer (agent) - Schema design review
579
+
580
+ ---
581
+
582
+ **Generate schemas fast. Migrate safely. Query confidently.** ️