// Developer Tools & Infrastructure•2022•VerifiedOpen Source

Venida

TypeScript & Fastify Backend Boilerplate & Code Generator

// FIGURE 01SYSTEM INTERFACE SPECIMEN
Venida system interface
Venida // TypeScript & Fastify Backend Boilerplate & Code Generator

Project at a Glance

  • Problem: Bootstrapping a structured Node.js/TypeScript REST API often requires wiring HTTP routing, lifecycle hooks, request validation, database migrations, background job queues, PM2 configs, and CLI scaffolding from scratch on every new repository.
  • Deliverables: An open-source, batteries-included TypeScript + Fastify 4 backend boilerplate platform (seje-digital/venida, 2022-2024) featuring a layered MVC + Service architecture, a custom CLI (venida.ts), a .venida template code generator (Vgen), Knex.js + MySQL migrations/seeders, a BullMQ + Redis queue worker engine, centralized error declarations, and PM2 deployment manifests.
  • Core Stack: TypeScript, Fastify 4, Node.js, Knex.js, MySQL (mysql2), BullMQ, Redis, PM2.
  • Practical Value: Led and architected as an open-source backend scaffolding platform under SE-JE Digital to provide an opinionated, ready-to-use foundation for TypeScript API development.

Project Overview

Venida Platform is an open-source backend boilerplate built under SE-JE Digital (2022-2024), where I led and designed the majority of its core architecture. Inspired by the productivity of batteries-included frameworks while keeping Fastify 4 and TypeScript at the core, Venida packages routing, database migrations, background queues, code generation, and process management into one cohesive repository structure.

Venida is maintained purely as an open-source boilerplate and architectural reference under SE-JE Digital rather than a commercial client deployment.

System Architecture & Directory Blueprint

venida/
├── app/
│   ├── Console/          # Custom CLI commands (Server, Vgen, Knex, Queue, Route)
│   ├── Http/
│   │   ├── Controllers/  # Versioned API controllers (e.g. Api/V1/UserController)
│   │   └── Hooks/        # Fastify lifecycle hooks (OnRequest, PreValidation, OnResponse)
│   ├── Job/              # Background queue job classes
│   ├── Models/           # Knex-backed data models
│   └── Services/         # Domain business logic layer
├── config/               # Centralized app, database, redis, router, package configs
├── database/             # Knex migrations & seeders
├── declaration/          # Centralized error-declaration.json & global types
├── generators/templates/ # .venida scaffolding templates (controller/model/service/route)
├── routes/               # Modular API route definitions
├── system/
│   ├── Core/             # Boot, Core, Datasource, Security, Base classes & Queue Worker
│   ├── Handler/          # Request, Response, and Route handlers
│   └── Package/          # Built-in Queue & Validator packages
├── venida.ts             # CLI entry point
├── venida.server.yaml    # PM2 HTTP server manifest
└── venida.queue.yaml     # PM2 background queue worker manifest

Core Architectural Decisions

1. Fastify 4 Core with Layered MVC + Service Separation

  • Wraps Fastify 4 inside system/Core/ (Boot.ts, Core.ts, Handler/Route.ts) with pre-configured @fastify/helmet, @fastify/compress, @fastify/formbody, and @fastify/multipart plugins.
  • Enforces clear boundaries across routes/ -> Http/Hooks (OnRequest, PreValidation, OnResponse) -> Http/Controllers -> Services -> Models, paired with a custom system/Package/Validator.ts and a centralized declaration/error-declaration.json registry for consistent API error responses.

2. Custom CLI (venida.ts) & Vgen Template Code Generator

  • Built a custom console runner (app/Console/) exposing artisan-style developer commands:
    • Server & Routing: server, list, route:list
    • Database (Knex.js): knex:init, knex:migrate, knex:migrate-rollback, knex:seed, make:migration, make:seeder
    • Queues: queue:table, queue:work
    • Code Scaffolding (Vgen): Generates new controller, model, service, route, migration, and seeder files automatically from reusable .venida templates under generators/templates/.

3. Background Job Queue Engine (BullMQ + Redis)

  • Abstracts asynchronous background processing into system/Core/Base/Queue/ (BaseQueueJob.ts, Processor.ts, Worker.ts) backed by BullMQ and Redis.
  • Separates HTTP traffic and queue workers into independent PM2 manifests (venida.server.yaml and venida.queue.yaml) so long-running jobs do not block API latency.

4. Custom Build & Watch Tooling

  • Includes dedicated compiler.ts (TypeScript compilation with uglify-js) and watch.ts (chokidar file watcher) scripts so teams can iterate in debug mode or compile production builds ready for PM2 execution.

Scope & Open-Source Context

  • Open-Source Focus: Venida was created as a pure open-source boilerplate platform under SE-JE Digital (not deployed as a commercial client system) to explore and standardize batteries-included Fastify + TypeScript backend architecture.
  • Key Engineering Takeaway: Designing a framework core from scratch (Boot, Datasource, Queue, Validator, Vgen code generator, and custom compiler scripts) deepened practical understanding of how web frameworks orchestrate lifecycle hooks, dependency wiring, and developer ergonomics under the hood.