This guide will help you set up your development environment for contributing to Mezon.
-
Node.js: Version 18.17.0 or higher
- Download from nodejs.org
- Verify:
node --version
-
Yarn: Version 1.22.17 or higher
- Install:
npm install -g yarn - Verify:
yarn --version
- Install:
-
Git: Latest version
- Download from git-scm.com
- Configure:
git config --global user.name "Your Name" git config --global user.email "your.email@example.com"
-
Nx CLI: Latest version
- Install:
npm install -g @nx/cli - Verify:
nx --version
- Install:
-
VS Code: Primary IDE with extensions:
- ESLint
- Prettier
- TypeScript and JavaScript Language Features
- Nx Console
- GitLens
- Auto Rename Tag
- Bracket Pair Colorizer
-
Git Bash (Windows users): For consistent command line experience
# Clone the main repository
git clone https://github.com/mezonai/mezon.git
cd mezon
# Or clone your fork
git clone https://github.com/YOUR_USERNAME/mezon.git
cd mezon# Install all project dependencies
yarn install
# This will install dependencies for all apps and libraries
# May take 3-5 minutes on first runCreate environment files for each application:
# Create .env file in apps/chat/
touch apps/chat/.envAdd the following variables to apps/chat/.env:
# API Configuration
VITE_API_BASE_URL=http://localhost:3000/api
VITE_WS_URL=ws://localhost:3000/ws
# Authentication
VITE_JWT_SECRET=your-jwt-secret-key
# Feature Flags
VITE_ENABLE_AI_FEATURES=true
VITE_ENABLE_VOICE_CHAT=true
# Analytics (optional)
VITE_ANALYTICS_ID=your-analytics-id
# Debug Mode
VITE_DEBUG_MODE=true# Create .env file in apps/admin/
touch apps/admin/.envAdd to apps/admin/.env:
VITE_API_BASE_URL=http://localhost:3000/api
VITE_ADMIN_SECRET=your-admin-secretStart the development server:
# Start chat application
yarn dev:chat
# Or start admin application
yarn dev:admin
# Or start all applications
yarn dev:allThe applications will be available at:
- Chat: http://localhost:4200
- Admin: http://localhost:4201
Create .vscode/settings.json:
{
"typescript.preferences.importModuleSpecifier": "relative",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.organizeImports": true
},
"eslint.workingDirectories": [
"apps/chat",
"apps/admin",
"libs"
],
"typescript.preferences.includePackageJsonAutoImports": "off",
"files.exclude": {
"**/node_modules": true,
"**/dist": true,
"**/.nx": true
}
}Create .vscode/extensions.json:
{
"recommendations": [
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"ms-vscode.vscode-typescript-next",
"nrwl.angular-console",
"eamodio.gitlens",
"formulahendry.auto-rename-tag",
"bradlc.vscode-tailwindcss"
]
}# Always work on feature branches
git checkout -b feature/your-feature-name
# Keep your branch up to date
git fetch origin
git rebase origin/mainRun code quality checks before committing:
# Type checking
yarn typecheck
# Linting
yarn lint
# Fix linting issues
yarn lint:fix
# Format code
yarn format
# Fix formatting issues
yarn format:fix# Run all tests
yarn test
# Run tests in watch mode
yarn test:watch
# Run tests with coverage
yarn test:coverage
# Run specific test file
yarn test apps/chat/src/components/MessageList.test.tsx# Build chat application
nx build chat
# Build admin application
nx build admin
# Build all applications
nx run-many --target=build --all
# Build with production optimizations
nx build chat --prod# Add dependency to specific project
yarn add package-name --dev
nx add package-name --project=chat
# Remove dependency
yarn remove package-name
# Update dependencies
yarn upgrade
# Check for outdated packages
yarn outdated- Open Chrome DevTools (F12)
- Go to Sources tab
- Enable source maps for debugging TypeScript
- Set breakpoints in your code
Create .vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Chat App",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}/apps/chat/src",
"sourceMapPathOverrides": {
"webpack:///./src/*": "${webRoot}/*"
}
}
]
}If you encounter network issues:
# Clear Nx cache
nx reset
# Clear yarn cache
yarn cache clean
# Delete node_modules and reinstall
rm -rf node_modules
yarn installIf working on backend features:
# Install Docker for database
# Run PostgreSQL container
docker run --name mezon-db -e POSTGRES_PASSWORD=password -p 5432:5432 -d postgres
# Run database migrations
yarn db:migrate
# Seed development data
yarn db:seed# Enable webpack bundle analyzer
ANALYZE=true yarn build chat
# Use faster builds in development
yarn dev:chat --skip-nx-cacheIf you encounter memory issues:
# Increase Node.js memory limit
export NODE_OPTIONS="--max-old-space-size=8192"
# Or add to your shell profile
echo 'export NODE_OPTIONS="--max-old-space-size=8192"' >> ~/.bashrc# Ensure all dependencies are installed
yarn install
# Clear Nx cache
nx reset
# Check tsconfig paths# Fix npm permissions
sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib/node_modules# Use Git Bash instead of Command Prompt
# Enable Developer Mode in Windows 10/11
# Run as Administrator if needed# Kill process using port 4200
npx kill-port 4200
# Or use different port
yarn dev:chat --port 4201- Documentation: Check existing docs first
- Issues: Search GitHub issues
- Community: Join our developer community
- Discussions: Use GitHub Discussions for questions
Once your environment is set up:
- Read the Architecture Guide
- Review the Style Guide
- Check the Contributing Guidelines
- Pick a "good first issue" from GitHub
- Start coding! π
Run this checklist to verify your setup:
# β
Check Node.js version
node --version # Should be 18.17.0+
# β
Check Yarn version
yarn --version # Should be 1.22.17+
# β
Check Nx CLI
nx --version # Should be latest
# β
Install dependencies
yarn install # Should complete without errors
# β
Type checking
yarn typecheck # Should pass
# β
Linting
yarn lint # Should pass
# β
Tests
yarn test # Should pass
# β
Build
nx build chat # Should complete successfully
# β
Start development server
yarn dev:chat # Should start on http://localhost:4200If all steps pass, you're ready to develop! π