Skip to content

Package: @venizia/ignis

Detailed breakdown of the core framework directory structure.

Quick Reference

Package: Core framework with fundamental building blocks, architectural layers, and modular features.

Top-Level Directories

DirectoryPrimary FocusKey Components
baseCore architectureApplications, Controllers, Repositories, Services, Models
componentsPluggable featuresAuth, Swagger, HealthCheck, SocketIO
helpersUtilitiesDI (extended), Re-exports from @venizia/ignis-helpers
commonShared codeConstants, bindings, types, environments
utilitiesPure functionsCrypto, date, parse, performance, schema
__tests__TestsIntegration and E2E tests

Project Structure Overview

Top-level breakdown of the src directory:

FolderPurpose
__tests__Contains integration and end-to-end tests for the framework's features.
baseThe core building blocks and abstract classes of the framework. This is where the fundamental architecture is defined.
commonA directory for code that is shared and used across the entire framework.
componentsA collection of ready-to-use, high-level components that can be plugged into an Ignis application.
helpersContains core extensions (like Inversion) and re-exports from @venizia/ignis-helpers.
utilitiesA collection of pure, standalone utility functions.

Detailed Sections

__tests__

This directory is dedicated to the framework's test suite.

File/FolderPurpose/Key Details
jwt/Contains test cases specifically for the JWT authentication functionality, demonstrating how tokens are generated and validated.
jwt/test-cases/jwt.tsExample: defines TestCase001 to check JWT creation.

base

This is the foundational layer of Ignis, defining the core architecture and abstract classes that other parts of the framework extend or implement.

base/applications

File/FolderPurpose/Key Details
abstract.tsDefines AbstractApplication, the base class for Ignis applications. Handles core server setup (Hono instance, runtime detection for Bun/Node.js), environment validation, and route inspection. Mandates abstract methods for middleware setup and configuration.
base.tsExtends AbstractApplication to provide BaseApplication, implementing common functionalities like component, controller, service, repository, and datasource registration. Includes default middleware registration (e.g., error handling, favicon, request tracking) and startup information logging. Integrates with @venizia/ignis-boot for automatic artifact discovery when bootOptions is configured.
types.tsContains interfaces for application configurations (IApplicationConfigs), application information (IApplicationInfo), and various middleware options (e.g., ICORSOptions, ICSRFOptions). Now includes IBootableApplication interface for boot system integration.

base/components

File/FolderPurpose/Key Details
base.tsDefines BaseComponent, the abstract class for all pluggable components. Manages component-specific bindings and a configure() method for setup logic.

base/controllers

File/FolderPurpose/Key Details
abstract.tsDefines AbstractController, an abstract class providing core controller functionalities like getRouteConfigs for standardizing route configurations, and registerRoutesFromRegistry() for automatically registering decorator-based routes.
base.tsExtends AbstractController to provide BaseController, an abstract class for handling HTTP requests. Integrates with @hono/zod-openapi for route definition and OpenAPI schema generation. Key methods include defineRoute and bindRoute.
factory/Contains the ControllerFactory and related helpers for generating controllers.
factory/controller.tsProvides ControllerFactory to generate pre-configured CRUD controllers from a given entity and repository.
factory/definition.tsExports route definition helpers.
common/Contains shared types (types.ts) and constants (constants.ts) for the controller layer.

base/datasources

File/FolderPurpose/Key Details
base.tsContains AbstractDataSource and BaseDataSource, abstract classes for managing database connections. They define methods for configuration (configure()) and retrieving connection strings.
types.tsDefines IDataSource interface and TDataSourceDriver (e.g., node-postgres).

base/helpers

File/FolderPurpose/Key Details
base.tsBaseHelper is a generic base class providing common utilities like a logger instance and scope management. Many other helpers and components extend this class.

base/metadata

This directory centralizes the metadata handling for decorators, crucial for Ignis's DI and routing systems.

File/FolderPurpose/Key Details
injectors.tsDefines the @injectable and @inject decorators for dependency injection.
persistents.tsContains @model and @datasource decorators for marking classes as data models or data sources, respectively.
routes.tsDefines the @controller decorator for marking classes as API controllers, and the new decorator set (@api, @get, @post, etc.) for defining routes on controller methods.

base/middlewares

A collection of essential, low-level middlewares used by the application.

File/FolderPurpose/Key Details
app-error.middleware.tsGlobal error handling middleware that catches ApplicationError instances and formats responses consistently.
emoji-favicon.middleware.tsServes a simple emoji favicon for the application.
not-found.middleware.tsHandles 404 Not Found errors.
request-normalize.middleware.tsNormalizes incoming requests, particularly for parsing JSON bodies.
request-spy.middleware.tsLogs incoming requests and adds a unique request ID for tracing.

base/mixins

Contains mixins to extend the functionality of core classes, particularly AbstractApplication.

File/FolderPurpose/Key Details
component.mixin.tsAdds component() and registerComponents() methods.
controller.mixin.tsAdds controller() and registerControllers() methods.
repository.mixin.tsAdds dataSource() and repository() methods.
service.mixin.tsAdds service() method.
types.tsDefines interfaces and types (TMixinOpts, IComponentMixin, IControllerMixin, etc.).

All registration methods accept an optional opts?: TMixinOpts parameter for custom binding configuration:

typescript
type TMixinOpts<Args extends AnyObject = any> = {
  binding: { namespace: string; key: string };
  args?: Args;
};

// Example: Custom binding key
this.controller(UserController, {
  binding: { namespace: 'controllers', key: 'CustomUserController' }
});

base/models

Defines base classes and utilities for data models, often used with Drizzle ORM.

File/FolderPurpose/Key Details
base.tsContains BaseEntity, a base class for models that wrap Drizzle ORM schemas and provide methods for generating Zod schemas for CRUD operations.
common/Contains shared types (types.ts) and constants (constants.ts) for the model layer, including definitions for IdType, TTableSchemaWithId, and SchemaTypes.
enrichers/Sub-directory for functions that add common fields to Drizzle ORM schemas.
enrichers/data-type.enricher.tsAdds generic data type columns (number, text, byte, JSON, boolean).
enrichers/id.enricher.tsAdds id column with number (serial) or string (UUID) types.
enrichers/principal.enricher.tsAdds polymorphic fields for associating with different principal types.
enrichers/tz.enricher.tsAdds createdAt and modifiedAt timestamp columns.
enrichers/user-audit.enricher.tsAdds createdBy and modifiedBy fields.

base/providers

File/FolderPurpose/Key Details
base.tsContains BaseProvider, an abstract class for creating custom dependency injection providers. Providers are used for dependencies that require complex instantiation logic.

base/repositories

File/FolderPurpose/Key Details
core/base.tsDefines AbstractRepository, the abstract base class for all repositories.
core/readable.tsImplements ReadableRepository for read-only data access.
core/persistable.tsImplements PersistableRepository, extending ReadableRepository with write capabilities (create, update, delete).
core/default-crud.tsProvides DefaultCRUDRepository, the standard full CRUD repository that extends PersistableRepository.
common/types.tsDefines interfaces for filters (TFilter), WHERE clauses (TWhere), and repository operations (IRepository, IPersistableRepository).

base/services

File/FolderPurpose/Key Details
base.tsDefines BaseService, the abstract base for all business logic services.
types.tsDefines IService and ICrudService interfaces.

common

This directory holds various shared definitions and constants used throughout the framework.

File/FolderPurpose/Key Details
bindings.tsDefines BindingNamespaces (e.g., COMPONENT, SERVICE) and BindingKeys (APPLICATION_INSTANCE, APPLICATION_SERVER) for the dependency injection container.
constants.tsContains application-wide constants such as HTTP methods and status codes, MimeTypes, RuntimeModules (Bun, Node.js), and DataTypes.
environments.tsDefines Environment types (e.g., DEVELOPMENT, PRODUCTION) and EnvironmentKeys for structured access to environment variables.
statuses.tsDefines various status constants like UserStatuses, RoleStatuses, and MigrationStatuses.
types.tsContains general TypeScript utility types like ValueOrPromise, AnyObject, IClass, TMixinTarget, and IProvider.

components

This directory contains high-level, pluggable components that encapsulate specific features, extending the application's functionality.

components/auth/

Provides authentication and authorization features.

File/FolderPurpose/Key Details
authenticate/JWT-based authentication.
authenticate/common/Constants, keys, and types for authentication.
authenticate/component.tsAuthenticateComponent registers authentication services and controllers.
authenticate/controllers/factory.tsdefineAuthController creates a pre-configured controller with sign-in, sign-up, change password, and "who am I" routes.
authenticate/services/jwt-token.service.tsJWTTokenService handles JWT generation, verification, and payload encryption/decryption.
authenticate/strategies/Authentication strategies, e.g., JWTAuthenticationStrategy.
authenticate/strategies/strategy-registry.tsAuthenticationStrategyRegistry manages and provides authentication strategies.
models/Data models (entities and requests) for authentication, including User, Role, Permission, SignInRequestSchema, SignUpRequestSchema, etc.

components/health-check/

Adds a simple /health endpoint to the application.

File/FolderPurpose/Key Details
component.tsHealthCheckComponent registers the HealthCheckController.
controller.tsHealthCheckController defines the /health route.

components/request-tracker/

Logs and traces incoming requests.

File/FolderPurpose/Key Details
component.tsRequestTrackerComponent integrates hono/request-id and RequestSpyMiddleware for request tracking.

components/socket-io/

Integrates Socket.IO for real-time communication.

File/FolderPurpose/Key Details
component.tsSocketIOComponent sets up the Socket.IO server, integrates with Redis for scaling, and handles authentication.

components/swagger/

Generates interactive OpenAPI documentation.

File/FolderPurpose/Key Details
component.tsSwaggerComponent configures Swagger UI using @hono/zod-openapi and @hono/swagger-ui, generating documentation from route schemas.

helpers

Contains framework extensions and utilities.

File/FolderPurpose/Key Details
inversion/Framework DI Extension: Extends @venizia/ignis-inversion to provide application-aware dependency injection with logging and enhanced metadata support.
index.tsRe-exports extensions and utilities from @venizia/ignis-helpers.

utilities

This directory contains pure, standalone utility functions that perform common, stateless operations.

File/FolderPurpose/Key Details
crypto.utility.tsProvides a hash() function for cryptographic hashing (SHA256, MD5).
date.utility.tsDate and time manipulation functions (dayjs integration, sleep, isWeekday, getDateTz, hrTime).
module.utility.tsvalidateModule() to check for module existence at runtime.
parse.utility.tsFunctions for type checking (isInt, isFloat), type conversion (int, float, toBoolean), string/object transformation (toCamel, keysToCamel), array transformations (parseArrayToRecordWithKey, parseArrayToMapWithKey), and getUID() for unique IDs.
performance.utility.tsUtilities for measuring code execution time (executeWithPerformanceMeasure, getPerformanceCheckpoint, getExecutedPerformance).
promise.utility.tsHelper functions for Promises (executePromiseWithLimit, isPromiseLike, transformValueOrPromise, getDeepProperty).
request.utility.tsUtilities for handling HTTP request data, such as parseMultipartBody for multipart form data.
schema.utility.tsHelper functions and predefined schemas for zod and @hono/zod-openapi (jsonContent, jsonResponse, requiredString, AnyObjectSchema, IdParamsSchema, UUIDParamsSchema).

This detailed breakdown illustrates the modular and layered design of the Ignis framework, emphasizing its extensibility and adherence to robust architectural patterns.