create a BE Bootstrapper for Clean Architecture

In the fast-paced world of Backend Engineering, consistency and speed are key. As a Senior Software Engineer, I’ve found that manually setting up the same boilerplate for every new microservice or laboratory experiment is a waste of precious cognitive load.
To solve this, I’ve developed a Zsh automation script that scaffolds a production-ready Node.js API using Clean Architecture, TypeScript (ESM), and a robust Jest testing suite in seconds.
The Architecture Strategy
The script follows a strict separation of concerns, dividing the project into:
Domain: Entities and Repository interfaces.
Application: Business logic through Use Cases.
Infrastructure: Database mocks, Repositories implementation, and Express.js setup.
Key Features of the Bootstrapper
Native ESM Support: Configured with
"type": "module"andmoduleResolution: "Bundler"to avoid the friction of manual.jsextensions in imports.Strategic Testing Suite: It creates a dual-layer testing environment:
Unit Tests: Centralized in
/tests/unitto validate business logic in isolation.Integration Tests: Located in
/tests/integrationusing Supertest to verify the full HTTP lifecycle.
Advanced Jest Configuration: Uses
--runInBandand--verboseby default. This ensures tests run sequentially for easier debugging and provides detailed feedback on everydescribeblock.Security Baseline: Automatically generates a
.gitignorethat excludes sensitive files like.env,.pem, and.keyfrom the start.
The Setup Process
Once you source the script in your .zshrc, creating a new API is as simple as:
Bash
create-api my-new-service
The script then handles the package.json creation (avoiding common npm pkg override errors), installs dependencies, and configures tsconfig.json and jest.config.js to play nicely with modern TypeScript 5.x standards.
Conclusion
Automation isn't just about saving time; it's about reducing the barrier to entry for quality code. By having a standardized starting point, you ensure that every project starts with high-test coverage and a scalable architecture.
đź”— Get the Script
You can find the full source code for this Zsh function in my GitHub Gist: View the Full Script on GitHub Gist
Support the Journey.
I create content and share knowledge from the serverless frontier. If you found this helpful, consider buying me a coffee!
Buy me a coffeeComments (0)
You must be logged in to comment.
Login to Comment