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 pre-configured in .env.example (no action needed for local dev):
| Variable | Purpose |
|---|---|
NODE_ENV, PORT | App environment and port |
ACCESS_TOKEN_EXPIRY | JWT expiry duration |
MAILER_TRANSPORT_* | Ethereal (test) email transport |
APP_ACCOUNT, FRONTEND_URL | Frontend URLs |
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.
Full .env Reference
The canonical variable reference lives in the Installation doc. The sections above explain how to obtain credentials for each service.
