The Clean Architecture CLI is a command-line tool designed to generate backend projects following the principles of Clean Architecture. It creates a well-structured folder hierarchy and includes basic configuration files to kickstart your development process.
- Generates a project structure based on Clean Architecture principles.
- Includes essential configurations:
server.js
with a basic Express server..gitignore
for Node.js projects.package.json
pre-configured with scripts and dependencies.
- Modular and extensible design for easy maintenance and scalability.
To install the CLI globally and use it as a command:
npm install -g clean-arch-cli
If you're working on the CLI locally:
- Clone the repository:
git clone <repository-url> cd clean_arch_cli
- Link the CLI globally:
npm link
To create a new project, run:
clean-arch-cli <project-name>
Example:
clean-arch-cli my-backend-project
This will generate a folder with the specified project name containing the following structure:
📁 src
├── 📁 domain
│ ├── 📁 entities # Domain entities
│ ├── 📁 repositories # Repository interfaces
│ └── 📁 value-objects # (Optional) Value objects
├── 📁 application
│ ├── 📁 use-cases # Use cases
│ └── 📁 services # Auxiliary services
├── 📁 infrastructure
│ ├── 📁 orm
│ │ ├── schema # Model definition file (ORM agnostic)
│ │ ├── migrations/ # ORM-generated migrations
│ │ ├── client # ORM client configuration
│ │ └── 📁 repositories # Concrete repository implementations
│ ├── 📁 external
│ │ └── 📁 apis # Adapters for external APIs
│ ├── 📁 webserver
│ │ ├── 📁 express # Express.js-specific configuration
│ │ └── server.js # Main server configuration
│ ├── 📁 config # Application configuration
│ ├── 📁 logger # Logging configuration
│ └── 📁 docker # Docker-related files
├── 📁 interfaces
│ ├── 📁 controllers # HTTP controllers
│ ├── 📁 routes # Application routes
│ ├── 📁 middlewares # Express middlewares
│ └── 📁 validators # Specific input validators
├── 📁 tests
│ ├── 📁 unit # Unit tests
│ ├── 📁 integration # Integration tests
│ ├── 📁 e2e # End-to-end tests
│ └── 📁 mocks # (Optional) Dependency mocks
└── 📁 shared
├── 📁 utils # Utility functions
├── 📁 constants # Global constants
└── 📁 exceptions # Centralized error handling
A minimal Express server with a default route:
import express from "express";
const app = express();
app.get("/", (req, res) => {
res.json({ message: "Welcome to your Clean Architecture API" });
});
const PORT = 8000;
app.listen(PORT, () => {
console.log("🚀 Server deployed on http://localhost:" + PORT);
});
Includes common exclusions for Node.js projects:
# Node.js
node_modules/
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
.env
# Logs
logs/
*.log
npm-debug.log*
yarn-debug.log*
pnpm-debug.log*
# OS
.DS_Store
Thumbs.db
# Editor
.vscode/
.idea/
*.swp
Pre-configured with basic scripts and dependencies:
- Start the server:
npm start
- Run the server with file watching:
npm run dev
If you want to test or develop the CLI:
- Clone the repository and navigate to the project directory.
- Link the CLI globally:
npm link
- Run the CLI:
clean-arch-cli <project-name>
Developed by [Jorge Sarricolea]. Feel free to reach out via GitHub or email.