How priyanshuraj20/dentwise works
1. Overall shape
- Dentwise is a Next.js App Router SaaS with a mixed server/client architecture.
- The app is split into user-facing experiences: landing, appointment booking, dashboard, admin management, Pro upsell, and an AI voice experience.
2. Route-level domains
- src/app/page.tsx is the marketing landing page.
- src/app/appointments/page.tsx contains the booking flow.
- src/app/dashboard/page.tsx is the authenticated patient dashboard.
- src/app/admin/page.tsx is the staff/admin console.
- src/app/pro/page.tsx handles the paid-plan surface.
- src/app/voice/page.tsx exposes the voice-agent experience.
3. Authentication and access control
- The repo is built around Clerk for sign-in, identity, and subscription-aware access.
- src/proxy.ts is the route boundary for auth/redirect logic.
- src/components/UserSync.tsx and src/lib/actions/users.ts indicate a user-sync step between Clerk identity and the app’s own user record.
4. Booking workflow
- The appointment experience is a multi-step client flow in src/components/appointments/*.
- The booking path is explicitly staged as doctor selection → time/service selection → confirmation.
- Hooks such as src/hooks/use-doctors.ts and src/hooks/use-appointment.ts likely coordinate fetching and state across those steps.
5. Core data model and persistence
- Prisma is the data access layer, with the schema in prisma/schema.prisma.
- src/lib/prisma.ts centralizes database access to a PostgreSQL backend.
- The main persisted entities appear to be users, doctors, and appointments, since those are the server action modules present under src/lib/actions/.
6. Server-side application logic
- Business operations are concentrated in Next.js server actions:
- src/lib/actions/appointments.ts
- src/lib/actions/doctors.ts
- src/lib/actions/users.ts
- This keeps write operations, validation, and database mutations on the server boundary rather than in client components.
7. Email notification pipeline
- src/app/api/send-appointment-email/route.ts is a dedicated API route for sending transactional mail.
- src/lib/resend.ts integrates with Resend.
- src/components/emails/AppointmentConfirmationEmail.tsx defines the email content used for booking confirmations.
- Net effect: booking data flows from the app into email delivery after persistence.
8. Admin and operational console
- The admin area is built from a client shell plus focused management widgets:
- AdminDashboardClient.tsx
- AdminStats.tsx
- DoctorsManagement.tsx
- RecentAppointments.tsx
- This subsystem is for operational visibility and CRUD-like maintenance of doctors and appointments.
9. AI voice agent and paid-plan boundary
- src/app/voice/page.tsx and src/components/voice/VapiWidget.tsx integrate the Vapi voice agent.
- src/components/voice/ProPlanRequired.tsx suggests the voice feature is gated behind subscription level.
- The pro route appears to be the plan-upgrade/billing boundary that unlocks voice capabilities.
10. UI system and client data fetching
- The app uses a shared design system built from shadcn/ui primitives in src/components/ui/.
- Page-specific UI is organized into feature folders like landing, dashboard, appointments, admin, and voice.
- src/components/providers/TanStackProvider.tsx shows TanStack Query is used for client-side caching and fetching where interactive screens need it.
11. Runtime and deployment boundaries
- The project runs as a modern Next.js full-stack app on Vercel.
- External dependencies are environment-driven: Clerk, PostgreSQL, Resend, and Vapi.
- Static assets live in public/, while next.config.ts, prisma/, and the App Router directories define the main operational boundaries.
12. Key end-to-end data flow
- Authenticated user enters the booking flow → selects doctor/time → server action writes to PostgreSQL via Prisma → confirmation email is sent through Resend → appointment becomes visible in dashboard/admin views.
- The voice/pro flow is parallel: authenticated user enters /voice → entitlement is checked via subscription state → Vapi widget provides the AI interaction if allowed.
Main entry points: proxy.ts Auth proxy · appointments/page.tsx Booking page · appointments.ts Appointment actions · dashboard/page.tsx Patient dashboard
Components 22
App surfaces
Next.js routes and top-level user experiences
- Landing page · Marketing homepage
src/app/page.tsx - Booking page · Multi-step appointment flow entry
src/app/appointments/page.tsx - Patient dashboard · Authenticated patient view
src/app/dashboard/page.tsx - Admin console · Staff management surface
src/app/admin/page.tsx - Pro page · Paid-plan and upgrade surface
src/app/pro/page.tsx - Voice page · AI voice experience entry
src/app/voice/page.tsx
Feature UI
Domain-specific client components and screens
- Booking flow · Doctor, time, and confirmation steps
src/components/appointments/DoctorSelectionStep.tsx - Admin widgets · Stats, doctor CRUD, and recent appointments
src/components/admin/AdminStats.tsx - Dashboard widgets · Overview, actions, and next appointment panels
src/components/dashboard/WelcomeSection.tsx - Landing sections · Hero, pricing, CTA, and explainer sections
src/components/landing/Hero.tsx - Voice widgets · Vapi embed and subscription gate
src/components/voice/VapiWidget.tsx
Server core
Server actions, persistence, and API boundaries
- Auth proxy · Route-level auth and redirect logic
src/proxy.ts - Appointment actions · Write and read appointment state
src/lib/actions/appointments.ts - Doctor actions · Doctor lookup and maintenance logic
src/lib/actions/doctors.ts - User actions · User persistence and synchronization logic
src/lib/actions/users.ts - Prisma DB · Central database client and schema-backed persistence
prisma/schema.prisma - Resend mail · Transactional email delivery
src/lib/resend.ts - Vapi client · Voice-agent service configuration
src/lib/vapi.ts - Email API · Dedicated appointment-email sending endpoint
src/app/api/send-appointment-email/route.ts
Shared system
Reusable UI, providers, hooks, and integration helpers
- User sync · Connects Clerk identity to app user records
src/components/UserSync.tsx - Query provider · Client caching and fetching setup
src/components/providers/TanStackProvider.tsx - Confirm email · Appointment confirmation email content
src/components/emails/AppointmentConfirmationEmail.tsx
Connections 29
- Auth proxy → Landing page: guards · Applies route access logic before public and protected pages
- Auth proxy → Booking page: guards · Controls access to booking flow
- Auth proxy → Patient dashboard: guards · Protects authenticated dashboard
- Auth proxy → Admin console: guards · Restricts staff console
- Auth proxy → Pro page: guards · Checks plan-related access
- Auth proxy → Voice page: guards · Restricts voice experience by entitlement
- Landing page → Landing sections: renders · Composes marketing sections
- Booking page → Booking flow: renders · Hosts the booking workflow
- Booking page → User sync: syncs · Ensures authenticated user exists in app DB
- Patient dashboard → Dashboard widgets: renders · Composes patient overview panels
- Patient dashboard → User sync: depends on · Requires synced user context
- Admin console → Admin widgets: renders · Composes admin management UI
- Pro page → Voice page: unlocks · Plan boundary for voice capabilities
- Voice page → Voice widgets: renders · Loads voice-agent interaction UI
- Booking page → Appointment actions: reads/writes · Fetches doctors and creates appointments
- Booking flow → Appointment actions: calls · Submits booking steps to server actions
- Booking flow → Doctor actions: fetches · Loads available doctors for selection
- Admin widgets → Doctor actions: manages · CRUD operations for doctors
- Admin widgets → Appointment actions: reviews · Displays recent and scheduled appointments
- User sync → User actions: writes · Creates or updates app user records
- Appointment actions → Prisma DB: persists · Stores appointment data in PostgreSQL via Prisma
- Doctor actions → Prisma DB: persists · Reads and updates doctor records
- User actions → Prisma DB: persists · Stores synced user records
- Email API → Resend mail: sends via · Delegates outbound email delivery
- Email API → Confirm email: uses · Renders appointment confirmation content
- Appointment actions → Email API: triggers · Kicks off confirmation email after booking
- Voice widgets → Vapi client: integrates · Embeds the voice-agent runtime
- Booking page → Query provider: uses · Interactive client fetching and cache support
- Patient dashboard → Query provider: uses · Client-side data access for dashboard widgets