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
- Frontend
Backend Setup
Step 1: Environment Configuration
Create a.env file in the backend/ directory:
.env
Step 2: Database Setup
1
Create PostgreSQL Database
2
Generate Prisma Client
3
Apply Database Schema
prisma/schema.prisma.4
Verify Database
http://localhost:5555 to inspect your database.Step 3: Seed Database (Optional)
Seeding creates sample data for development and testing.
- Admin user (email:
[email protected], password:admin123) - Manager user (email:
[email protected], password:manager123) - Staff user (email:
[email protected], 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:3001Frontend 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- Open
http://localhost:3000in your browser - Navigate to
/enor/vifor localized content - Try logging in with seeded credentials
Database Management
Common Commands
Database Schema
The database includes the following main entities:User & Authentication
User & Authentication
- User: Core user accounts with roles (ADMIN, MANAGER, STAFF, CUSTOMER)
- Session: Active user sessions
- Account: OAuth provider accounts
- Verification: Email verification tokens
Booking System
Booking System
- Booking: Main booking records with status tracking
- BookingPet: Junction table linking bookings to pets
- BookingService: Junction table linking bookings to services with pricing
Pet Management
Pet Management
- Pet: Pet profiles with medical history, vaccinations, allergies
- Supports multiple images
- JSON-based vaccination records
Service & Staff
Service & Staff
- Service: Service catalog with JSONB multi-language fields
- Staff: Employee profiles with working hours and specializations
- StaffService: Junction table with proficiency levels
System
System
- Setting: Key-value configuration store with JSONB values
- AuditLog: Complete audit trail of user actions
Environment Variables Reference
Backend Environment Variables
| Variable | Required | Description | Example |
|---|---|---|---|
DATABASE_URL | ✅ | PostgreSQL connection string | postgresql://user:pass@localhost:5432/db |
NODE_ENV | ✅ | Environment mode | development, production |
PORT | ✅ | Backend server port | 3001 |
BETTER_AUTH_URL | ✅ | Better Auth endpoint | http://localhost:3001/api/auth |
BETTER_AUTH_SECRET | ✅ | Better Auth secret (32+ chars) | Generated string |
SESSION_SECRET | ✅ | Session encryption secret | Generated string |
JWT_SECRET | ✅ | JWT signing secret | Generated string |
FRONTEND_URL | ✅ | Frontend URL for CORS | http://localhost:3000 |
SMTP_HOST | ❌ | Email server host | smtp.gmail.com |
SMTP_PORT | ❌ | Email server port | 587 |
SMTP_USER | ❌ | Email username | [email protected] |
SMTP_PASS | ❌ | Email password | Your password |
Frontend Environment Variables
| Variable | Required | Description | Example |
|---|---|---|---|
NEXT_PUBLIC_API_URL | ✅ | Backend API URL | http://localhost:3001 |
NEXT_PUBLIC_APP_URL | ✅ | Frontend app URL | http://localhost:3000 |
GOOGLE_CLIENT_ID | ❌ | Google OAuth client ID | From Google Console |
GOOGLE_CLIENT_SECRET | ❌ | Google OAuth secret | From Google Console |
GITHUB_CLIENT_ID | ❌ | GitHub OAuth client ID | From GitHub Settings |
GITHUB_CLIENT_SECRET | ❌ | GitHub OAuth secret | From GitHub Settings |
Code Quality & Testing
Linting & Formatting
Type Checking
Running Tests
- Backend
- Frontend
Troubleshooting
Database Connection Error
Database Connection Error
Problem:
connect ECONNREFUSED 127.0.0.1:5432Solution:- Ensure PostgreSQL is running:
brew services start postgresql(macOS) - Check
DATABASE_URLin.env - Verify credentials:
psql -U postgres - Check PostgreSQL logs:
tail -f /usr/local/var/log/postgres.log
Port Already in Use
Port Already in Use
Problem:
Error: listen EADDRINUSE: address already in use :::3000Solution:Missing Environment Variables
Missing Environment Variables
Problem: Application crashes with undefined env variablesSolution:
- Copy example env files to
.env/.env.local - Ensure all required variables are set
- Restart development server
Prisma Client Not Generated
Prisma Client Not Generated
Problem:
PrismaClient not foundSolution:Module Not Found
Module Not Found
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 [email protected]