Schema Reference
41 Prisma models. Single source of truth: prisma/schema.prisma in the marketplace repo.
Model categories
Core identity
| Model | Purpose | Notes |
|---|---|---|
Consumer | End user | Has passwordHash, googleId, resetToken, alias, bio, services |
Seller | Business | Approval workflow (status: pending/active/rejected). role='admin' flag for admin |
Doctor | Healthcare provider | Added resetToken 2026-04-17 |
DeliveryPartner | Rider | Phone-based auth |
Admin | Currently a Seller flag, not a separate table |
Commerce
| Model | Purpose |
|---|---|
Store | Seller's commerce surface (kirana, photo studio, clothing) |
Product | Both store products + ads (single table — storeId set vs consumerId set) |
ProductImage | Multi-image per product (max 10) |
Category | Product category lookup |
StoreCategory | Many-to-many store ↔ category |
Cart | Server-side cart (mobile uses AsyncStorage too) |
Subscription | Consumer subscribes to a store for updates |
Orders
| Model | Purpose |
|---|---|
StoreOrder + StoreOrderItem | Current orders (shop). paymentMethod, paymentStatus, cancellationReason, all status timestamps |
Order + OrderItem | Eats (legacy, archived 2026-04-17 — preserved for historical data) |
Restaurant + MenuItem | Eats (legacy) |
Payment | Online payment session (UPI / PhonePe). 5-min TTL |
DeliveryAssignment | Auto-assignment of riders to orders |
Reels
| Model | Purpose |
|---|---|
Reel | Main entity |
ReelTag | Multi-tag (up to 5 per reel) — gated by REELS_COMMERCE_ENABLED |
ReelLike, ReelComment, ReelView | Engagement, deduplicated by fingerprint |
ReelProductRedirect | Tap-on-tagged-product attribution log |
ReelEarning | Creator commission (1% of attributed orders, 24h window) |
Requests (Community)
| Model | Purpose |
|---|---|
Request | Q&A post. discussionType ∈ "private" / "public" |
RequestThread | For private: 1 per supporter (max 3); for public: 1 shared |
RequestMessage | Chat. editedAt, isEdited, isDeleted |
Health
| Model | Purpose |
|---|---|
Prescription | Doctor-issued, viewable by consumer |
DoctorNotification, DoctorNotifPrefs | Doctor's notification system |
Auth + verification
| Model | Purpose |
|---|---|
VerificationCode | Polymorphic OTP store (consumerId / sellerId / doctorId, one set) |
Invitation | Seller invite tokens (7-day expiry) |
SellerDocument | KYC docs uploaded for verification |
Notifications + email
| Model | Purpose |
|---|---|
Notification (consumer), SellerNotification, DoctorNotification | In-app inbox rows |
PushSubscription | Web Push subscriptions |
PushToken | Expo push tokens (mobile) |
EmailLog | Every email send tracked — added 2026-04-17. Status: sent/failed, attempts, error |
Misc
| Model | Purpose |
|---|---|
Contribution | 0.5% charity ledger |
WebsiteContact, WebsiteJob, WebsiteJobApplication | Public landing-page submissions |
SearchLog | AI search query log |
AnalyticsEvent | PWA install/launch tracking |
IntelligenceEvent | Behavioral feed personalization signal |
Conventions
- All tables
PascalCasesingular (e.g.,StoreOrder, notstore_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.
Related
- Migration Guide — how we change the schema
- Common Queries — frequently-used SQL
- Source of truth:
prisma/schema.prisma