Background Jobs (@wrelik/jobs)
Relevant source files
The following files were used as context for generating this wiki page:
The @wrelik/jobs package provides a standardized, vendor-agnostic wrapper for handling background jobs and event-driven workflows within the Wrelik ecosystem. It is designed to follow the project's core principle of "adapter-first architecture," ensuring that application-level code does not interact directly with third-party software development kits (SDKs).
This module leverages Inngest as its underlying engine to support serverless-friendly job queuing and complex workflow orchestration. By centralizing the job integration here, the project reduces vendor lock-in and enforces consistent best practices across all consuming applications.
Sources: README.md:10-15, README.md:54-55, DECISIONS.md:16-20
Architecture and Design
The background jobs system is built as a lightweight abstraction layer. Instead of apps importing the vendor SDK directly, they utilize the @wrelik/jobs package, which manages the integration boundary.
Core Principles
- Minimal Surface Area: The package exposes only the functionality required by Wrelik applications, simplifying the developer experience.
- Explicit Boundaries: It prevents the leakage of vendor-specific logic into the business logic of individual applications.
- Serverless Compatibility: The choice of Inngest as the vendor reflects the need for an event-driven queue that operates effectively in serverless environments.
Sources: README.md:12-18, DECISIONS.md:16-20, DECISIONS.md:25-30
Dependency Structure
The following diagram illustrates how @wrelik/jobs sits between the application layer and the third-party infrastructure.
The application interacts only with the @wrelik scoped package to maintain vendor neutrality.
Sources: README.md:83-85, DECISIONS.md:25-30
Technical Implementation
Dependencies and Tooling
The package is built using TypeScript and utilizes tsup for bundling into CommonJS and ESM formats.
| Category | Tool/Library | Purpose |
|---|---|---|
| Primary Dependency | inngest | Core engine for background jobs and workflows. |
| Build Tool | tsup | Compiles source to distribution files and generates type definitions. |
| Linting | @wrelik/eslint-config | Enforces project-wide coding standards and restricted imports. |
| Testing | vitest | Executes unit and integration tests. |
Sources: packages/jobs/package.json:11-20, package.json:4-15
Import Restrictions
To maintain the integrity of the adapter architecture, the project uses ESLint rules to prevent developers from bypassing the @wrelik/jobs wrapper.
// From packages/eslint-config/index.js
{
name: 'inngest',
message: 'Please use @wrelik/jobs instead.',
}
Sources: packages/eslint-config/index.js:28-31
Development Workflow
Building and Publishing
As part of a monorepo, @wrelik/jobs follows a standardized release lifecycle managed by Turbo and Changesets.
- Build:
tsup src/index.ts --format cjs,esm --dts --cleanproduces the distribution files. - Version: Changesets are used to track updates and manage semver bumps (e.g., the transition from version 0.1.0 to 0.1.1).
- Deployment: The package is published with public access.
Sources: packages/jobs/package.json:7-10, CONTRIBUTING.md:24-40, packages/jobs/CHANGELOG.md:1-12
Sequence of Job Execution
The following sequence diagram represents the logical flow of triggering a background job through the standardized adapter.
The wrapper ensures that the event formatting matches the system's expected standards before passing it to the vendor.
Sources: README.md:10-15, DECISIONS.md:28-30
Conclusion
The @wrelik/jobs package is a critical component of the Wrelik infrastructure, providing a stable interface for asynchronous processing. By wrapping Inngest, it ensures that applications remain decoupled from specific vendor implementations while gaining the benefits of a robust, event-driven workflow engine.
Sources: README.md:7-9, DECISIONS.md:16-20