Running the Backend
The backend is a Node.js + Express 5 API server located in demo-server/. It runs on port 6600 and requires PostgreSQL and Redis.
Prerequisites
- PostgreSQL 18 running and accessible
- Redis 6+ running locally (see Redis Setup)
1. Install dependencies
cd demo-server
npm install
2. Configure environment
cp .env.example .env
At minimum, fill in:
# Database
DB_HOST=localhost
DB_PORT=5432
DB_USER=your_user
DB_PASSWORD=your_password
DB_NAME=primesaas
# App
CLIENT_URL=http://localhost:3300
NODE_ENV=development
# Secrets (generate with: openssl rand -hex 32)
TOKEN_SECRET=your_jwt_secret
REFRESH_SECRET=your_refresh_secret
# Payment gateway (lemonsqueezy | stripe)
PAYMENT_GATEWAY=lemonsqueezy
See Database Setup and Lemon Squeezy Setup for the full configuration.
3. Run database migrations
npm run migrate
This runs all Knex migrations in migrations/ against your database.
4. Start the dev server
npm run dev
The API will be available at http://localhost:6600.
Production start
npm run start
This runs migrations and then starts the server — safe to use as a deploy command.
API structure
All routes are prefixed with /:
| Route group | Description |
|---|---|
/auth | Sign in, sign up, magic links, 2FA |
/account | User account management |
/accounts | Multi-tenant account management |
/payments | Payment history and invoices |
/checkout | Initiate checkout flow |
/subscription | Subscription management |
/plans | Pricing plan catalog |
/api-keys | API key CRUD |
/webhooks | Customer-registered webhooks |
/webhooks/stripe | Stripe payment webhooks |
/webhooks/lemonsqueezy | Lemon Squeezy payment webhooks |
/media | File upload and management |
/health | Health check endpoint |
Tech stack
- Express 5 REST API
- Knex.js query builder + migrations
- Argon2 password hashing
- JWT (access + refresh tokens)
- BullMQ background job queues
- Mailgun transactional email
- AWS S3 file storage
- Sentry error tracking