Skip to content

Core Package

@nx/core is the foundation library of the BANA monorepo. It is not a microservice — it ships no runtime of its own. Every other backend package imports and extends it, so core must be built first.

This is a light-touch identity card. Core legitimately deviates from the standard 8-file service template — its mature structure (architecture, components/*, configuration/*, database/*, utilities/*) is documented in the linked sub-pages below.

Identity Card

PropertyValue
Package@nx/core
TypeShared library / framework extension (no standalone runtime)
Snowflake worker ID0 (reserved for core)
FrameworkIGNIS (@venizia/ignis, @venizia/ignis-helpers)
RuntimeBun
ORMDrizzle ORM + node-postgres (PostgreSQL)
Buildbun run rebuild (clean + tsc + tsc-alias) — never raw tsc
Sourcepackages/core/src/

What Core Provides

CapabilityWhat it isLives in
Base application classesBaseApplication (shared middleware), IssuerApplication (JWKS issuer, ES256 — Identity), VerifierApplication (JWKS verifier — all other services), DefaultApplication (legacy symmetric JWT)src/application/
Bootstrap helpersbootstrapApplication(), bootstrapMigration(), createAppConfig(), createMigrationProcessLoader()src/helpers/bootstraps/, src/common/app-config.ts
Centralized Drizzle schemasThe single home for every schema in the monorepo — <domain>/<entity>/{schema.ts, model.ts, constants.ts, index.ts} across 14 domainssrc/models/schemas/<domain>/<entity>/
Shared column defsgenerateCommonColumnDefs() (id, timestamps, soft-delete, metadata jsonb), isoTimestamp(), i18n column helperssrc/models/schemas/common/
RepositoriesOne per entity, grouped by domain; extend SoftDeletableRepository or ArchivedRepositorysrc/repositories/<domain>/
Repository base classesSoftDeletableRepository (re-exported from @venizia/ignis), ArchivedRepository (status-based archive lifecycle)src/base/repository/
Service base classesBaseSocketEventService (WebSocket emit via Signal), MerchantScopedService (merchant-scoped CRUD)src/base/service/
Snowflake IdGeneratorSingleton wrapping IGNIS SnowflakeUidHelpersrc/utilities/id-generator.utility.ts
Kafka / CDC topic contractsKafkaTopics (domain event names + build() prefixer), CDCKafkaTopics (Debezium), CdcTablessrc/common/kafka/, src/common/cdc/
Event busIEventBus interface + Redis Pub/Sub adapter; typed event definitionssrc/helpers/event-bus/, src/common/events/
RedisRedisConnectionFactory (single / cluster)src/helpers/redis/
Shared utilitiesCryptoUtility, dayjs (timezone-configured), useRequestContext(), merchant-access + postgres + transform + slug helperssrc/utilities/
Constants & typesStatuses (IGNIS, reused — no custom enums), PostgresSchemas, FixedUserRoles, validations, shared decoratorssrc/common/

Cross-Package Seam

Kafka/CDC is the dominant cross-package communication seam — not a BullMQ queue subsystem.

MechanismPurpose
KafkaTopicsDomain event topic names (e.g. PAYMENT_SUCCESS, INVENTORY_ISSUED_FOR_SALE, LEDGER_GENERATE), with build({ paths }) prefixing nx.seller
CDCKafkaTopicsDebezium CDC topics built from CdcTables (e.g. MERCHANT, PRODUCT, SALE_ORDER)
Event bus (IEventBus)In-process pub/sub abstraction with a Redis Pub/Sub adapter
RedisShared connection management for caching and pub/sub

Who Depends On Core

Every backend package depends on @nx/core and connects to the same database via the re-exported PostgresCoreDataSource.

PackageApplication baseRole
@nx/identityIssuerApplicationJWT issuer (JWKS, ES256); auth, RBAC, users
@nx/commerceVerifierApplicationProducts, pricing, merchants, organizers
@nx/saleVerifierApplicationSale orders, checkout
@nx/financeVerifierApplicationIncome/expense, wallets
@nx/paymentVerifierApplicationPayment orchestration, webhooks
@nx/inventoryVerifierApplicationStock management, purchase orders
@nx/signalVerifierApplicationCentralized WebSocket service
Other services (invoice, ledger, licensing, outreach, tax, helpdesk, search, asset)VerifierApplicationConsume core schemas, repos, and contracts

Documentation Map

PageWhat you'll find
ArchitectureApplication hierarchy, lifecycle, runtime patterns
Components
Components OverviewIndex of base classes and shared infrastructure
DefaultApplicationBase app class, middleware, lifecycle methods
SoftDeletableRepositorySoft-delete + restore pattern (re-exported from IGNIS)
BaseSocketEventServiceWebSocket event broadcasting
Network ServicesIdentityNetworkService cross-service HTTP
Bootstrap HelpersbootstrapApplication / bootstrapMigration
RedisConnectionFactoryRedis single/cluster connections
Event BusIEventBus + Redis Pub/Sub adapter
Configuration
Configuration OverviewEnvironment, constants, events, topics
Environment VariablesEnvironmentKeys reference
ConstantsPostgresSchemas, FixedUserRoles, etc.
EventsEvent definitions + WebSocket topic builders
Queues / KafkaCross-package messaging contracts
Database
Database OverviewSchema layout, generateCommonColumnDefs, DataSource
Public SchemaUsers, products, merchants, organizers
Pricing SchemaFares, costs, taxes
Allocation SchemaEvent seating
Sale SchemaSale orders + items
Inventory SchemaStock, purchase orders, vendors
Finance SchemaWallets, categories, transactions
Payment SchemaWebhook configurations
Outreach SchemaOutreach domain
ERDEntity-relationship diagram
MigrationsPer-domain migrator CLI, Drizzle Kit, seeds
Utilities
Utilities OverviewIndex of shared utilities
IdGeneratorSnowflake ID singleton
CryptoUtilityEncryption + HMAC signing
DateUtilityTimezone-configured dayjs
RequestContextAuth context + response formatting

Schema Domains

Schemas live under src/models/schemas/<domain>/<entity>/; repositories mirror them under src/repositories/<domain>/. There are 14 domains — service packages consume these schemas, they do not define their own.

public · pricing · allocation · sale · inventory · finance · payment · invoice · ledger · identity · licensing · outreach · tax · helpdesk

The database/ sub-pages currently document a 7-schema snapshot. See the Database Overview for the documented schemas; the full 14-domain layout is the source of truth (packages/core/AGENTS.md).

Build & Scripts

ScriptPurpose
bun run rebuildClean + build (always use this)
bun run lint:fixESLint + Prettier auto-fix
bun run testRun tests (requires .env.test)
bun run db:generate / db:migrateGenerate / apply migrations for one domain
bun run db:generate:all / db:migrate:allAll domains

IGNIS References

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