Skip to main content

Development Setup

Active development

Moonlight is in active development. Dependencies, environment variables and the docker-compose layout below match the current state of the repo and are reviewed as the stack evolves. If something here drifts from what you see in the codebase, the codebase wins.

Prerequisites

  • Node.js 20+
  • Docker & Docker Compose
  • npm (backend), pnpm (frontend)

Quick Start

1. Start Infrastructure

docker-compose up

This starts:

  • PostgreSQL (port 9432) — main database
  • PostgreSQL (port 9433) — test database
  • Pub/Sub emulator (port 8085) — Google Cloud Pub/Sub stand-in for ingest, accounting-sync, scheduler-tick topics
  • MinIO (ports 9000/9001) — S3-compatible file storage
  • Flyway — database migrations (run automatically)

2. Start Backend

cd moonlight-server
cp .env.example .env
npm install
npm run start:dev

Server runs at http://localhost:3000.

API docs available at http://localhost:3000/api/docs.

3. Start Frontend

cd moonlight-ui
cp .env.example .env
pnpm install
pnpm dev

UI runs at http://localhost:5173.

4. Test Login

Email: [email protected]
Password: password123

(These credentials are created by sample/sample-data.sql)

Database

Connection

ParameterValue
Hostlocalhost
Port9432
Usermoon
Passwordmoonpass
Databasemoon_db

Migrations

Schema is managed by Flyway. To add a new migration:

# Create a new migration file
touch flyway/migrations/V10__description.sql

# Restart docker-compose to apply
docker-compose down && docker-compose up

Seeding

Load sample data:

psql -h localhost -p 9432 -U moon -d moon_db -f sample/sample-data.sql

Environment Variables

Backend (moonlight-server/.env)

VariableDefaultDescription
PORT3000Server port
DB_HOSTlocalhostDatabase host
DB_PORT9432Database port
DB_USERmoonDatabase user
DB_PASSmoonpassDatabase password
DB_NAMEmoon_dbDatabase name
JWT_SECRETJWT signing secret
PUBSUB_PROJECT_IDmoonlight-localPub/Sub project id (matches docker-compose --project)
PUBSUB_EMULATOR_HOSTlocalhost:8085Emulator address; unset in production to talk to real Pub/Sub
PUBSUB_AUTO_CREATEtrueAuto-create topics/subscriptions on app boot (set false in prod when infra is provisioned)
LOCAL_SCHEDULER_ENABLED(auto)Enables local scheduler that publishes periodic ticks; defaults to true when emulator is set
S3_ENDPOINThttp://localhost:9000S3/MinIO endpoint
S3_BUCKETmoonlightS3 bucket name
S3_ACCESS_KEYminioadminS3 access key
S3_SECRET_KEYminioadminS3 secret key
S3_REGIONus-east-1S3 region
OPENAI_API_KEYOpenAI key for OCR (optional)

Frontend (moonlight-ui/.env)

VariableDefaultDescription
VITE_API_URLhttp://localhost:3000Backend API URL