Skip to main content

Schema Reference

41 Prisma models. Single source of truth: prisma/schema.prisma in the marketplace repo.

Model categories

Core identity

ModelPurposeNotes
ConsumerEnd userHas passwordHash, googleId, resetToken, alias, bio, services
SellerBusinessApproval workflow (status: pending/active/rejected). role='admin' flag for admin
DoctorHealthcare providerAdded resetToken 2026-04-17
DeliveryPartnerRiderPhone-based auth
AdminCurrently a Seller flag, not a separate table

Commerce

ModelPurpose
StoreSeller's commerce surface (kirana, photo studio, clothing)
ProductBoth store products + ads (single table — storeId set vs consumerId set)
ProductImageMulti-image per product (max 10)
CategoryProduct category lookup
StoreCategoryMany-to-many store ↔ category
CartServer-side cart (mobile uses AsyncStorage too)
SubscriptionConsumer subscribes to a store for updates

Orders

ModelPurpose
StoreOrder + StoreOrderItemCurrent orders (shop). paymentMethod, paymentStatus, cancellationReason, all status timestamps
Order + OrderItemEats (legacy, archived 2026-04-17 — preserved for historical data)
Restaurant + MenuItemEats (legacy)
PaymentOnline payment session (UPI / PhonePe). 5-min TTL
DeliveryAssignmentAuto-assignment of riders to orders

Reels

ModelPurpose
ReelMain entity
ReelTagMulti-tag (up to 5 per reel) — gated by REELS_COMMERCE_ENABLED
ReelLike, ReelComment, ReelViewEngagement, deduplicated by fingerprint
ReelProductRedirectTap-on-tagged-product attribution log
ReelEarningCreator commission (1% of attributed orders, 24h window)

Requests (Community)

ModelPurpose
RequestQ&A post. discussionType ∈ "private" / "public"
RequestThreadFor private: 1 per supporter (max 3); for public: 1 shared
RequestMessageChat. editedAt, isEdited, isDeleted

Health

ModelPurpose
PrescriptionDoctor-issued, viewable by consumer
DoctorNotification, DoctorNotifPrefsDoctor's notification system

Auth + verification

ModelPurpose
VerificationCodePolymorphic OTP store (consumerId / sellerId / doctorId, one set)
InvitationSeller invite tokens (7-day expiry)
SellerDocumentKYC docs uploaded for verification

Notifications + email

ModelPurpose
Notification (consumer), SellerNotification, DoctorNotificationIn-app inbox rows
PushSubscriptionWeb Push subscriptions
PushTokenExpo push tokens (mobile)
EmailLogEvery email send tracked — added 2026-04-17. Status: sent/failed, attempts, error

Misc

ModelPurpose
Contribution0.5% charity ledger
WebsiteContact, WebsiteJob, WebsiteJobApplicationPublic landing-page submissions
SearchLogAI search query log
AnalyticsEventPWA install/launch tracking
IntelligenceEventBehavioral feed personalization signal

Conventions

  • All tables PascalCase singular (e.g., StoreOrder, not store_orders)
  • All timestamps as DateTime (@db.Timestamp(3) for ms precision where needed)
  • Money as Decimal(10, 2) — NEVER float
  • Soft delete via status: "deleted" rather than actual row deletion (preserves history + cascade safety)
  • Polymorphic relations modeled with consumerId? sellerId? doctorId? triple-optional (one MUST be set, no DB constraint enforcing it — code responsibility)

How to inspect locally

cd /Users/siddu/marketplace
npx prisma studio # opens browser-based GUI at localhost:5555

For production:

PGPASSWORD=Ka26Mkt2026 psql -h 34.123.40.64 -U ka26user -d ka26
\dt # list tables
\d "StoreOrder" # describe a table

Credentials: 1Password vault.