Skip to content

Configuration

Overview

The Core package provides centralized configuration management through environment variables, constants, event channel definitions, and queue definitions. All services inherit these configurations for consistent behavior across the entire BANA platform.

SectionDescription
ConstantsStatic constants, enumerations, and schema definitions
Environment VariablesComplete environment variable reference
EventsEvent definitions and payload types for cross-service communication
Cross-Package Messaging (Kafka / CDC)Kafka domain-event + Debezium CDC topic contracts

Directory Structure

packages/core/src/common/
├── index.ts              # All exports
├── environments.ts       # Environment key definitions (re-exported via keys.ts)
├── constants.ts          # Static constants
├── decorators.ts         # Custom decorators
├── validations.ts        # Validation utilities
├── events/               # Event definitions
│   ├── index.ts
│   ├── commerce-events.ts
│   ├── ledger-events.ts
│   ├── payment-events.ts
│   └── websocket-events.ts
├── kafka/                # Kafka topic + message contracts
│   ├── index.ts
│   ├── topics.ts         # KafkaTopics + CDCKafkaTopics
│   └── types.ts
└── cdc/                  # Debezium CDC table constants
    ├── index.ts
    └── tables.ts

Environment Variables

The EnvironmentKeys class extends Ignis Framework's base keys with application-specific configuration:

typescript
import { EnvironmentKeys as BaseEnvironmentKeys } from '@venizia/ignis';

export class EnvironmentKeys extends BaseEnvironmentKeys {
  // Application
  static readonly APP_ENV_NODE_ENV = 'APP_ENV_NODE_ENV';
  static readonly APP_ENV_APPLICATION_EXPLORER_URL = 'APP_ENV_APPLICATION_EXPLORER_URL';

  // Database
  static readonly APP_ENV_POSTGRES_HOST = 'APP_ENV_POSTGRES_HOST';
  static readonly APP_ENV_POSTGRES_PORT = 'APP_ENV_POSTGRES_PORT';
  // ... more keys
}

Categories

CategoryExamplesDescription
ApplicationAPP_ENV_NODE_ENV, APP_ENV_APPLICATION_NAMECore app settings
DatabaseAPP_ENV_POSTGRES_HOST, APP_ENV_POSTGRES_PORTPostgreSQL connection
Redis/BullMQAPP_ENV_BULLMQ_REDIS_HOSTJob queue connection
StorageAPP_ENV_MINIO_HOST, APP_ENV_MINIO_ACCESS_KEYMinIO/S3 storage
MailAPP_ENV_MAIL_HOST, APP_ENV_MAIL_USERSMTP configuration
ID GenerationAPP_ENV_SNOWFLAKE_WORKER_IDSnowflake ID config
ServicesAPP_ENV_IDENTITY_SERVICE_BASE_URLInter-service URLs

View all Environment Variables -->

Constants

Static configuration values used across the application:

PostgreSQL Schemas

typescript
export class PostgresSchemas {
  static readonly PUBLIC = 'public';
  static readonly PRICING = 'pricing';
  static readonly ALLOCATION = 'allocation';
  static readonly SALE = 'sale';
  static readonly INVENTORY = 'inventory';
  static readonly FINANCE = 'finance';
  static readonly PAYMENT = 'payment';
}

Fixed User Roles

typescript
export class FixedUserRoles {
  static readonly SUPER_ADMIN = '999-super-admin';
  static readonly ADMIN = '998-admin';
  static readonly OPERATOR = '997-operator';
  static readonly ORGANIZER_OWNER = '899-organizer-owner';
  static readonly EMPLOYEE = '898-employee';

  static readonly ALWAYS_ALLOW_ROLES = new Set([
    FixedUserRoles.SUPER_ADMIN,
    FixedUserRoles.ADMIN,
  ]);
}

View all Constants -->

Events

Typed event definitions for cross-service communication, published/subscribed via the event bus (IEventBus, Redis Pub/Sub adapter). Defined in src/common/events/: commerce-events.ts, ledger-events.ts, payment-events.ts, websocket-events.ts.

The exact event-class list below is a partial snapshot — see Events and the source files for the current set.

WebSocket Utilities

ClassDescription
WebSocketRoomsBuild standardized room identifiers (wr:{prefix}/{paths})
WebSocketTopicsBuild standardized topic identifiers (ws:{paths})

View all Events -->

Cross-Package Messaging (Kafka / CDC)

The cross-package seam is Kafka (domain events) and Debezium CDC, not a BullMQ queue subsystem. Topic constants live in src/common/kafka/topics.ts.

ClassPurpose
KafkaTopicsDomain-event topic names + build({ paths }) prefixer (nx.seller)
CDCKafkaTopicsDebezium CDC topic names built from CdcTables

View Cross-Package Messaging -->

Usage

Access Environment Variables

typescript
import { applicationEnvironment } from '@venizia/ignis';
import { EnvironmentKeys } from '@nx/core';

// Get required variable
const dbHost = applicationEnvironment.get<string>(EnvironmentKeys.APP_ENV_POSTGRES_HOST);

// Get with default
const port = applicationEnvironment.get<number>(EnvironmentKeys.APP_ENV_POSTGRES_PORT) ?? 5432;

Use Constants

typescript
import { FixedUserRoles, DeviceTypes, PostgresSchemas } from '@nx/core';

// Role checking
if (userRoles.includes(FixedUserRoles.SUPER_ADMIN)) {
  // Super admin logic
}

// Device type validation
if (DeviceTypes.isValid(device.type)) {
  // Valid device type
}

// Schema reference
const schema = PostgresSchemas.PRICING;

Configuration Flow

Best Practices

1. Use Type-Safe Keys

typescript
// Good -- type-safe
const host = applicationEnvironment.get<string>(EnvironmentKeys.APP_ENV_POSTGRES_HOST);

// Bad -- error-prone
const host = process.env.APP_ENV_POSTGRES_HOST;

2. Validate Required Configuration

typescript
// At application startup
function validateConfig() {
  const required = [
    EnvironmentKeys.APP_ENV_POSTGRES_HOST,
    EnvironmentKeys.APP_ENV_POSTGRES_DATABASE,
    EnvironmentKeys.APP_ENV_SNOWFLAKE_WORKER_ID,
  ];

  for (const key of required) {
    if (!applicationEnvironment.get(key)) {
      throw new Error(`Missing required environment variable: ${key}`);
    }
  }
}

3. Use Constants for Magic Values

typescript
// Good -- use constant
if (user.role === FixedUserRoles.SUPER_ADMIN) { }

// Bad -- magic string
if (user.role === '999-super-admin') { }

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.