This guide will help you set up the PairFlix project for local development.
- Docker and Docker Compose (latest version)
- Node.js (v18+)
- npm (v8+)
- Git
-
Clone the repository:
git clone <repository-url> cd pairflix
-
Environment Variables:
Create
.envfiles for both client apps and the backend:Backend (.env in backend/ directory):
NODE_ENV=development PORT=8000 JWT_SECRET=your_jwt_secret_key_change_this_in_production JWT_REFRESH_SECRET=your_refresh_secret_key_change_this_in_production JWT_EXPIRATION=1h JWT_REFRESH_EXPIRATION=7d DB_HOST=postgres DB_PORT=5432 DB_NAME=pairflix DB_USER=postgres DB_PASSWORD=postgres TMDB_API_KEY=your_tmdb_api_keyClient App (.env in app.client/ directory):
VITE_API_URL=http://localhost:8000/api/v1 VITE_TMDB_IMAGE_BASE_URL=https://image.tmdb.org/t/p ADMIN_TOKEN_KEY=admin_tokenAdmin App (.env in app.admin/ directory):
VITE_API_URL=http://localhost:8000/api/v1 VITE_TMDB_IMAGE_BASE_URL=https://image.tmdb.org/t/p ADMIN_TOKEN_KEY=admin_token -
Start the development environment with Docker Compose:
docker-compose up
This will start:
- PostgreSQL database on port 5432
- Backend API server on port 3000
- Client app on port 5173
- Admin app on port 5174
Note: The Docker build now uses multi-stage builds to build the component library before building the client and admin apps.
-
Database Initialization:
The database will be automatically set up with seeds for two users.
Default credentials:
- User 1:
user1@example.com/password123 - User 2:
user2@example.com/password123
- User 1:
The project uses a shared component library located in lib.components/. This library provides standardized UI components used by both the client and admin applications.
-
Component Library Changes:
If you make changes to components in the library, you need to rebuild to see the changes in the apps:
cd lib.components npm run build -
Using Components from the Library:
Import components using the path alias:
// In app.client or app.admin import { Button, Card, DataTable } from '@lib.components';
-
Adding New Components to the Library:
Add new components to the library when they are reusable across applications:
# Create component files in lib.components/src/components # Export them in lib.components/src/index.ts # Build the library cd lib.components npm run build
If you prefer to run components without Docker:
Component Library:
cd lib.components
npm install
npm run buildBackend:
cd backend
npm install
npm run devClient App:
cd app.client
npm install
npm run devAdmin App:
cd app.admin
npm install
npm run devBackend Tests:
cd backend
npm test # Run all tests
npm test:watch # Run tests in watch mode
npm test:coverage # Run tests with coverage reportClient App Tests:
cd app.client
npm test # Run all tests
npm test:watch # Run tests in watch mode
npm test:coverage # Run tests with coverage reportAdmin App Tests:
cd app.admin
npm test # Run all tests
npm test:watch # Run tests in watch mode
npm test:coverage # Run tests with coverage reportThe project uses ESLint and Prettier for code quality:
# Backend
cd backend
npm run lint # Check for linting issues
npm run lint:fix # Fix linting issues
npm run format # Format code with Prettier
# Client App
cd app.client
npm run lint # Check for linting issues
npm run lint:fix # Fix linting issues
npm run format # Format code with Prettier
# Admin App
cd app.admin
npm run lint # Check for linting issues
npm run lint:fix # Fix linting issues
npm run format # Format code with PrettierThe API documentation is available at /api-docs when running the backend server.
Connect to the PostgreSQL database:
docker-compose exec postgres psql -U postgres -d pairflix# Inside the backend container
docker-compose exec backend npm run db:migrate# Inside the backend container
docker-compose exec backend npm run db:migrate:create -- --name your_migration_nameThe application uses The Movie Database (TMDb) API for content metadata.
To use it:
- Register for an account on TMDb
- Generate an API key
- Add the key to your backend
.envfile
-
Database Connection Issues
- Ensure PostgreSQL is running:
docker-compose ps - Check database logs:
docker-compose logs postgres - Verify database environment variables in backend
.env
- Ensure PostgreSQL is running:
-
API Connection Issues
- Check that backend is running:
docker-compose ps - Verify API URL in client and admin app
.envfiles - Check CORS settings if modifying API origins
- Check that backend is running:
-
Docker Issues
- Restart with fresh containers:
docker-compose down && docker-compose up - Rebuild images:
docker-compose build --no-cache
- Restart with fresh containers:
-
Component Library Issues
-
If changes to the component library aren't reflecting in the apps:
- Ensure you've built the library:
cd lib.components && npm run build - Check path aliases in tsconfig.json of the app
- Verify the component is properly exported in the library index.ts
- Ensure you've built the library:
-
If Docker builds fail with npm errors related to
@pairflix/components:- The multi-stage Docker build should handle this automatically
- If issues persist, rebuild with no cache:
docker-compose build --no-cache
-
If you encounter issues not covered here, please:
- Check existing issues in the project repository
- Create a new issue with details about the problem
- Include relevant logs and environment information