Backend scaffolding CLI - for Node.js
Xacos is a powerful CLI tool that helps you scaffold production-ready Node.js backend projects with Express.js, following industry best practices and professional folder structures.
npm install -g xacosnpx xacos <command>Creates a new backend project with a professional folder structure.
npx xacos init my-backend --js --mongodb
npx xacos init my-backend --ts --prismaOptions:
--js- Use JavaScript (default)--ts- Use TypeScript--mongodb- Setup MongoDB with Mongoose--prisma- Setup Prisma ORM--redis- Include Redis client--ws- Include native WebSocket--socket.io- Include Socket.io--docker- Include Docker files--git-action- Include GitHub Actions CI/CD
Example:
npx xacos init api-server --ts --prisma --redis --dockerCreates a complete module with controller, service, model, and routes.
npx xacos add User
npx xacos add notification
npx xacos add productThis command generates:
src/controllers/{name}.controller.jssrc/services/{name}.service.jssrc/models/{name}.model.jssrc/routes/{name}.routes.js
And automatically registers the route in src/routes/index.js.
Sets up Redis client with helper functions.
npx xacos create:redisCreates src/utils/redis.js with connection, caching helpers, and error handling.
Sets up Prisma ORM with schema and database configuration.
npx xacos create:prismaCreates:
prisma/schema.prismasrc/config/db.js(Prisma client)
Sets up native WebSocket server.
npx xacos create:wsCreates src/sockets/index.js with WebSocket server configuration.
Sets up Socket.io server.
npx xacos create:socket.ioCreates src/sockets/index.js with Socket.io server and room management.
Sets up BullMQ for job processing.
npx xacos create:message-queueCreates src/queues/index.js with example email queue and worker.
Sets up event-driven pub/sub system.
npx xacos create:pub-subCreates:
src/utils/pubsub.js- Event emitter wrappersrc/subscribers/index.js- Example subscribers
Creates Dockerfile and docker-compose.yml.
npx xacos make:dockerCreates:
docker/Dockerfiledocker/docker-compose.yml.dockerignore
Automatically configures services based on your project (MongoDB, Redis, PostgreSQL).
Creates GitHub Actions workflow for CI/CD.
npx xacos make:git-actionCreates .github/workflows/ci.yml with:
- Node.js setup
- Dependency caching
- Linting, testing, building
- Prisma migrations (if using Prisma)
After running init, you'll get:
my-backend/
βββ src/
β βββ app.js # Express app configuration
β βββ server.js # Server bootstrap
β βββ config/ # Configuration files
β β βββ db.js
β β βββ env.js
β βββ routes/ # API routes
β β βββ index.js
β βββ controllers/ # Route controllers
β βββ services/ # Business logic
β βββ models/ # Data models
β βββ middlewares/ # Custom middlewares
β βββ utils/ # Utility functions
β β βββ logger.js
β β βββ response.js
β βββ sockets/ # WebSocket/Socket.io
β βββ queues/ # Message queues
β βββ subscribers/ # Event subscribers
βββ prisma/ # Prisma schema (if --prisma)
βββ docker/ # Docker files (if --docker)
βββ .github/workflows/ # CI/CD (if --git-action)
βββ .env
βββ .env.example
βββ .gitignore
βββ package.json
βββ README.md
βββ xacos.json # CLI metadata
-
Create a new project:
npx xacos init my-api --js --mongodb
-
Add a module:
cd my-api npx xacos add User -
Install dependencies:
npm install
-
Start development server:
npm run dev
# 1. Initialize project
npx xacos init blog-api --ts --prisma --redis
# 2. Add modules
cd blog-api
npx xacos add Posts
npx xacos add Comments
npx xacos add Users
# 3. Add features
npx xacos create:message-queue
npx xacos create:pub-sub
# 4. Setup deployment
npx xacos make:docker
npx xacos make:git-action
# 5. Install and run
npm install
npx prisma generate
npx prisma migrate dev
npm run dev- β Professional Structure - Industry-standard folder organization
- β TypeScript Support - Full TypeScript support with type definitions
- β Database Options - MongoDB (Mongoose) or Prisma ORM
- β Real-time - WebSocket and Socket.io support
- β Caching - Redis integration
- β Job Queues - BullMQ for background jobs
- β Event System - Pub/Sub for event-driven architecture
- β Docker Ready - Docker and docker-compose setup
- β CI/CD - GitHub Actions workflows
- β Auto-wiring - Routes automatically registered
When you run npx xacos add Users, you get:
Controller (user.controller.js):
getUsers()- GET /api/usersgetUserById()- GET /api/users/:idcreateUser()- POST /api/usersupdateUser()- PUT /api/users/:iddeleteUser()- DELETE /api/users/:id
Service (user.service.js):
- Business logic layer
- Calls model methods
Model (user.model.js):
- Database operations
- Adapts to MongoDB or Prisma automatically
Routes (user.routes.js):
- RESTful routes
- Auto-registered in
routes/index.js
- Express.js - Web framework
- Mongoose - MongoDB ODM (optional)
- Prisma - Next-generation ORM (optional)
- Redis - Caching and sessions (optional)
- BullMQ - Job queue (optional)
- Socket.io - Real-time communication (optional)
- WebSocket - Native WebSocket (optional)
MIT
Contributions are welcome! Please feel free to submit a Pull Request.
For issues and feature requests, please use the GitHub issue tracker.
Built with β€οΈ for the Node.js community