A modern, scalable Node.js boilerplate with Express.js, featuring a well-structured architecture, built-in authentication, database integration, and comprehensive helper utilities.
- 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
- 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
- Sequelize ORM: Full database support with MySQL
- Model Handler: Centralized database connection management
- Query Logging: Built-in SQL query logging for debugging
- AWS S3 Integration: Cloud file storage capabilities
- File System Helper: Local file operations utilities
- File Type Detection: Automatic file type recognition
- Email Service: Nodemailer integration for email functionality
- QR Code Generation: Built-in QR code utilities
- Gemini AI Helper: Google Gemini AI integration
- AI-powered Features: Ready-to-use AI capabilities
- 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
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
-
Clone the repository
git clone <repository-url> cd EssadaJS
-
Install dependencies
npm install
-
Environment Setup Create a
.envfile 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
npm run devnpm startResponse:
{
"status": 200,
"message": "OK",
"data": {
"token": "jwt_token_here",
"user": {
"id": 1,
"email": "user@example.com",
"name": "User Name"
}
}
}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 */ }
}
}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;
};- Create controller in
src/controllers/primary/v1/ - Create service in
src/services/primary/v1/ - Create validator in
src/validators/primary/v1/ - Create repository in
src/repositories/primary/v1/ - Add route in
src/routes/primary/v1/
- JWT Token Authentication
- Password Hashing with BCrypt
- CORS Protection
- Request Validation with AJV
- SQL Injection Protection (Sequelize)
- Environment Variable Security
- Express.js: Web framework
- Sequelize: ORM for database operations
- MySQL2: MySQL database driver
- JWT: JSON Web Token authentication
- BCrypt: Password hashing
- Nodemon: Development server with auto-reload
- Morgan: HTTP request logger
- Axios: HTTP client
- Nodemailer: Email functionality
- QRCode: QR code generation
- AWS SDK: Cloud storage integration
- Moment: Date/time utilities
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the ISC License.
For support and questions, please open an issue in the repository.
EssadaJS - A modern Node.js boilerplate for building scalable applications.