System Architecture

Next.js 14 App Router Architecture

The platform leverages Next.js 14's App Router with server components for optimal performance, utilizing server-side rendering, automatic code splitting, and edge deployment capabilities.

Application Structure

app/
├── (marketing)/          # Public pages (SSR)
│   ├── page.tsx         # Homepage
│   ├── booking/         # Session booking
│   ├── blog/            # SEO blog
│   └── contact/         # Contact form
├── admin/               # Protected area
│   ├── (auth)/         # Login flows
│   └── (protected)/    # Dashboard
└── api/                 # API routes
    ├── auth/           # NextAuth
    ├── bookings/       # CRUD ops
    └── admin/          # Admin endpoints

Key Architectural Patterns

  • Server Components: Default rendering for reduced JavaScript bundle size and improved performance
  • API Route Handlers: RESTful endpoints for CRUD operations with TypeScript type safety
  • Middleware Protection: Session validation on all protected routes with role-based access control
  • Database ORM: Prisma for type-safe database queries with automatic migrations

Database Schema Design

PostgreSQL database with Prisma ORM featuring 9 normalized models for bookings, users, content management, and system configuration. Full referential integrity with cascading operations.

Core Models

  • • User (roles, authentication)
  • • Booking (sessions, payments)
  • • Service (offerings, pricing)
  • • Availability (scheduling)
  • • BlockedDate (calendar mgmt)

Content Models

  • • BlogPost (SEO content)
  • • Tag (categorization)
  • • Testimonial (reviews)
  • • ContactSubmission (leads)

Technology Stack Details

Frontend

  • • Next.js 14.2
  • • React 18
  • • TypeScript 5.3
  • • Tailwind CSS
  • • shadcn/ui
  • • Framer Motion

Backend

  • • Node.js Runtime
  • • PostgreSQL
  • • Prisma ORM 5.22
  • • NextAuth.js 4.24
  • • bcrypt
  • • Nodemailer

DevOps

  • • Vercel Platform
  • • Edge Deployment
  • • GitHub Actions
  • • Prisma Migrate
  • • ESLint
  • • Git Version Control