Skip to main content

Codebase Summary

Overview of the Pet Service Management System codebase structure and organization.

Project Overview

Full-stack web application for managing pet services: boarding, grooming, veterinary care, training, daycare, transportation.

Frontend

Next.js 16.0.10 + React 19.2.1

Backend

NestJS 11.0.1 + PostgreSQL

Type Safety

TypeScript 5 Strict Mode

Directory Structure

backend/
├── src/
│   ├── auth/              # Authentication & authorization
│   │   ├── guards/        # Auth, Admin guards
│   │   ├── auth.controller.ts
│   │   ├── auth.service.ts
│   │   └── auth.module.ts
│   ├── bookings/          # Booking management
│   │   ├── dto/           # Data transfer objects
│   │   ├── bookings.controller.ts
│   │   ├── bookings.service.ts
│   │   └── bookings.module.ts
│   ├── services/          # Service catalog
│   ├── staff/             # Staff management
│   ├── settings/          # Configuration
│   ├── dashboard/         # Analytics
│   ├── prisma/            # Database service
│   └── main.ts            # Entry point
├── prisma/
│   ├── schema.prisma      # Database schema
│   └── seed.ts            # Database seeding
└── test/                  # E2E tests

Backend Architecture

Core Modules

  • Better Auth integration
  • Admin guard for role-based access
  • Authentication guard for protected routes
  • JWT token management
  • Pet service bookings with status tracking
  • Multiple pets per booking support
  • Status workflow: PENDING → CONFIRMED → IN_PROGRESS → COMPLETED → CANCELLED
  • Pricing calculations and payment tracking
  • 6 categories: BOARDING, GROOMING, VETERINARY, TRAINING, DAYCARE, TRANSPORT
  • Multi-language support (JSONB fields)
  • Pricing by unit (per day/hour/session)
  • Images and descriptions
  • Employee scheduling and availability
  • Staff-service proficiency mapping (1-5 skill levels)
  • Performance metrics (ratings, booking counts)
  • Working hours management
  • Key-value store with type support
  • Grouped settings (GENERAL, PAYMENT, CONTACT)
  • Application-wide configuration
  • Business metrics and statistics
  • User activity monitoring
  • Performance reports
  • Database operations via Prisma ORM
  • Connection management
  • Query optimization

Database Schema

User & Authentication:
  • User (Better Auth compatible)
  • Session (session management)
  • Account (OAuth accounts)
  • Verification (email verification)
Pet Management:
  • Pet (medical history, allergies, vaccinations)
  • Species: DOG, CAT, BIRD, RABBIT, OTHER
Services:
  • Service (catalog with JSONB multi-language fields)
  • Categories: BOARDING, GROOMING, VETERINARY, TRAINING, DAYCARE, TRANSPORT
Bookings:
  • Booking (status tracking, pricing)
  • BookingPet (many-to-many: bookings to pets)
  • BookingService (many-to-many: bookings to services)
  • Status: PENDING, CONFIRMED, IN_PROGRESS, COMPLETED, CANCELLED
Staff:
  • Staff (employee details, availability)
  • StaffService (staff-service mapping with proficiency)
System:
  • Setting (configuration store)
  • AuditLog (user actions, entity changes)
Roles: ADMIN, MANAGER, STAFF, CUSTOMER

API Endpoints

POST   /auth/login
POST   /auth/register
POST   /auth/logout
GET    /auth/session

Frontend Architecture

Routing Structure

App Router with i18n:
  • Dynamic locale parameter: [locale]/
  • Supported locales: en, de, fr, ko, ja, vi, lo, km, my, fil
Public Routes:
  • /[locale]/ - Home page
  • /[locale]/services - Service listing
  • /[locale]/booking - Booking flow
  • /[locale]/contact - Contact page
  • /[locale]/login - Login
  • /[locale]/register - Registration
Protected Routes:
  • /[locale]/dashboard - Dashboard overview
  • /[locale]/dashboard/booking - Booking management
  • /[locale]/dashboard/services - Service management
  • /[locale]/dashboard/staff - Staff management
  • /[locale]/dashboard/settings - Settings

Component Architecture

Layout Components:
  • Header.tsx - Navigation header
  • Footer.tsx - Footer with contact
  • DashboardHeader.tsx - Dashboard header
  • LanguageSwitcher.tsx - Language selection
Utilities:
  • lib/api/ - API client functions
  • lib/auth-client.ts - Better Auth config
  • lib/auth-helpers.ts - Auth utilities
  • lib/transformers.ts - Data transformation

Multi-Language Support

next-intl Implementation:
  • 10 language support with JSON message files
  • Dynamic language switching
  • Locale-aware routing
Languages: en, de, fr, ko, ja, vi, lo, km, my, fil

Technology Stack

PackageVersionPurpose
NestJS^11.0.1Backend framework
Prisma^5.22.0ORM
Better Auth^1.4.7Authentication
TypeScript^5.7.3Type safety

Development Patterns

Backend

  • Feature-based modules (Auth, Bookings, Services)
  • Each module: controller, service, module files
  • DTOs for request/response validation
  • Guards for authentication/authorization

Frontend

  • Functional components with hooks
  • Layout components for shared UI
  • Page components for routes
  • Typed API client functions

Build & Deployment

npm run build          # Build
npm run start:dev      # Development
npm run start:prod     # Production
npm run prisma:generate # Generate Prisma client
npm run prisma:db:push # Apply schema