initrajs
Version:
โก InitraJS - JavaScript CLI Toolkit | Lightning-fast scaffolding for React, Next.js, Node.js with TypeScript | The future of JavaScript development | 10x faster than create-react-app | Ultimate developer productivity tool
537 lines (409 loc) โข 16.9 kB
Markdown
# โก InitraJS
> The ultimate fullstack scaffolding CLI. Zero config, maximum productivity. Built for speed, scalability, and modern dev workflows.
[](https://www.npmjs.com/package/initrajs)
[](https://www.npmjs.com/package/initrajs)
[](LICENSE)
[](https://github.com/blessedrajp)
**๐ [Try it Live](https://initrajs.vercel.app) | ๐ [Documentation](https://initrajs.vercel.app) | ๐ [Get Started Now](#-installation--quick-start)**
---
## ๐ฏ What Makes InitraJS Special?
**InitraJS** isn't just another CLI tool โ it's your development superpower. While other tools give you basic scaffolding, InitraJS delivers production-ready applications with enterprise-grade architecture, comprehensive testing, and modern best practices built in from day one.
### โก **Lightning Fast Setup**
```bash
# From zero to running app in under 60 seconds
npm install -g initrajs
npx initrajs init my-app
cd my-app && npm start
```
### ๐๏ธ **Enterprise-Grade Architecture**
- **Clean Architecture**: MVC + Service Layer pattern with dependency injection
- **Type Safety**: Full TypeScript support with intelligent type generation
- **Security First**: JWT authentication, CORS, rate limiting, and security headers
- **Testing Ready**: Jest, React Testing Library, and E2E tests configured
- **Production Optimized**: Bundle splitting, lazy loading, and performance monitoring
---
## ๐ Introduction
**InitraJS** is a powerful zero-config CLI that scaffolds production-ready fullstack applications and generates components with lightning speed. Featuring cutting-edge architecture, comprehensive code generation, and battle-tested best practices โ get from idea to deployment in minutes, not hours.
**๐ฏ Perfect for:**
- ๐ Startups needing rapid prototyping
- ๐ข Enterprise teams requiring consistent architecture
- ๐จโ๐ป Solo developers wanting best practices built-in
- ๐ Learning modern fullstack development patterns
---
## ๐ Table of Contents
- [๐ Features](#-features)
- [๐ฏ What Makes InitraJS Special](#-what-makes-initrajs-special)
- [๐ฆ Installation & Quick Start](#-installation--quick-start)
- [โก Quick Demo](#-quick-demo)
- [๐ฏ Code Generation](#-code-generation)
- [๐งฐ Supported Templates](#-supported-templates)
- [๐ Project Structure](#-project-structure)
- [โ๏ธ Backend Architecture](#-backend-architecture)
- [๐ ๏ธ Advanced Usage](#-advanced-usage)
- [๐ Success Stories](#-success-stories)
- [๐ฃ๏ธ Roadmap](#-roadmap)
- [๐ Troubleshooting](#-troubleshooting)
- [๐จโ๐ป Contributing](#-contributing)
- [๐ License](#-license)
---
## ๐ Features
### ๐ฏ **Intelligent Code Generation**
- ๐งฉ **Smart Components**: Generate React components with TypeScript, CSS, tests, and Storybook stories
- ๐ **Page Generation**: Create React pages or Next.js app router pages with full folder structure
- ๐ง **Backend Scaffolding**: Generate complete APIs with controllers, services, models, DTOs, and routes
- ๐จ **Style Integration**: Automatic CSS/SCSS generation with BEM methodology
- ๐งช **Test Coverage**: Jest + React Testing Library setup out of the box
### ๐งฉ **Frontend Excellence (React / Next.js)**
- โ๏ธ **Full TypeScript Support** with intelligent type generation
- ๐จ **Integrated MUI v5** with global theme customization
- ๐ง **Configured Redux Toolkit** for scalable state management
- ๐ **AuthContext + AuthGuard** for protected routing
- ๐งพ **Class-based API Services** for clean, DRY code
- ๐ **Modular App Directory Structure** using Next.js App Router
- ๐พ **Session-based token handling**, synced with AuthContext
- ๐ฑ **Responsive Design** with mobile-first approach
### ๐ง **Backend Powerhouse (Node.js)**
- ๐๏ธ **Structured MVC + Service Layer** architecture
- ๐ **JWT authentication** with middleware protection
- โ
**DTOs and Validators** using `express-validator`
- ๐ **Modular route handling** with auto-registration
- ๐ฅ **Global error middleware** with consistent responses
- ๐ฆ **TypeScript-first** with modern conventions
- ๐ **Auto-generated CRUD operations**
---
## ๐ฆ Installation & Quick Start
### ๐ Global Installation (Recommended)
```bash
npm install -g initrajs
```
### โก Quick Demo
```bash
# Create a full-stack app in seconds
npx initrajs init my-awesome-app
cd my-awesome-app
# Generate a component with everything
initrajs c ProductCard --css --test --story --props "title,price,image"
# Create a protected dashboard page
initrajs page Dashboard --next --css --test
# Generate a complete API endpoint
initrajs api User --ts
# Start developing
npm run dev
```
### ๐ From Idea to Production
```bash
# 1. Initialize project (30 seconds)
npx initrajs init ecommerce-app --template nextjs
# 2. Generate components (2 minutes)
initrajs c ProductGrid --css --test --props "products,loading"
initrajs c ShoppingCart --css --test --props "items,onUpdate"
# 3. Create pages (1 minute)
initrajs page Products --next --css --test
initrajs page Checkout --next --css --test
# 4. Build API (2 minutes)
initrajs api Product --ts
initrajs api Order --ts
# 5. Deploy (1 minute)
npm run build && npm run deploy
```
**๐ Result: Production-ready e-commerce app in under 10 minutes!**
---
## ๐ฏ Code Generation
### ๐งฉ **Component Generation**
```bash
# Basic component (defaults to TypeScript)
initrajs c Header
# Component with all the bells and whistles
initrajs c ProductCard --css --test --story --props "title,price,image"
# Layout component with TypeScript
initrajs c AppLayout --layout --ts --css
# Server-side component for Next.js
initrajs c UserProfile --server --css --test
```
**Generated Structure:**
```
src/components/ProductCard/
โโโ ProductCard.tsx # Main component with TypeScript
โโโ ProductCard.scss # BEM-style CSS (if --css)
โโโ ProductCard.test.tsx # Jest tests (if --test)
โโโ ProductCard.stories.tsx # Storybook story (if --story)
โโโ index.ts # Barrel export
```
### ๐ **Page Generation**
```bash
# React page for standard React apps
initrajs page Home --react --css --test
# Next.js page with app router structure
initrajs page Dashboard --next --ts --css --test
# Custom path for organization
initrajs page UserProfile --next --path "app/user" --css
```
**Next.js Page Structure:**
```
app/dashboard/
โโโ page.tsx # Main page component
โโโ loading.tsx # Loading UI
โโโ error.tsx # Error boundary
โโโ dashboard.scss # Page styles (if --css)
โโโ page.test.tsx # Page tests (if --test)
```
### ๐ง **Backend Generation**
```bash
# Complete API with all files
initrajs api Product --ts
# Individual backend components
initrajs route User --ts
initrajs controller Order --ts
initrajs service PaymentService --ts
initrajs model ProductModel --ts
initrajs middleware AuthMiddleware --jwt --ts
```
---
## ๐งฐ Supported Templates
| Template | Tech Stack | TypeScript | Features |
|----------|------------|------------|----------|
| **React** | Vite + MUI + Redux | โ
| Theme, State Management, AuthContext |
| **Next.js** | App Router + MUI + Redux | โ
| AuthGuard, Layouts, Sessions, SEO |
| **Node.js** | Express MVC + TypeScript | โ
| DTOs, Middleware, Services, JWT |
### ๐จ **Template Features**
#### **React Template**
- โก **Vite** for blazing fast development
- ๐จ **Material-UI v5** with custom theming
- ๐๏ธ **Redux Toolkit** with configured store
- ๐ **Authentication** context and guards
- ๐ฑ **Responsive** design system
#### **Next.js Template**
- ๐ **App Router** for modern routing
- ๐ก๏ธ **Middleware-based** authentication
- ๐ **SEO optimized** with metadata API
- ๐ฏ **Server Components** support
- ๐ฆ **Bundle optimization**
#### **Node.js Template**
- ๐๏ธ **Clean Architecture** with layers
- ๐ **Security** middlewares included
- ๐ **API Documentation** ready
- ๐งช **Testing** setup with Jest
- ๐ณ **Docker** configuration
---
## ๐ Project Structure
### **Next.js App Structure**
```
app/
โโโ layout.tsx # Root layout (Providers, Theme)
โโโ globals.css # Global styles
โโโ auth/
โ โโโ layout.tsx # Auth pages layout
โ โโโ login/page.tsx # Login page
โ โโโ register/page.tsx # Register page
โโโ (dashboard)/ # Route groups
โ โโโ layout.tsx # Protected layout with AuthGuard
โ โโโ dashboard/page.tsx # Dashboard page
โ โโโ settings/page.tsx # Settings page
โ โโโ profile/page.tsx # Profile page
โโโ api/ # API routes
โโโ components/ # Reusable components
โโโ lib/ # Utilities and configurations
```
### **Backend Structure**
```
src/
โโโ controllers/ # Request handlers
โโโ services/ # Business logic
โโโ models/ # Data models
โโโ routes/ # Route definitions
โโโ middleware/ # Custom middleware
โ โโโ auth.middleware.ts
โ โโโ error.middleware.ts
โ โโโ validation.middleware.ts
โโโ dto/ # Data Transfer Objects
โโโ validators/ # Input validation
โโโ utils/ # Helper functions
โโโ types/ # TypeScript types
โโโ server.ts # Application entry point
```
---
## โ๏ธ Backend Architecture
### **๐๏ธ MVC + Service Layer Pattern**
```typescript
// Controller Layer
export class UserController {
async createUser(req: Request, res: Response) {
const result = await this.userService.create(req.body);
res.json(result);
}
}
// Service Layer
export class UserService {
async create(userData: CreateUserDTO): Promise<User> {
// Business logic here
return this.userModel.create(userData);
}
}
// Model Layer
export class UserModel {
async create(data: CreateUserDTO): Promise<User> {
// Database operations
}
}
```
### **๐ Authentication Flow**
1. **Token Storage**: Secure sessionStorage implementation
2. **Context Sync**: AuthContext manages global auth state
3. **Route Protection**: AuthGuard automatically protects routes
4. **Middleware**: JWT validation on backend routes
5. **Auto-refresh**: Token refresh handling
---
## ๐ ๏ธ Advanced Usage
### **๐๏ธ CLI Options**
| Option | Description | Usage |
|--------|-------------|-------|
| `--ts` | Generate TypeScript files | `initrajs c Button --ts` |
| `--js` | Generate JavaScript files | `initrajs c Button --js` |
| `--css` | Include CSS/SCSS files | `initrajs c Button --css` |
| `--test` | Generate test files | `initrajs c Button --test` |
| `--story` | Generate Storybook stories | `initrajs c Button --story` |
| `--path` | Custom file path | `initrajs c Button --path "src/ui"` |
| `--props` | Component props | `initrajs c Button --props "text,onClick"` |
| `--server` | Server-side component | `initrajs c Button --server` |
| `--client` | Client-side component | `initrajs c Button --client` |
| `--layout` | Layout component | `initrajs c Header --layout` |
| `--next` | Next.js page structure | `initrajs page Home --next` |
| `--react` | Standard React page | `initrajs page Home --react` |
### **๐ฏ Smart Defaults**
- **TypeScript First**: Defaults to `.tsx` unless `--js` specified
- **Modern Patterns**: Uses latest React patterns and hooks
- **Best Practices**: Follows industry standards for file organization
- **Performance**: Optimized bundle splitting and lazy loading
- **Accessibility**: WCAG compliant components
### **๐ง Customization**
```bash
# Custom component with all options
initrajs c DataTable \
--ts \
--css \
--test \
--story \
--props "data,columns,onSort,loading" \
--path "src/components/tables"
# Next.js page with custom route
initrajs page UserDashboard \
--next \
--css \
--test \
--path "app/(dashboard)/users"
```
<!-- ---
## ๐ Success Stories
> *"InitraJS cut our project setup time from 2 weeks to 2 hours. The generated code follows all our enterprise standards!"*
> **โ Sarah Chen, Lead Developer at TechCorp**
> *"As a solo developer, InitraJS gives me the structure of a full development team. It's like having senior developers built into my CLI."*
> **โ Mike Rodriguez, Freelance Developer**
> *"We've used InitraJS for 5 client projects. Each time, we deliver faster without sacrificing quality."*
> **โ DevStudio Agency**
--- -->
## ๐ฃ๏ธ Roadmap
### โ
**Completed**
- โ
React, Next.js, Node.js Templates
- โ
TypeScript-first scaffolding
- โ
MUI with theme configuration
- โ
AuthContext + Redux integration
- โ
Class-based API services
- โ
MVC backend with DTO, validation, error handling
- โ
Component & page generators
- โ
CSS/SCSS generation with BEM
- โ
Test file generation (Jest + RTL)
- โ
Storybook story generation
### ๐ง **In Progress**
- ๐ง Database integration templates (Prisma, MongoDB)
- ๐ง Docker containerization
- ๐ง GitHub Actions CI/CD templates
- ๐ง Interactive CLI with project wizard
### ๐ **Planned**
- ๐ Custom template overrides
- ๐ CLI plugins ecosystem
- ๐ Monorepo & microservice support
- ๐ GraphQL API generation
- ๐ E2E testing setup (Playwright)
- ๐ PWA configuration
- ๐ Mobile app templates (React Native)
- ๐ VS Code extension
---
## ๐ Troubleshooting
### **Common Issues & Fixes**
#### **๐ Upgrade CLI**
```bash
npm install -g initrajs@latest
```
#### **๐งน Clear NPX Cache**
```bash
npx clear-npx-cache
npm cache clean --force
```
#### **๐ฆ Node Version**
Ensure you're using Node.js 16+ for optimal compatibility.
#### **๐ง Permission Issues**
```bash
# On macOS/Linux
sudo npm install -g initrajs
# On Windows (Run as Administrator)
npm install -g initrajs
```
#### **๐ Development Mode**
```bash
git clone https://github.com/blessedrajp/initrajs.git
cd initrajs
npm install
npm run dev
npm link # Use local version
```
---
## ๐จโ๐ป Contributing
We welcome contributions! Here's how to get started:
```bash
# Fork and clone the repository
git clone https://github.com/blessedrajp/initrajs.git
cd initrajs
# Install dependencies
npm install
# Start development mode
npm run dev
# Run tests
npm test
# Build the project
npm run build
```
### **๐ฏ Contribution Guidelines**
1. **Fork** the repository
2. **Create** a feature branch (`git checkout -b feature/amazing-feature`)
3. **Commit** your changes (`git commit -m 'Add amazing feature'`)
4. **Push** to the branch (`git push origin feature/amazing-feature`)
5. **Open** a Pull Request
### **๐ Bug Reports**
Please use our [issue template](https://github.com/blessedrajp/initrajs/issues/new) when reporting bugs.
---
## ๐ License
Licensed under the [MIT License](LICENSE).
---
## ๐ Acknowledgments
**Built with โค๏ธ by [Blessed Raj P](https://github.com/blessedrajp)**
*Crafted for developers who value speed, structure, and scalability.*
### **๐ Special Thanks**
- The React and Next.js communities
- Material-UI team for excellent components
- Redux Toolkit for state management excellence
- All contributors and early adopters
---
## ๐ Links
- ๐ **[Official Website](https://initrajs.vercel.app)**
- ๐ **[Documentation](https://initrajs.vercel.app/docs)**
- ๐ **[Interactive Demo](https://initrajs.vercel.app/playground)**
- ๐ฆ **[NPM Package](https://www.npmjs.com/package/initrajs)**
- ๐ **[Report Issues](https://github.com/blessedrajp/initrajs/issues)**
- ๐ฌ **[Discussions](https://github.com/blessedrajp/initrajs/discussions)**
- ๐ฆ **[Twitter Updates](https://twitter.com/blessedrajp)**
---
<div align="center">
**โก InitraJS - From Zero to Production in Minutes โก**
*Star โญ this repo if InitraJS helps speed up your development!*
[](https://github.com/blessedrajp/initrajs/stargazers)
</div>