Spaces:
Build error
Build error
| // PostgreSQL 16 Schema | |
| // Run: npx prisma migrate dev --name init | |
| generator client { | |
| provider = "prisma-client-js" | |
| } | |
| datasource db { | |
| provider = "postgresql" | |
| url = env("DATABASE_URL") | |
| } | |
| // ββ Users & Auth ββ | |
| model User { | |
| id String .Uuid | |
| email String | |
| emailVerified DateTime? | |
| passwordHash String? // bcrypt/Argon2 β null for OIDC users | |
| fullName String | |
| phone String? | |
| avatarUrl String? | |
| // Multi-role support | |
| roles UserRole[] | |
| // OIDC identities | |
| identities OidcIdentity[] | |
| // Profile type (for account switching) | |
| clientProfile ClientProfile? | |
| vendorProfile VendorProfile? | |
| adminProfile AdminProfile? | |
| // Sessions | |
| sessions Session[] | |
| createdAt DateTime | |
| updatedAt DateTime | |
| deletedAt DateTime? // soft delete for GDPR | |
| @ | |
| @ | |
| } | |
| model UserRole { | |
| id String .Uuid | |
| userId String .Uuid | |
| role Role // CLIENT | VENDOR | ADMIN | |
| isPrimary Boolean | |
| createdAt DateTime | |
| user User | |
| @ | |
| @ | |
| } | |
| enum Role { | |
| CLIENT | |
| VENDOR | |
| ADMIN | |
| } | |
| model OidcIdentity { | |
| id String .Uuid | |
| userId String .Uuid | |
| provider String // google | apple | cognito | keycloak | |
| subject String // OIDC sub claim | |
| idToken String? | |
| accessToken String? | |
| refreshToken String? | |
| expiresAt DateTime? | |
| createdAt DateTime | |
| user User | |
| @ | |
| @ | |
| } | |
| model Session { | |
| id String .Uuid | |
| userId String .Uuid | |
| token String | |
| portal String // client | vendor | admin | |
| ipAddress String? | |
| userAgent String? | |
| expiresAt DateTime | |
| revokedAt DateTime? | |
| createdAt DateTime | |
| user User | |
| @ | |
| @ | |
| } | |
| // ββ Client Profile ββ | |
| model ClientProfile { | |
| id String .Uuid | |
| userId String .Uuid | |
| partnerName String? | |
| weddingDate DateTime? | |
| location String? | |
| guestCount Int? | |
| budget Decimal? .Decimal(12, 2) | |
| createdAt DateTime | |
| updatedAt DateTime | |
| user User | |
| bookings Booking[] | |
| shortlists Shortlist[] | |
| workspaces Workspace[] | |
| } | |
| // ββ Vendor Profile ββ | |
| model VendorProfile { | |
| id String .Uuid | |
| userId String .Uuid | |
| businessName String | |
| categoryId String .Uuid | |
| description String? | |
| district String? | |
| address String? | |
| website String? | |
| socialLinks Json? // {facebook, instagram, etc} | |
| isVerified Boolean | |
| isPublished Boolean | |
| kycStatus KycStatus | |
| kycSubmittedAt DateTime? | |
| kycApprovedAt DateTime? | |
| createdAt DateTime | |
| updatedAt DateTime | |
| user User | |
| category Category | |
| packages Package[] | |
| bookings Booking[] | |
| leads Lead[] | |
| availability VendorAvailability[] | |
| } | |
| enum KycStatus { | |
| PENDING | |
| SUBMITTED | |
| APPROVED | |
| REJECTED | |
| } | |
| // ββ Admin Profile ββ | |
| model AdminProfile { | |
| id String .Uuid | |
| userId String .Uuid | |
| permissions String[] // MANAGE_VENDORS | MANAGE_CONTRACTS | MANAGE_USERS | SYSTEM_ADMIN | |
| createdAt DateTime | |
| updatedAt DateTime | |
| user User | |
| } | |
| // ββ Categories ββ | |
| model Category { | |
| id String .Uuid | |
| name String | |
| slug String | |
| emoji String? | |
| status ContentStatus | |
| sortOrder Int | |
| parentId String? .Uuid | |
| createdAt DateTime | |
| updatedAt DateTime | |
| parent Category? | |
| children Category[] | |
| vendors VendorProfile[] | |
| } | |
| enum ContentStatus { | |
| DRAFT | |
| PUBLISHED | |
| ARCHIVED | |
| } | |
| // ββ Packages ββ | |
| model Package { | |
| id String .Uuid | |
| vendorId String .Uuid | |
| name String | |
| description String? | |
| price Decimal .Decimal(12, 2) | |
| guestCapacity Int? | |
| isActive Boolean | |
| createdAt DateTime | |
| updatedAt DateTime | |
| vendor VendorProfile | |
| @ | |
| } | |
| // ββ Vendor Availability ββ | |
| model VendorAvailability { | |
| id String .Uuid | |
| vendorId String .Uuid | |
| date DateTime .Date | |
| type AvailabilityType | |
| label String? | |
| createdAt DateTime | |
| vendor VendorProfile | |
| @ | |
| @ | |
| } | |
| enum AvailabilityType { | |
| AVAILABLE | |
| BOOKED | |
| BLOCKED | |
| } | |
| // ββ Bookings ββ | |
| model Booking { | |
| id String .Uuid | |
| clientId String .Uuid | |
| vendorId String .Uuid | |
| packageId String? .Uuid | |
| status BookingStatus | |
| idempotencyKey String // prevent duplicate writes | |
| date DateTime | |
| guestCount Int? | |
| notes String? | |
| totalAmount Decimal? .Decimal(12, 2) | |
| createdAt DateTime | |
| updatedAt DateTime | |
| client ClientProfile | |
| vendor VendorProfile | |
| package Package? | |
| contracts Contract[] | |
| @ | |
| @ | |
| @ | |
| } | |
| enum BookingStatus { | |
| PENDING | |
| CONFIRMED | |
| CANCELLED | |
| COMPLETED | |
| } | |
| // ββ Shortlist ββ | |
| model Shortlist { | |
| id String .Uuid | |
| clientId String .Uuid | |
| vendorId String .Uuid | |
| notes String? | |
| createdAt DateTime | |
| client ClientProfile | |
| @ | |
| @ | |
| } | |
| // ββ Workspaces (client planning) ββ | |
| model Workspace { | |
| id String .Uuid | |
| clientId String .Uuid | |
| name String | |
| tasks Json? // embedded checklist items | |
| timeline Json? // embedded timeline events | |
| createdAt DateTime | |
| updatedAt DateTime | |
| client ClientProfile | |
| @ | |
| } | |
| // ββ Leads ββ | |
| model Lead { | |
| id String .Uuid | |
| vendorId String .Uuid | |
| clientId String? .Uuid | |
| name String | |
| type String | |
| status LeadStatus | |
| notes String? | |
| createdAt DateTime | |
| updatedAt DateTime | |
| vendor VendorProfile | |
| @ | |
| } | |
| enum LeadStatus { | |
| NEW | |
| VIEWED | |
| QUOTED | |
| CONVERTED | |
| LOST | |
| } | |
| // ββ Reviews ββ | |
| model Review { | |
| id String .Uuid | |
| vendorId String .Uuid | |
| clientId String .Uuid | |
| rating Int // 1-5 | |
| content String? | |
| isFlagged Boolean | |
| createdAt DateTime | |
| vendor VendorProfile | |
| @ | |
| @ | |
| } | |
| // ββ CONTRACTS ββ | |
| model Contract { | |
| id String .Uuid | |
| bookingId String .Uuid | |
| vendorId String .Uuid | |
| clientId String .Uuid | |
| // Contract metadata | |
| title String | |
| serviceType String? | |
| totalAmount Decimal .Decimal(12, 2) | |
| status ContractStatus | |
| version Int | |
| // Timestamps | |
| sentAt DateTime? | |
| viewedAt DateTime? | |
| signedAt DateTime? | |
| vendorSignedAt DateTime? | |
| clientSignedAt DateTime? | |
| completedAt DateTime? | |
| createdAt DateTime | |
| updatedAt DateTime | |
| // Relations | |
| booking Booking | |
| sections ContractSection[] | |
| versions ContractVersion[] | |
| signatures ContractSignature[] | |
| auditLogs ContractAuditLog[] | |
| deliverables ContractDeliverable[] | |
| @ | |
| @ | |
| @ | |
| @ | |
| } | |
| enum ContractStatus { | |
| DRAFT | |
| SENT | |
| VIEWED | |
| SIGNED | |
| ACTIVE | |
| AMENDED | |
| DISPUTED | |
| COMPLETED | |
| CANCELLED | |
| } | |
| model ContractSection { | |
| id String .Uuid | |
| contractId String .Uuid | |
| sortOrder Int | |
| title String | |
| content String | |
| createdAt DateTime | |
| contract Contract | |
| @ | |
| } | |
| model ContractDeliverable { | |
| id String .Uuid | |
| contractId String .Uuid | |
| description String | |
| dueDate DateTime? | |
| quantity Int? | |
| acceptanceCriteria String? | |
| isCompleted Boolean | |
| completedAt DateTime? | |
| createdAt DateTime | |
| contract Contract | |
| @ | |
| } | |
| // Immutable contract version snapshot | |
| model ContractVersion { | |
| id String .Uuid | |
| contractId String .Uuid | |
| version Int | |
| reason String? // reason for amendment | |
| snapshot Json // full frozen copy of contract + sections + deliverables | |
| createdBy String // userId | |
| createdAt DateTime | |
| contract Contract | |
| @ | |
| @ | |
| } | |
| model ContractSignature { | |
| id String .Uuid | |
| contractId String .Uuid | |
| contractVersionId String .Uuid | |
| signerId String // userId | |
| signerRole Role | |
| signature String? // digital signature data | |
| ipAddress String? | |
| userAgent String? | |
| signedAt DateTime | |
| contract Contract | |
| contractVersion ContractVersion | |
| @ | |
| @ | |
| } | |
| // Append-only audit log β rows are NEVER updated or deleted | |
| model ContractAuditLog { | |
| id String .Uuid | |
| contractId String .Uuid | |
| action String // created | sent | viewed | signed | declined | amended | disputed | resolved | completed | |
| actorId String? // userId | |
| actorRole Role? | |
| detail String? | |
| metadata Json? // version diff, IP, etc | |
| createdAt DateTime | |
| contract Contract | |
| @ | |
| } | |
| // ββ Contract Templates (vendor-submitted, admin-approved) ββ | |
| model ContractTemplate { | |
| id String .Uuid | |
| vendorId String? .Uuid | |
| name String | |
| category String | |
| status ContentStatus // admin approval workflow | |
| structure Json // frozen section structure + deliverable templates | |
| submittedAt DateTime | |
| approvedAt DateTime? | |
| approvedBy String? // admin userId | |
| createdAt DateTime | |
| updatedAt DateTime | |
| vendor VendorProfile? | |
| @ | |
| @ | |
| } | |
| // ββ Admin Audit Log ββ | |
| model AdminAuditLog { | |
| id String .Uuid | |
| adminId String .Uuid | |
| action String | |
| target String? // resource acted on | |
| detail String? | |
| createdAt DateTime | |
| @ | |
| } | |
| // ββ Notifications ββ | |
| model Notification { | |
| id String .Uuid | |
| userId String .Uuid | |
| title String | |
| body String | |
| type String // booking | contract | review | system | |
| isRead Boolean | |
| link String? | |
| createdAt DateTime | |
| @ | |
| } | |
| // ββ Rate Limiting (backed by Redis; schema for reference) ββ | |
| // Key pattern: ratelimit:{ip}:{method}:{path}:{window} | |
| // Redis INCR + EXPIRE | |