Skip to content

Command-line tool designed to generate backend projects following the principles of Clean Architecture.

Notifications You must be signed in to change notification settings

JorgeSarricolea/clean_arch_cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clean Architecture CLI

Overview

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.


Features

  • 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.

Installation

Global Installation

To install the CLI globally and use it as a command:

npm install -g clean-arch-cli

Local Development

If you're working on the CLI locally:

  1. Clone the repository:
    git clone <repository-url>
    cd clean_arch_cli
  2. Link the CLI globally:
    npm link

Usage

Generate a New Project

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

Configuration Files

server.js

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);
});

.gitignore

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

package.json

Pre-configured with basic scripts and dependencies:

  • Start the server: npm start
  • Run the server with file watching: npm run dev

Development

Run Locally

If you want to test or develop the CLI:

  1. Clone the repository and navigate to the project directory.
  2. Link the CLI globally:
    npm link
  3. Run the CLI:
    clean-arch-cli <project-name>

Author

Developed by [Jorge Sarricolea]. Feel free to reach out via GitHub or email.


Let me know if you'd like to customize any part of this README.md! 🎉

About

Command-line tool designed to generate backend projects following the principles of Clean Architecture.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published