How dharshan47/rrckitchen works
Purpose and runtime
RRC Kitchen is a Next.js 16/React 19 TypeScript PWA marketplace for Thanjavur meal delivery. It serves customers, kitchen partners, delivery partners, and administrators from one App Router application. Primary web entry points are app/page.tsx, app/layout.tsx, and role-specific route trees such as app/kitchen/dashboard, app/delivery-partner/dashboard, and app/admin.
Routing and application boundary
Pages are composed as server/client React surfaces under app/; API route handlers provide webhook, integration, and client-facing HTTP boundaries under app/api. Business operations are primarily server actions grouped by domain in actions/, rather than a separate backend service.
• app/cart/page.tsx
• app/kitchens/[slug]/page.tsx
• app/api/payment/verify/route.ts
• actions/index.ts
Identity, roles, and portals
Better-Auth supports phone OTP authentication and administrative auth/2FA. Authorization boundaries distinguish customer accounts from kitchen, delivery, and admin operations; each role has a dedicated dashboard and corresponding action modules.
• app/api/auth/[...all]/route.ts
• lib/auth.ts
• lib/auth-guards.ts
• app/admin/layout.tsx
• actions/onboarding/auth.ts
Catalog, discovery, and cart
Customer discovery flows retrieve kitchens, menus, categories, nearby/search results, and reviews; client components and Zustand stores manage interactive filtering, menu selection, wishlist, location, and cart state. Checkout converts the client cart plus address/coupon inputs into an order/payment flow.
• actions/catalog/home-data.ts
• actions/catalog/kitchen-detail.ts
• actions/catalog/menu.ts
• stores/cartStore.ts
• components/cart/cart-content.tsx
Order lifecycle and dispatch
Orders progress from checkout/payment through kitchen preparation, dispatch assignment, pickup, delivery status, completion, reviews, and payout/reconciliation. Dispatch logic is split between central dispatch actions and order-oriented actions, while delivery partners submit availability, status, and location updates.
• actions/orders/orders.ts
• actions/dispatch/dispatch-actions.ts
• actions/delivery/profile.ts
• app/api/delivery/order-status/route.ts
• app/api/rider/location/route.ts
Payments, financial operations, and scheduled recovery
Razorpay covers online orders, UPI collect, verification, and webhooks; cash-on-delivery is also represented in the order/payment domain. Refund, kitchen payout, delivery payout, and retry/settlement jobs are separate operational stages. Webhook handling is an external trust boundary and scheduled GitHub/Vercel-triggered endpoints process deferred work.
• app/api/payment/create-order/route.ts
• app/api/auth/razorpay/webhook/route.ts
• actions/payments/refund.ts
• actions/payouts/kitchen-payout.ts
• app/api/jobs/settle-payouts/route.ts
• .github/workflows/scheduled-jobs.yml
Persistence, cache, media, and integrations
PostgreSQL is the system of record through Prisma, with its schema defining users/roles, kitchens, menus, orders, payments, delivery partners, reviews, and service zones. Redis supports caching; Cloudinary is the signed media upload/delete boundary. Geocoding/routing APIs support location-aware fulfillment.
• prisma/schema.prisma
• lib/prisma.ts
• lib/redis.ts
• app/api/cloudinary/sign/route.ts
• app/api/geocode/search/route.ts
Real-time, notification, and offline delivery
Ably provides order-tracking and rider-location channels to customer and partner dashboards. Web Push subscriptions and notification logic handle asynchronous user alerts. The service worker and manifest establish installable/offline PWA behavior; cron/job endpoints also drive nudges and event processing.
• lib/ably/server.ts
• hooks/useAblySubscribe.ts
• components/map/live-order-tracking-map.tsx
• app/api/push/subscribe/route.ts
• app/api/cron/process-order-events/route.ts
• public/sw.js
Main entry points: orders.ts Order lifecycle · page.tsx Customer storefront · schema.prisma PostgreSQL / Prisma · route.ts API routes
Components 18
Next.js application
App Router surfaces and HTTP boundaries.
- Customer storefront · Discovery, cart, checkout, and order tracking.
app/page.tsx - Role portals · Kitchen, delivery, and admin operational surfaces.
app/kitchen/dashboard - API routes · Client, webhook, integration, and job endpoints.
app/api/payment/verify/route.ts - PWA service worker · Provides installable and offline behavior.
public/sw.js
Business operations
Server actions implement marketplace workflows.
- Auth and role guards · Phone OTP, admin 2FA, and authorization checks.
lib/auth.ts - Catalog and discovery · Retrieves kitchens, menus, search, and reviews.
actions/catalog/home-data.ts - Cart state · Holds client-side meal selections for checkout.
stores/cartStore.ts - Order lifecycle · Creates and advances orders through completion and reviews.
actions/orders/orders.ts - Dispatch operations · Assigns delivery work and coordinates fulfillment.
actions/dispatch/dispatch-actions.ts - Delivery updates · Availability, order status, and rider location updates.
actions/delivery/profile.ts - Refunds and payouts · Handles refunds and kitchen or rider payouts.
actions/payments/refund.ts
Data and integrations
Persistence, real-time, payments, and external services.
- PostgreSQL / Prisma · Stores marketplace identities, catalog, orders, payments, and zones.
prisma/schema.prisma - Redis cache
lib/redis.ts - Razorpay · Online payment, UPI collect, verification, and webhooks.
app/api/payment/create-order/route.ts - Scheduled settlement · Processes deferred payouts and recovery work.
app/api/jobs/settle-payouts/route.ts - Ably real-time · Publishes order tracking and rider-location updates.
lib/ably/server.ts - Web Push · Stores subscriptions and sends asynchronous alerts.
app/api/push/subscribe/route.ts - Media and geolocation APIs · Supports signed uploads, geocoding, and routing.
app/api/cloudinary/sign/route.ts
Connections 22
- Customer storefront → Catalog and discovery: browses
- Customer storefront → Cart state: updates
- Cart state → Order lifecycle: checkout input
- Role portals → Auth and role guards: authorizes
- Customer storefront → Auth and role guards: signs in
- API routes → Auth and role guards: enforces roles
- Catalog and discovery → PostgreSQL / Prisma: reads catalog
- Catalog and discovery → Redis cache: caches
- Order lifecycle → PostgreSQL / Prisma: persists orders
- Order lifecycle → Razorpay: creates and verifies payment
- Razorpay → API routes: webhook
- Order lifecycle → Dispatch operations: requests assignment
- Dispatch operations → Delivery updates: assigns delivery
- Delivery updates → PostgreSQL / Prisma: records status and location
- Order lifecycle → Ably real-time: publishes order events
- Delivery updates → Ably real-time: publishes rider updates
- Ably real-time → Customer storefront: live tracking
- Order lifecycle → Web Push: sends alerts
- Refunds and payouts → PostgreSQL / Prisma: records reconciliation
- Scheduled settlement → Refunds and payouts: triggers settlement
- API routes → Media and geolocation APIs: proxies integrations
- PWA service worker → Customer storefront: offline support