Guide - Environment Setup
This guide walks through every service that booki-api depends on and explains how to obtain the required credentials.
Quick Start
cp .env.example .env
# Then fill in the sections below
Variables already covered by the current backend defaults or existing .env.example entries (override them only if you need custom values):
| Variable | Purpose |
|---|---|
NODE_ENV, PORT | App environment and port |
MONGO_DB_DEV | Local database name fallback |
ACCESS_TOKEN_EXPIRY | JWT access token expiry |
REFRESH_TOKEN_EXPIRY | JWT refresh token expiry |
BOOKING_VERIFICATION_EXPIRY | Booking verification window |
TOKEN_EXPIRY | Owner/user verification expiry |
EMAIL_VERIFICATION_EXPIRY | Email verification expiry |
MAILER_TRANSPORT_* | Ethereal (test) email transport |
APP_ACCOUNT, FRONTEND_URL | Legacy frontend URL aliases |
OWNER_WEB_APP_URL | Owner app URL |
CUSTOMER_WEB_APP_URL | Customer app URL |
GOOGLE_REDIRECT_URI | Google OAuth callback URL |
DEFAULT_USER_* | Default admin seed credentials |
1. Redis
Redis is used for caching and session management.
REDIS_HOST=your-redis-host.redis.cloud
REDIS_PORT=12345
REDIS_PASSWORD=your-redis-password
REDIS_TLS=true
Set
REDIS_TLS=truefor Redis Cloud and production. Set tofalsefor local Redis.
Option A — Redis Cloud (recommended for beginners):
- Sign up at redis.com/try-free — free 30 MB tier.
- Create a database and copy host, port, and password into
.env.
Option B — Local Redis:
# macOS
brew install redis && brew services start redis
# Linux
sudo apt-get install redis-server && sudo systemctl start redis
# Windows — download from https://github.com/microsoftarchive/redis/releases
Local .env values:
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=
REDIS_TLS=false
For detailed Redis commands and cache patterns, see Redis Guide.
2. Maya
Maya is the payment gateway used for booking payments and subscription billing.
MAYA_PUBLIC_KEY=pk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
MAYA_SECRET_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
MAYA_API_URL=https://pg-sandbox.paymaya.com
MAYA_PAYMENT_EXPIRY=1440
- Obtain Maya sandbox credentials from the project supervisor or the Maya developer portal.
- Set
MAYA_API_URL=https://pg-sandbox.paymaya.comfor development. - Switch to
https://pg.paymaya.comfor production. MAYA_PAYMENT_EXPIRYis in minutes (default1440= 24 hours).
Use sandbox keys (
pk-Z0OS.../sk-aXQd...pattern) for development. Switch to live keys only in production.
3. Google OAuth
Required for Google Sign-In.
GOOGLE_CLIENT_ID=1084594124395-xxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-xxxxxxxxxxxxxxxxxxxxxxxxx
- Open console.cloud.google.com.
- Create or select a project.
- Go to APIs & Services → Library, search Google+ API, and enable it.
- Go to APIs & Services → Credentials → Create Credentials → OAuth 2.0 Client ID.
- Application type: Web application.
- Authorized redirect URIs:
http://localhost:3000/auth/google/callback(development)https://your-domain.com/auth/google/callback(production)
- Copy the Client ID and Client Secret.
4. Gmail SMTP
Used for transactional emails — booking confirmations, password resets, and notifications.
GMAIL_USER=your-email@gmail.com
GMAIL_APP_PASSWORD=xxxx xxxx xxxx xxxx
GMAIL_HOST=smtp.gmail.com
GMAIL_PORT=587
GMAIL_SECURE=false
ADMIN_EMAIL=admin@yourdomain.com
You need a Gmail App Password (not your regular Google password). App Passwords require 2-Step Verification to be enabled on the account.
For step-by-step instructions, see Gmail Setup Guide.
5. MongoDB
MONGO_URI=mongodb+srv://username:password@cluster.mongodb.net/
MONGO_DB=codiDev
- Create a free cluster at mongodb.com/cloud/atlas.
- Create a database user and whitelist your IP.
- Click Connect → Drivers and copy the connection string.
- Replace
username,password, and cluster inMONGO_URI. - Set
MONGO_DBto your database name.
6. Stripe and other runtime settings
The API also reads these optional settings when you enable payments or tighten defaults:
STRIPE_SECRET_KEY=sk_live_or_test_key
STRIPE_PUBLISHABLE_KEY=pk_live_or_test_key
STRIPE_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxxxxxxx
TIMEZONE=Asia/Manila
MAX_SLOTS_PER_TIME=3
CACHE_SHORT_TTL=300
CACHE_LONG_TTL=3600
BRANCH_INVITE_TOKEN_EXPIRY_DAYS=3
Use the defaults shown above unless your deployment needs different values.
Full .env Reference
The canonical variable reference lives in the Installation doc. The sections above explain how to obtain credentials for each service.
