Buildly CLI Documentation

The Project Generation and Scaffolding Utility

1. Overview

Buildly is designed to eliminate development friction by automating the setup of clean, architecture-focused folder structures. It supports React (for components), Next.js (for pages/modules), and Express.js (for API endpoints), pre-populating essential files with starter code.

Key Features

2. Installation & Core Command

2.1 Installation

Install **Buildly** globally via npm to make the command available in any directory on your system:

npm install -g buildly

Alternatively, you can run it directly using `npx` without a global installation:

npx buildly g <name> --[framework option]

2.2 The Generate Command (`g`)

The primary command is `g` (generate), which takes the module name (the folder name) and a framework flag.

Command Syntax

buildly g <ModuleName> <Options>

Available Options

Option Description Generates Structure For
--react Generates a modular folder structure for a standard React component or module. React (Components)
--next Generates a folder structure suitable for a Next.js App Router Page. Next.js (Pages)
--express Generates a dedicated folder for Express.js API logic (Routes, Controllers, Schemas). Express.js (API)
--no-extend Skips the creation of extended subfolders (`components`, `forms`, `hooks`, etc.), resulting in a minimalist structure. All Frameworks

3. Framework Guides and Boilerplate

3.1 React Scaffolding

Example Command (Using `Home` as module name):

buildly g Home --react

Generated Structure:

Home/ ├─ index.jsx (Main Functional Component) ├─ components/ │ └─ index.jsx (Placeholder for nested components) ├─ forms/ │ └─ form.jsx (Custom hook/stateful form component) ├─ constants/ │ └─ index.js (For module-specific constants) ├─ hooks/ │ └─ index.js (For module-specific custom hooks) └─ interface/ └─ index.js (For TypeScript interfaces/types - often used even in JS projects for reference)

File Boilerplate Examples:

Home/index.jsx (Main Component)

View Boilerplate

Home/forms/form.jsx (Stateful Form)

View Boilerplate

Home/hooks/index.js (Custom Hook)

View Boilerplate

3.2 Next.js Scaffolding

Example Command (Using `Dashboard` as module name):

buildly g Dashboard --next

Generated Structure:

Dashboard/ ├─ page.jsx (App Router Page Component) ├─ components/ │ └─ index.jsx (Internal components for the page) ├─ forms/ │ └─ form.jsx (Page-specific forms - note: uses 'form.jsx' instead of 'index.jsx' for forms/forms) ├─ constants/ │ └─ index.js ├─ hooks/ │ └─ index.js └─ interface/ └─ index.js

File Boilerplate Examples:

Dashboard/page.jsx (Main Page)

View Boilerplate

Note: The boilerplate for `forms/form.jsx`, `hooks/index.js`, `constants/index.js`, and `interface/index.js` in Next.js scaffolding is identical to the React scaffolding.

3.3 Express.js Scaffolding

Example Command (Using `User` as module name):

buildly g User --express

Generated Structure:

User/ ├─ index.js (Main export/entry point for the resource) ├─ router/ │ └─ user.router.js (Defines API routes and links to controller methods) ├─ controller/ │ └─ user.controller.js (Contains all the business logic) └─ schema/ └─ user.schema.js (Mongoose/Joi schema for data validation or modeling)

File Boilerplate Examples (for 'User' module):

User/controller/user.controller.js (Business Logic)

View Boilerplate

User/router/user.router.js (Routes Definition)

View Boilerplate

User/schema/user.schema.js (Schema/Model)

View Boilerplate