YeboCars Data Models
Full Prisma schema documentation with every field for all 20+ models.
Database Configuration
prisma
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
}Core Models
User
User accounts for both customers and dealers.
prisma
model User {
id String @id @default(cuid())
phone String @unique
password String
name String?
email String? @unique
role UserRole @default(USER) // USER | DEALER | ADMIN
// Verification
isPhoneVerified Boolean @default(false)
isEmailVerified Boolean @default(false)
verificationOtp String?
otpExpiry DateTime?
// Profile
avatar String?
dateOfBirth DateTime?
gender String?
// Location
countryId String?
city String?
address String?
// Dealer association
dealerId String? @unique
// Status
isActive Boolean @default(true)
lastLogin DateTime?
// Auth
refreshToken String?
resetPasswordOtp String?
resetPasswordExpiry DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
enum UserRole {
USER
DEALER
ADMIN
}Car
Core car listing model.
prisma
model Car {
id String @id @default(cuid())
// Basic Info
make String
model String
year Int
price Float
// Specifications
mileage Int
fuelType FuelType
transmission Transmission
bodyType String
engineSize String?
horsePower Int?
// Colors
color String?
exteriorColor String?
interiorColor String?
// Condition
condition CarCondition @default(USED)
// Description
description String?
features String[]
// Media
images String[]
videos String[]
// Seller
sellerId String
sellerType SellerType
// Location
countryId String
city String?
// Status
status CarStatus @default(PENDING)
isFeatured Boolean @default(false)
// Stats
views Int @default(0)
favorites Int @default(0)
inquiries Int @default(0)
// VIN
vin String? @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
enum FuelType {
PETROL
DIESEL
ELECTRIC
HYBRID
LPG
}
enum Transmission {
AUTOMATIC
MANUAL
CVT
SEMI_AUTOMATIC
}
enum CarCondition {
NEW
USED
CERTIFIED
}
enum CarStatus {
PENDING
ACTIVE
SOLD
INACTIVE
REJECTED
}
enum SellerType {
PRIVATE
DEALER
}Dealer
Dealer/dealership profiles.
prisma
model Dealer {
id String @id @default(cuid())
// Business Info
name String
businessName String?
registrationNumber String?
taxId String?
// Contact
phone String
email String
website String?
// Location
countryId String
city String
address String
latitude Float?
longitude Float?
// Branding
logo String?
banner String?
description String?
// Status
isApproved Boolean @default(false)
isActive Boolean @default(true)
approvedAt DateTime?
approvedBy String?
// Plan
plan DealerPlan @default(BASIC)
planExpiry DateTime?
stripeCustomerId String?
// Stats
totalListings Int @default(0)
totalSold Int @default(0)
totalViews Int @default(0)
rating Float @default(0)
reviewCount Int @default(0)
// Verification
verificationDocs Json?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
enum DealerPlan {
BASIC // $10/mo - 10 listings
DEALER // $25/mo - 50 listings
PRO // $60/mo - Unlimited
}DealerApplication
Dealer registration applications.
prisma
model DealerApplication {
id String @id @default(cuid())
userId String @unique
// Business Info
businessName String
registrationNumber String
taxId String?
// Contact
contactName String
contactPhone String
contactEmail String
// Location
countryId String
city String
address String
// Documents
businessLicense String?
idDocument String?
proofOfAddress String?
// Status
status ApplicationStatus @default(PENDING)
rejectionReason String?
// Review
reviewedBy String?
reviewedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
enum ApplicationStatus {
PENDING
UNDER_REVIEW
APPROVED
REJECTED
ADDITIONAL_INFO_REQUIRED
}Favorite
User favorites/saved cars.
prisma
model Favorite {
id String @id @default(cuid())
userId String
carId String
createdAt DateTime @default(now())
@@unique([userId, carId])
}Inquiry
Car inquiries from users.
prisma
model Inquiry {
id String @id @default(cuid())
carId String
userId String
// Contact info
name String
phone String
email String?
// Inquiry details
message String
type InquiryType @default(GENERAL)
// Status
status InquiryStatus @default(NEW)
// Response
respondedAt DateTime?
response String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
enum InquiryType {
GENERAL
TEST_DRIVE
PRICE_NEGOTIATION
TRADE_IN
}
enum InquiryStatus {
NEW
CONTACTED
IN_PROGRESS
CLOSED
CONVERTED
}TestDriveRequest
Test drive requests.
prisma
model TestDriveRequest {
id String @id @default(cuid())
carId String
userId String
// Contact
name String
phone String
email String?
// Scheduling
preferredDate DateTime
preferredTime String
alternateDate DateTime?
// Status
status TestDriveStatus @default(PENDING)
// Confirmation
confirmedDate DateTime?
confirmedTime String?
notes String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
enum TestDriveStatus {
PENDING
CONFIRMED
COMPLETED
CANCELLED
NO_SHOW
}Message
User-to-user messaging.
prisma
model Message {
id String @id @default(cuid())
conversationId String
senderId String
receiverId String
content String
attachments String[]
carId String? // Associated car (optional)
isRead Boolean @default(false)
readAt DateTime?
createdAt DateTime @default(now())
}
model Conversation {
id String @id @default(cuid())
participant1Id String
participant2Id String
lastMessageAt DateTime?
lastMessage String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([participant1Id, participant2Id])
}Notification
User notifications.
prisma
model Notification {
id String @id @default(cuid())
userId String
type NotificationType
title String
message String
data Json?
isRead Boolean @default(false)
readAt DateTime?
createdAt DateTime @default(now())
}
enum NotificationType {
NEW_INQUIRY
TEST_DRIVE_REQUEST
TEST_DRIVE_CONFIRMED
PRICE_DROP
NEW_MESSAGE
LISTING_APPROVED
LISTING_REJECTED
PAYMENT_SUCCESS
PAYMENT_FAILED
SUBSCRIPTION_EXPIRING
SYSTEM
}Review
Dealer reviews.
prisma
model Review {
id String @id @default(cuid())
dealerId String
userId String
rating Int // 1-5
title String?
comment String?
// Verification
verified Boolean @default(false)
carId String? // Associated car purchase
// Response
response String?
respondedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}SavedSearch
User saved searches.
prisma
model SavedSearch {
id String @id @default(cuid())
userId String
name String
filters Json // Search parameters
// Notifications
alertEnabled Boolean @default(false)
alertFrequency String @default("daily")
lastAlertAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}Country
Multi-country support.
prisma
model Country {
id String @id @default(cuid())
name String
code String @unique // ISO 3166-1 alpha-2
code3 String @unique // ISO 3166-1 alpha-3
callingCode String
// Currency
currency Json // { code, name, symbol, rate }
// Status
isActive Boolean @default(true)
isSupported Boolean @default(false)
// Locale
languages String[]
flag String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}Blog (for autoblogger)
prisma
model BlogPost {
id String @id @default(cuid())
slug String @unique
title String
excerpt String?
content String
// Media
featuredImage String?
images String[]
// Meta
category String?
tags String[]
// SEO
metaTitle String?
metaDescription String?
// Author
authorId String?
authorName String?
// Status
status PostStatus @default(DRAFT)
publishedAt DateTime?
// Stats
views Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
enum PostStatus {
DRAFT
PUBLISHED
ARCHIVED
}Statistics Models
CarView
Track car views.
prisma
model CarView {
id String @id @default(cuid())
carId String
userId String?
ipAddress String?
userAgent String?
createdAt DateTime @default(now())
}DealerStats
Dealer analytics.
prisma
model DealerStats {
id String @id @default(cuid())
dealerId String @unique
totalViews Int @default(0)
totalInquiries Int @default(0)
totalTestDrives Int @default(0)
totalSales Int @default(0)
// Period stats
monthlyViews Int @default(0)
monthlyInquiries Int @default(0)
monthlySales Int @default(0)
conversionRate Float @default(0)
avgResponseTime Int? // minutes
lastUpdated DateTime @default(now())
}Model Count Summary
| Category | Models |
|---|---|
| Core | User, Car, Dealer |
| Applications | DealerApplication |
| Interactions | Favorite, Inquiry, TestDriveRequest |
| Messaging | Message, Conversation |
| Notifications | Notification |
| Reviews | Review |
| Search | SavedSearch, CarModel |
| Content | BlogPost |
| Analytics | CarView, DealerStats |
| System | Country |
| Total | ~20 models |
Database Indexes
prisma
// Car indexes
@@index([make])
@@index([model])
@@index([year])
@@index([price])
@@index([status])
@@index([sellerId])
@@index([countryId])
@@index([bodyType])
@@index([fuelType])
// User indexes
@@index([phone])
@@index([email])
@@index([role])
// Dealer indexes
@@index([plan])
@@index([isApproved])
@@index([countryId])
// Message indexes
@@index([conversationId, createdAt])
@@index([senderId])
@@index([receiverId])