Skip to content

A modern, scalable Node.js boilerplate with Express.js, featuring a well-structured architecture, built-in authentication, database integration, and comprehensive helper utilities.

License

Notifications You must be signed in to change notification settings

Asadaaaaa/EssadaJS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

EssadaJS

EssadaJS Icon

A modern, scalable Node.js boilerplate with Express.js, featuring a well-structured architecture, built-in authentication, database integration, and comprehensive helper utilities.

πŸš€ Features

Core Architecture

  • Modular Structure: Clean separation of concerns with controllers, services, repositories, validators, and middlewares
  • Multi-threading: Built-in cluster support for better performance
  • API Versioning: Organized route structure with version control
  • Environment Configuration: Easy environment variable management

Authentication & Security

  • JWT Authentication: Secure token-based authentication
  • Password Hashing: BCrypt integration for secure password storage
  • SHA256 Utilities: Additional cryptographic helpers
  • Authorization Middleware: Role-based access control

Database Integration

  • Sequelize ORM: Full database support with MySQL
  • Model Handler: Centralized database connection management
  • Query Logging: Built-in SQL query logging for debugging

File Management

  • AWS S3 Integration: Cloud file storage capabilities
  • File System Helper: Local file operations utilities
  • File Type Detection: Automatic file type recognition

Communication

  • Email Service: Nodemailer integration for email functionality
  • QR Code Generation: Built-in QR code utilities

AI Integration

  • Gemini AI Helper: Google Gemini AI integration
  • AI-powered Features: Ready-to-use AI capabilities

Development Tools

  • Comprehensive Logging: Structured logging system
  • Response Presets: Standardized API response formats
  • Validation: AJV schema validation
  • CORS Support: Cross-origin resource sharing
  • Morgan Logging: HTTP request logging

πŸ“ Project Structure

EssadaJS/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ controllers/          # Request handlers
β”‚   β”‚   └── primary/v1/
β”‚   β”‚       β”œβ”€β”€ Auth.controller.js
β”‚   β”‚       └── index.js
β”‚   β”œβ”€β”€ helpers/             # Utility functions
β”‚   β”‚   β”œβ”€β”€ FileSystem.helper.js
β”‚   β”‚   β”œβ”€β”€ GeminiAI.helper.js
β”‚   β”‚   β”œβ”€β”€ JWT.helper.js
β”‚   β”‚   β”œβ”€β”€ Logger.helper.js
β”‚   β”‚   β”œβ”€β”€ Mailer.helper.js
β”‚   β”‚   β”œβ”€β”€ ResponsePreset.helper.js
β”‚   β”‚   β”œβ”€β”€ SHA256.helper.js
β”‚   β”‚   └── index.js
β”‚   β”œβ”€β”€ middlewares/         # Request processing
β”‚   β”‚   β”œβ”€β”€ Handler.middleware.js
β”‚   β”‚   β”œβ”€β”€ primary/v1/
β”‚   β”‚   β”‚   └── Authorization.middleware.js
β”‚   β”‚   └── index.js
β”‚   β”œβ”€β”€ models/              # Database models
β”‚   β”‚   β”œβ”€β”€ Handler.model.js
β”‚   β”‚   β”œβ”€β”€ Users.model.example.js
β”‚   β”‚   └── index.js
β”‚   β”œβ”€β”€ repositories/        # Data access layer
β”‚   β”‚   └── primary/v1/
β”‚   β”‚       β”œβ”€β”€ User.repository.js
β”‚   β”‚       └── index.js
β”‚   β”œβ”€β”€ routes/              # API endpoints
β”‚   β”‚   β”œβ”€β”€ Handler.route.js
β”‚   β”‚   └── primary/v1/
β”‚   β”‚       β”œβ”€β”€ Auth.route.js
β”‚   β”‚       β”œβ”€β”€ Handler.route.js
β”‚   β”‚       └── index.js
β”‚   β”œβ”€β”€ services/            # Business logic
β”‚   β”‚   └── primary/v1/
β”‚   β”‚       β”œβ”€β”€ Auth.service.js
β”‚   β”‚       └── index.js
β”‚   β”œβ”€β”€ validators/          # Request validation
β”‚   β”‚   └── primary/v1/
β”‚   β”‚       β”œβ”€β”€ Auth.validator.js
β”‚   β”‚       └── index.js
β”‚   └── Main.js             # Application entry point
β”œβ”€β”€ storage/                 # File storage
β”‚   β”œβ”€β”€ app/
β”‚   └── configs/
β”œβ”€β”€ package.json
└── README.md

πŸ› οΈ Installation

  1. Clone the repository

    git clone <repository-url>
    cd EssadaJS
  2. Install dependencies

    npm install
  3. Environment Setup Create a .env file in the root directory:

    # Server Configuration
    PORT=3000
    IP=0.0.0.0
    SERVER_THREADS=4
    
    # Database Configuration
    DB_ENABLE=true
    DB_HOST=localhost
    DB_PORT=3306
    DB_USERNAME=your_username
    DB_PASSWORD=your_password
    DB_DATABASE=your_database
    DB_DIALECT=mysql
    DB_LOGGING=true
    
    # JWT Configuration
    JWT_SECRET=your_jwt_secret
    JWT_EXPIRES_IN=24h
    
    # Email Configuration
    EMAIL_HOST=smtp.gmail.com
    EMAIL_PORT=587
    EMAIL_USER=your_email@gmail.com
    EMAIL_PASS=your_app_password
    
    # Gemini AI Configuration (optional)
    GEMINI_API_KEY=your_gemini_api_key

πŸš€ Usage

Development Mode

npm run dev

Production Mode

npm start

πŸ“š Example API Response

Response:

{
  "status": 200,
  "message": "OK",
  "data": {
    "token": "jwt_token_here",
    "user": {
      "id": 1,
      "email": "user@example.com",
      "name": "User Name"
    }
  }
}

Response Format

All API responses follow a standardized format:

Success Response:

{
  "status": 200,
  "message": "Success message",
  "data": { /* response data */ }
}

Error Response:

{
  "status": 400,
  "message": "Error message",
  "err": {
    "type": "validation",
    "data": { /* error details */ }
  }
}

πŸ”§ Configuration

Database Models

Create your database models in src/models/ following the Sequelize pattern:

// Example: src/models/Users.model.js
import { DataTypes } from 'sequelize';

export default (sequelize) => {
  const User = sequelize.define('User', {
    id: {
      type: DataTypes.INTEGER,
      primaryKey: true,
      autoIncrement: true
    },
    email: {
      type: DataTypes.STRING,
      unique: true,
      allowNull: false
    },
    password: {
      type: DataTypes.STRING,
      allowNull: false
    }
  });
  
  return User;
};

Adding New Routes

  1. Create controller in src/controllers/primary/v1/
  2. Create service in src/services/primary/v1/
  3. Create validator in src/validators/primary/v1/
  4. Create repository in src/repositories/primary/v1/
  5. Add route in src/routes/primary/v1/

πŸ›‘οΈ Security Features

  • JWT Token Authentication
  • Password Hashing with BCrypt
  • CORS Protection
  • Request Validation with AJV
  • SQL Injection Protection (Sequelize)
  • Environment Variable Security

πŸ“¦ Dependencies

Core Dependencies

  • Express.js: Web framework
  • Sequelize: ORM for database operations
  • MySQL2: MySQL database driver
  • JWT: JSON Web Token authentication
  • BCrypt: Password hashing

Development Dependencies

  • Nodemon: Development server with auto-reload
  • Morgan: HTTP request logger

Utility Dependencies

  • Axios: HTTP client
  • Nodemailer: Email functionality
  • QRCode: QR code generation
  • AWS SDK: Cloud storage integration
  • Moment: Date/time utilities

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the ISC License.

πŸ†˜ Support

For support and questions, please open an issue in the repository.


EssadaJS - A modern Node.js boilerplate for building scalable applications.

About

A modern, scalable Node.js boilerplate with Express.js, featuring a well-structured architecture, built-in authentication, database integration, and comprehensive helper utilities.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published