Getting Started – Configuration

Introduction

Before you can start using the platform, you need to set up the core configuration. This guide walks you through the essential settings, environment variables, and best practices for a secure and scalable setup.

Prerequisites

  • Node.js ≥ 18.x
  • Docker ≥ 20.10
  • Access to a PostgreSQL database
  • Basic knowledge of YAML/JSON

Environment Variables

Create a .env file in the project root:

# .env
APP_PORT=3000
DB_HOST=localhost
DB_PORT=5432
DB_USER=admin
DB_PASSWORD=SuperSecret
JWT_SECRET=YourJWTSecretKeyHere
LOG_LEVEL=info

YAML Configuration File

Advanced settings are stored in config.yaml:

# config.yaml
server:
  host: 0.0.0.0
  port: ${APP_PORT}
logging:
  level: ${LOG_LEVEL}
  format: json
database:
  url: postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/appdb
security:
  jwtSecret: ${JWT_SECRET}
  tokenExpiration: 1h
features:
  enableAnalytics: true
  enableEmail: false

Docker Compose Setup

Spin up the whole stack with a single command:

# docker-compose.yml
version: "3.9"
services:
  app:
    image: myapp:latest
    env_file: .env
    ports:
      - "${APP_PORT}:3000"
    volumes:
      - ./config.yaml:/app/config.yaml
    depends_on:
      - db
  db:
    image: postgres:15-alpine
    environment:
      POSTGRES_USER: ${DB_USER}
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_DB: appdb
    volumes:
      - pgdata:/var/lib/postgresql/data
volumes:
  pgdata:

Validate Configuration

Run the built‑in validator to ensure all required fields are set:

# npm run config:validate
✔ Environment variables loaded
✔ config.yaml parsed successfully
✔ All required keys present