Appearance
Local Setup
Prerequisites
- Node.js 20+
- pnpm (9.x+)
- PostgreSQL (Homebrew:
brew install postgresql@17) - Docker (for RabbitMQ via Docker Compose)
- cloudflared (optional:
brew install cloudflared)
Installation
bash
git clone <repo-url> mtl-rent
cd mtl-rent
pnpm installDatabase Setup
bash
# Create the database
createdb mtl_rent
# Copy environment file
cp .env.example .env
# Edit .env if needed (DATABASE_URL, JWT_SECRET, RESEND_API_KEY, etc.)
# Run migrations
pnpm db:migrate
# Seed with sample data (neighborhoods + demo listings)
pnpm db:seedRabbitMQ Setup
RabbitMQ is the message broker for the scraper pipeline and email queue.
bash
# Start RabbitMQ via Docker Compose
docker compose up -dRabbitMQ Management UI is available at http://localhost:15672 (guest/guest by default).
Running
Services run via pm2 (not pnpm dev directly):
bash
# Start all services (API + Web + Admin + Docs + Scraper + Tunnel)
pm2 start pnpm --name "mtl-rent" --cwd /path/to/mtl-rent -- dev
# Check status
pm2 status
# Watch logs
pm2 logs mtl-rent
# Restart after code changes
pm2 restart mtl-rent
# After database schema changes
pnpm --filter @mtl-rent/database build && pm2 restart mtl-rent
# After migration changes
pnpm db:migrate && pm2 restart mtl-rentThis starts all services concurrently:
- API at http://localhost:3001 (Swagger docs at /docs)
- Web at http://localhost:3000
- Admin at http://localhost:3002
- Docs at http://localhost:5174
- Cloudflare Tunnel exposing all services publicly
The scraper worker runs as a separate pm2 process (mtl-scraper).
Environment Variables
| Variable | Default | Description |
|---|---|---|
DATABASE_URL | postgresql://localhost/mtl_rent | PostgreSQL connection string |
API_PORT | 3001 | Fastify API port |
JWT_SECRET | dev-secret-change-in-production | JWT signing secret |
NEXT_PUBLIC_API_URL | http://localhost:3001 | API URL for frontend |
NEXT_PUBLIC_GOOGLE_MAPS_API_KEY | — | Google Maps API key |
GOOGLE_MAPS_API_KEY | — | Google Maps API key (server-side geocoding) |
AMQP_URL | amqp://localhost:5672 | RabbitMQ connection for scraper pipeline |
ADMIN_USER | admin | Admin dashboard username |
ADMIN_PASS | admin | Admin dashboard password |
Useful Commands
bash
pm2 status # Check service status
pm2 logs mtl-rent # Watch logs
pm2 restart mtl-rent # Restart services
pnpm db:generate # Generate migrations from schema changes
pnpm db:migrate # Apply migrations
pnpm db:seed # Seed sample data
pnpm db:studio # Open Drizzle Studio
docker compose up -d # Start RabbitMQ
docker compose down # Stop RabbitMQ