Skip to main content

Installation Guide

This guide walks you through setting up the Pet Service Management System on your local development environment.
Prerequisites: Node.js 18+, PostgreSQL 12+, Git

Quick Start

1. Clone the Repository

2. Install Dependencies


Backend Setup

Step 1: Environment Configuration

Create a .env file in the backend/ directory:
.env
Security: Use strong, unique secrets for production. Generate with:

Step 2: Database Setup

1

Create PostgreSQL Database

2

Generate Prisma Client

3

Apply Database Schema

This creates all tables, indexes, and constraints defined in prisma/schema.prisma.
4

Verify Database

Opens Prisma Studio at http://localhost:5555 to inspect your database.

Step 3: Seed Database (Optional)

Seeding creates sample data for development and testing.
Seed Data Includes:
  • Admin user (email: admin@example.com, password: admin123)
  • Manager user (email: manager@example.com, password: manager123)
  • Staff user (email: staff@example.com, password: staff123)
  • Customer users
  • 6 service categories (Boarding, Grooming, Veterinary, Training, Daycare, Transport)
  • Sample pets
  • Sample bookings

Step 4: Start Backend Server

Backend running at http://localhost:3001
Verify Backend:

Frontend Setup

Step 1: Environment Configuration

Create a .env.local file in the frontend/ directory:
.env.local

Step 2: Start Frontend Server

Frontend running at http://localhost:3000
Test the Application:
  1. Open http://localhost:3000 in your browser
  2. Navigate to /en or /vi for localized content
  3. Try logging in with seeded credentials

Database Management

Common Commands

Database Schema

The database includes the following main entities:
  • User: Core user accounts with roles (ADMIN, MANAGER, STAFF, CUSTOMER)
  • Session: Active user sessions
  • Account: OAuth provider accounts
  • Verification: Email verification tokens
  • Booking: Main booking records with status tracking
  • BookingPet: Junction table linking bookings to pets
  • BookingService: Junction table linking bookings to services with pricing
  • Pet: Pet profiles with medical history, vaccinations, allergies
  • Supports multiple images
  • JSON-based vaccination records
  • Service: Service catalog with JSONB multi-language fields
  • Staff: Employee profiles with working hours and specializations
  • StaffService: Junction table with proficiency levels
  • Setting: Key-value configuration store with JSONB values
  • AuditLog: Complete audit trail of user actions

Environment Variables Reference

Backend Environment Variables

Frontend Environment Variables


Code Quality & Testing

Linting & Formatting

Type Checking

Running Tests


Troubleshooting

Problem: connect ECONNREFUSED 127.0.0.1:5432Solution:
  1. Ensure PostgreSQL is running: brew services start postgresql (macOS)
  2. Check DATABASE_URL in .env
  3. Verify credentials: psql -U postgres
  4. Check PostgreSQL logs: tail -f /usr/local/var/log/postgres.log
Problem: Error: listen EADDRINUSE: address already in use :::3000Solution:
Problem: Application crashes with undefined env variablesSolution:
  1. Copy example env files to .env / .env.local
  2. Ensure all required variables are set
  3. Restart development server
Problem: PrismaClient not foundSolution:
Problem: Cannot find module 'xxx'Solution:

Next Steps

Architecture Overview

Understand system design and data flow

Deployment Guide

Deploy to production with Docker or Railway

API Reference

Explore REST API endpoints

Back to Home

Return to homepage

Need Help? Check Troubleshooting or reach out to support@petservice.example.com