Skip to content

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 install

Database 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:seed

RabbitMQ Setup

RabbitMQ is the message broker for the scraper pipeline and email queue.

bash
# Start RabbitMQ via Docker Compose
docker compose up -d

RabbitMQ 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-rent

This starts all services concurrently:

The scraper worker runs as a separate pm2 process (mtl-scraper).

Environment Variables

VariableDefaultDescription
DATABASE_URLpostgresql://localhost/mtl_rentPostgreSQL connection string
API_PORT3001Fastify API port
JWT_SECRETdev-secret-change-in-productionJWT signing secret
NEXT_PUBLIC_API_URLhttp://localhost:3001API URL for frontend
NEXT_PUBLIC_GOOGLE_MAPS_API_KEYGoogle Maps API key
GOOGLE_MAPS_API_KEYGoogle Maps API key (server-side geocoding)
AMQP_URLamqp://localhost:5672RabbitMQ connection for scraper pipeline
ADMIN_USERadminAdmin dashboard username
ADMIN_PASSadminAdmin 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