packages/db

Database

PostgreSQL on Neon, accessed via Drizzle from the API. Types flow from schema; Zod in packages/validators validates HTTP payloads (not a substitute for SQL constraints where needed).

Enums

Enum Values
package_type shahi_snan, shahi_puja, ganga_aarti, pind_pradanam, temple_visit
booking_status pending, confirmed, cancelled, completed
payment_gateway stripe only (or drop column)
payment_status pending, success, failed, refunded
puja_date_kind shahi_snan, auspicious, other
water_order_status submitted, processing, fulfilled, cancelled

Tables

Table Purpose Key columns
users Application user profile; align FK with Better Auth user id strategy. id, phone, email, name, country, city, timestamps
packages Catalog items for booking. slug, title, type, price, currency, min/max pilgrims, inclusions JSON, hero image key
bookings One purchase of a package by a user. user_id, package_id, status, service_date, slot_id?, notes
pilgrims People attached to a booking. booking_id, name, age, gotra, city, mobile
ancestors Pind Pradanam ancestor rows. booking_id, name, relation, gotra, year_of_passing?
payments Ledger row per Stripe attempt/settlement. booking_id, gateway, status, amount, currency, external_id, raw_payload?
stalls Nearest-stall map data. name, lat, lng, services_offered JSON, hours, address, is_active
reviews Package reviews. user_id, package_id, rating, comment
puja_dates Calendar incl. fixed Shahi Snan dates. date, kind, label, description
water_orders Veda Mineral Water orders. user_id?, contact, phone, company?, quantity, address, status

Recommended indexes

  • packages(type), packages(is_active), unique slug
  • bookings(user_id, status)
  • payments(booking_id), payments(external_id) unique where not null
  • pilgrims(booking_id), ancestors(booking_id)
  • reviews(package_id)
  • stalls(is_active); consider PostGIS later for scale

Better Auth alignment

Decide whether users.id is the Better Auth user id or whether you mirror into a separate profile table with FK. One source of truth prevents orphaned bookings.