feat: Full petmaster CRM with NestJS API and React frontend
- Client management (CRUD with JSONB custom fields) - Pet profiles - Service catalog with per-client pricing - Booking calendar with recurring appointments - Invoicing with Stripe integration - Real-time messaging (WebSocket) - Self-booking portal - Staff assignment - Docker multi-stage builds - Prisma schema + seed
This commit is contained in:
@@ -0,0 +1,162 @@
|
||||
model Client {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
firstName String
|
||||
lastName String
|
||||
email String @unique
|
||||
phone String?
|
||||
address String?
|
||||
notes String? @default("")
|
||||
customFields Json?
|
||||
isActive Boolean @default(true)
|
||||
|
||||
pets Pet[]
|
||||
bookings Booking[]
|
||||
invoices Invoice[]
|
||||
messages Message[] @relation("ClientMessages")
|
||||
|
||||
@@map("clients")
|
||||
}
|
||||
|
||||
model Pet {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
name String
|
||||
species String
|
||||
breed String?
|
||||
age Int?
|
||||
weight String? // e.g. "55 lbs"
|
||||
color String?
|
||||
tags String[] @default([])
|
||||
notes String? @default("")
|
||||
customFields Json?
|
||||
clientId String
|
||||
client Client @relation(fields: [clientId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("pets")
|
||||
}
|
||||
|
||||
model Service {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
name String
|
||||
description String @default("")
|
||||
duration Int // minutes
|
||||
basePrice Float // dollars
|
||||
|
||||
perClientPricing ClientPricing[]
|
||||
|
||||
@@map("services")
|
||||
}
|
||||
|
||||
model ClientPricing {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
price Float
|
||||
discountType String @default("none") // none, percentage, flat
|
||||
discountValue Float @default(0)
|
||||
|
||||
serviceId String
|
||||
service Service @relation(fields: [serviceId], references: [id], onDelete: Cascade)
|
||||
clientId String
|
||||
client Client @relation(fields: [clientId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([serviceId, clientId])
|
||||
@@map("client_pricing")
|
||||
}
|
||||
|
||||
model Booking {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
startAt DateTime
|
||||
endAt DateTime
|
||||
status BookingStatus @default(scheduled)
|
||||
notes String? @default("")
|
||||
customFields Json?
|
||||
|
||||
clientId String
|
||||
client Client @relation(fields: [clientId], references: [id])
|
||||
serviceId String
|
||||
service Service @relation(fields: [serviceId], references: [id])
|
||||
assignedStaff String?
|
||||
priceOverride Float?
|
||||
petId String?
|
||||
pet Pet? @relation(fields: [petId], references: [id])
|
||||
invoice Invoice?
|
||||
|
||||
recurringRule Json? // { interval: "weekly" | "biweekly" | "monthly", count: Int, endDate: DateTime? }
|
||||
|
||||
@@map("bookings")
|
||||
}
|
||||
|
||||
enum BookingStatus {
|
||||
scheduled
|
||||
confirmed
|
||||
in_progress
|
||||
completed
|
||||
cancelled
|
||||
}
|
||||
|
||||
model Invoice {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
invoiceNumber String @unique
|
||||
dueDate DateTime
|
||||
status InvoiceStatus @default(draft)
|
||||
stripePaymentIntentId String?
|
||||
subtotal Float @default(0)
|
||||
tax Float @default(0)
|
||||
total Float @default(0)
|
||||
notes String? @default("")
|
||||
|
||||
clientId String
|
||||
client Client @relation(fields: [clientId], references: [id])
|
||||
bookingId String?
|
||||
booking Booking? @relation(fields: [bookingId], references: [id])
|
||||
|
||||
items InvoiceItem[]
|
||||
|
||||
@@map("invoices")
|
||||
}
|
||||
|
||||
enum InvoiceStatus {
|
||||
draft
|
||||
sent
|
||||
paid
|
||||
overdue
|
||||
cancelled
|
||||
}
|
||||
|
||||
model InvoiceItem {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
description String
|
||||
quantity Int @default(1)
|
||||
unitPrice Float
|
||||
amount Float
|
||||
|
||||
invoiceId String
|
||||
invoice Invoice @relation(fields: [invoiceId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("invoice_items")
|
||||
}
|
||||
|
||||
model Message {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
readAt DateTime?
|
||||
content String
|
||||
isFromStaff Boolean @default(false)
|
||||
|
||||
clientId String
|
||||
client Client @relation("ClientMessages", fields: [clientId], references: [id])
|
||||
staffId String // staff member identifier
|
||||
|
||||
@@map("messages")
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
// Create default services
|
||||
const services = [
|
||||
{ name: 'Full Groom', description: 'Complete bath, haircut, nail trim', duration: 90, basePrice: 75 },
|
||||
{ name: 'Bath & Brush', description: 'Thorough bath with brushing', duration: 45, basePrice: 45 },
|
||||
{ name: 'Nail Trim', description: 'Quick nail clipping', duration: 15, basePrice: 15 },
|
||||
{ name: 'Dog Walking', description: '30 minute supervised walk', duration: 30, basePrice: 25 },
|
||||
{ name: 'Boarding (Standard)', description: 'Overnight boarding with feeding', duration: 1440, basePrice: 55 },
|
||||
{ name: 'Drop-in Visit', description: '20 min play/walk visit', duration: 20, basePrice: 30 },
|
||||
];
|
||||
|
||||
for (const svc of services) {
|
||||
await prisma.service.upsert({
|
||||
where: { name: svc.name },
|
||||
update: svc,
|
||||
create: svc,
|
||||
});
|
||||
}
|
||||
|
||||
console.log('Seed completed: default services created');
|
||||
}
|
||||
|
||||
main().catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
}).finally(async () => {
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
Reference in New Issue
Block a user