A fully containerized, production-grade monorepo featuring Next.js 15, Nest.js 10, shared packages, and complete CI/CD pipelines.
- Frontend: Next.js 15, React 18, TailwindCSS, TypeScript
- Backend: Nest.js 10, Prisma ORM, PostgreSQL
- Monorepo: Turborepo, npm workspaces
- Container: Docker, Docker Compose
- CI/CD: GitHub Actions
- Reverse Proxy: Nginx
- Code Quality: ESLint, Prettier, TypeScript strict mode
elevra/
βββ apps/
β βββ frontend/ # Next.js application
β βββ backend/ # Nest.js API
βββ packages/
β βββ ui/ # Shared React components
β βββ utils/ # Shared utilities
β βββ eslint-config/ # Shared ESLint config
βββ infra/
β βββ nginx/ # Reverse proxy configuration
βββ .github/workflows/ # CI/CD pipelines
βββ scripts/ # Deployment & setup scripts
- Node.js 20.x or higher
- npm 11.2.0 or higher
- Docker & Docker Compose (for containerized development)
- Git
1.Clone the repository
```bash
git clone <repository-url>
cd elevra
```
-
Run setup script
chmod +x scripts/setup.sh ./scripts/setup.sh
-
Configure environment variables
cp .env.example .env # Edit .env with your configuration -
Start development
# Option 1: Local development npm run dev # Option 2: Docker development npm run docker:dev
# Install all dependencies
npm install
# Start all apps in development mode
npm run dev
# Run specific workspace
npm run dev:frontend
npm run dev:backend
# Type checking
npm run type-check
# Linting
npm run lint
npm run lint:fix
# Format code
npm run formatServices will be available at:
- Frontend: http://localhost:3000
- Backend: http://localhost:4000
# Start all services with hot reload only backend
npm run docker:dev
# View logs
docker compose logs -f
# Stop services
npm run docker:down
# Rebuild services
docker compose -f docker-compose.dev.yml up --buildServices available at:
- Frontend: http://localhost:3000
- Backend: http://localhost:4000
- PostgreSQL: localhost:5432
# Generate Prisma client
cd apps/backend
npx prisma generate
# Create migration
npx prisma migrate dev --name your_migration_name
# Apply migrations
npx prisma migrate deploy
# Open Prisma Studio
npx prisma studionpm run buildnpm run build:frontend
npm run build:backend# Build and start with Docker
npm run docker:prod
# Health check
npm run health-check-
Server Requirements
- Ubuntu 20.04+ or similar Linux distribution
- Docker & Docker Compose installed
- Domain name configured
- SSL certificates (Let's Encrypt recommended)
-
Environment Setup
- Copy
.env.exampleto.env - Update all production values
- Generate strong
JWT_SECRET(min 32 characters) - Configure
DATABASE_URLwith production credentials - Set
CORS_ORIGINSto your production domains
- Copy
# Make deploy script executable
chmod +x scripts/deploy.sh
# Run deployment
./scripts/deploy.sh-
Configure GitHub Secrets
Navigate to:
Settings β Secrets and variables β ActionsAdd the following secrets:
DEPLOY_HOST: Your production server IP/domainDEPLOY_USER: SSH usernameDEPLOY_SSH_KEY: Private SSH key for deploymentPRODUCTION_URL: Your production URL (for health checks)
-
Push to main branch
git push origin main
This will automatically:
- Run CI checks (lint, type-check, build, test)
- Build Docker images
- Push to GitHub Container Registry
- Deploy to production server
- Run health checks
# Check service status
docker compose -f docker-compose.prod.yml ps
# View logs
docker compose -f docker-compose.prod.yml logs -f
# Run health checks
./scripts/health-check.sh# Run all tests
npm run test
# Run tests for specific workspace
npm run test --workspace=@elevra/backend
# Run tests with coverage
npm run test:cov --workspace=@elevra/backend
# Watch mode
npm run test:watch --workspace=@elevra/backendThe project uses a strict ESLint configuration with:
- TypeScript recommended rules
- Strict type checking
- No explicit
anytypes - Unused variable detection
# Run linter
npm run lint
# Fix auto-fixable issues
npm run lint:fixConsistent code formatting with Prettier:
# Check formatting
npm run format:check
# Format all files
npm run formatGit hooks are automatically set up to:
- Run linter and fix issues
- Format code with Prettier
- Ensure code quality before commits
The turbo.json defines task dependencies and caching:
- build: Depends on dependencies being built first, caches outputs
- dev: No caching, persistent for development
- lint: Can run in parallel
- type-check: Validates TypeScript types
- test: Runs after build, caches coverage
# Create package directory
mkdir packages/new-package
cd packages/new-package
# Initialize package
npm init -y
# Add to workspace
# Package is automatically recognized due to workspace configuration
# Create tsconfig.json extending base
cat > tsconfig.json << 'EOF'
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist"
},
"include": ["src"]
}
EOF
# Install in other packages
cd ../ui
npm install @elevra/new-package@*All Dockerfiles use multi-stage builds for:
- deps: Install production dependencies
- builder: Build the application
- runner: Minimal runtime image
Benefits:
- Smaller image sizes
- Faster builds with layer caching
- Secure production images (no dev dependencies)
Development (docker-compose.dev.yml):
- Hot reload with volume mounts
- Source code mounted for instant updates
- Exposed ports for debugging
- Development environment variables
Production (docker-compose.prod.yml):
- Optimized production builds
- No volume mounts (immutable containers)
- Nginx reverse proxy
- Health checks enabled
- Automatic restarts
This monorepo follows security best practices:
- β
No
anytypes in TypeScript - β Strict TypeScript configuration
- β Input validation with class-validator
- β CORS properly configured
- β Security headers (X-Frame-Options, CSP, etc.)
- β Rate limiting in Nginx
- β Environment variable validation
- β Non-root user in containers
- β Multi-stage builds
- β Minimal base images (Alpine)
- β No secrets in images
- β Health checks enabled
- Update all default passwords
- Generate strong JWT_SECRET (min 32 chars)
- Configure SSL certificates
- Set up proper CORS origins
- Enable firewall rules
- Configure backup strategy
- Set up monitoring (Sentry, etc.)
- Review and update rate limits
# View all logs
docker compose logs -f
# View specific service
docker compose logs -f backend
docker compose logs -f frontend
# Follow last 100 lines
docker compose logs -f --tail=100# Backend health
curl http://localhost:4000/health
# Frontend health
curl http://localhost:3000
# Automated health check
./scripts/health-check.shConfigure via LOG_LEVEL environment variable:
debug: All logsinfo: Info, warnings, errorswarn: Warnings and errorserror: Errors only
# Find process using port
lsof -i :3000
lsof -i :4000
lsof -i :5432
# Kill process
kill -9# Remove all containers and volumes
docker compose down --volumes --remove-orphans
# Rebuild without cache
docker compose build --no-cache
# Prune Docker system
docker system prune -a# Check if PostgreSQL is running
docker compose ps postgres
# Check database logs
docker compose logs postgres
# Connect to database
docker compose exec postgres psql -U dev -d elevra_dev# Clean install
npm run clean
rm -rf node_modules package-lock.json
npm install
# Or clean specific workspace
npm run clean --workspace=@elevra/frontendmain: Production-ready codedevelop: Development branchfeature/*: New featuresbugfix/*: Bug fixeshotfix/*: Emergency production fixes
Follow conventional commits:
feat: add user authentication
fix: resolve CORS issue in production
docs: update deployment guide
chore: upgrade dependencies
refactor: improve error handling
test: add unit tests for utils
- Create feature branch from
main - Make changes and commit
- Push branch and create PR
- Ensure CI passes
- Request code review
- Merge after approval
- Turborepo Documentation
- Next.js Documentation
- Nest.js Documentation
- Prisma Documentation
- Docker Documentation
# Package management
npm install # Install in root
npm install -w @elevra/frontend # Install in workspace
# Workspace commands
npm run --workspace= # Run script in workspace
npm run --workspaces # Run in all workspaces
# Docker commands
docker compose up -d # Start in background
docker compose restart # Restart service
docker compose exec sh # Access container shell
# Database commands
npx prisma studio # Open Prisma Studio
npx prisma db push # Push schema changes
npx prisma db seed # Seed databaseMIT License - see LICENSE file for details
- Maintainer: Aniket Rathod
- Email: aniketnr5023@gmail.com
- Repository: https://github.com/aniirathod/Elevra.git
Built with β€οΈ test test