UNPKG

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
# โšก InitraJS > The ultimate fullstack scaffolding CLI. Zero config, maximum productivity. Built for speed, scalability, and modern dev workflows. [![NPM Version](https://img.shields.io/npm/v/initrajs?color=blue)](https://www.npmjs.com/package/initrajs) [![Downloads](https://img.shields.io/npm/dw/initrajs.svg)](https://www.npmjs.com/package/initrajs) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) [![Made by Blessed Raj P](https://img.shields.io/badge/made%20by-blessedrajp-blueviolet)](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!* [![GitHub stars](https://img.shields.io/github/stars/blessedrajp/initrajs?style=social)](https://github.com/blessedrajp/initrajs/stargazers) </div>