A comprehensive RESTful API for an Enterprise Resource Planning (ERP) system built with Node.js, Express, and PostgreSQL. This API provides complete backend functionality for managing modules, tables, records, users, roles, permissions, notifications, file uploads, audit logs, and more.
NovaEra ERP API is a robust backend solution designed for enterprise-level resource planning and management. It features a modular architecture with role-based access control, comprehensive audit logging, real-time notifications, file management, and flexible data modeling capabilities.
- π Authentication & Authorization: JWT-based authentication with role-based access control (RBAC)
- π Dynamic Data Modeling: Create and manage custom modules, tables, and columns
- π Record Management: Full CRUD operations for records with assigned users and comments
- π Notifications: Real-time and scheduled notifications system
- π File Management: Secure file upload and management
- π Views & Sorting: Custom views with advanced sorting capabilities
- π Audit Logging: Comprehensive audit trail for all system activities
- π₯ Collaboration: User assignment, comments, and table collaboration features
- β° Scheduled Jobs: Automated notification scheduling using node-cron
- π Relationships: Foreign key relationships between tables and columns
- Runtime: Node.js
- Framework: Express.js
- Database: PostgreSQL
- Authentication: JWT (jsonwebtoken)
- Password Hashing: bcryptjs
- Task Scheduling: node-cron
- File Handling: Built-in Node.js file system
- Environment Management: dotenv
- CORS: cors middleware
- Cookie Parsing: cookie-parser
- Node.js (v14 or higher)
- PostgreSQL (v12 or higher)
- npm or yarn
-
Clone the repository
git clone https://github.com/yourusername/novaera-erp-api.git cd novaera-erp-api -
Install dependencies
npm install
-
Configure environment variables
cp .env.example .env
Edit
.envand fill in your database credentials and other configuration values:# Server Configuration PORT=3001 NODE_ENV=development # Database Configuration DB_HOST=localhost DB_PORT=5432 DB_USER=postgres DB_PASSWORD=your_password DB_NAME=erpsystem # SSL Configuration (options: disable, require, true) DB_SSL=disable # Optional: Database URL (for hosted environments) # DATABASE_URL=postgresql://user:password@host:port/database # JWT Configuration JWT_SECRET=your_jwt_secret_key # CORS Configuration (optional) # CORS_ORIGIN=http://localhost:3000
-
Set up the database
- Create a PostgreSQL database
- Run the SQL schema scripts from
novaera-saas-erp-dbrepository - Ensure the database user has appropriate permissions
-
Start the development server
npm run dev
-
Start the production server
npm start
The API will be available at http://localhost:3001 (or the port specified in your .env file).
Create a .env file in the root directory with the following variables:
# Server Configuration
PORT=3001
NODE_ENV=development
# Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_NAME=your_database_name
# SSL Configuration (options: disable, require, true)
# Set to 'disable' for local development
# Set to 'true' or 'require' for production/hosted databases
DB_SSL=disable
# Optional: Database URL (for hosted environments like Render, Railway, Heroku)
# If provided, this will be used instead of individual DB_* variables
# DATABASE_URL=postgresql://user:password@host:port/database
# JWT Configuration
# Generate a strong secret key for production (minimum 32 characters)
JWT_SECRET=your_jwt_secret_key
# CORS Configuration (optional)
# CORS_ORIGIN=http://localhost:3000See .env.example for a complete template.
novaera-erp-api/
β
βββ src/
β βββ app.js # Express app configuration
β βββ server.js # Server entry point
β β
β βββ config/
β β βββ db.js # Database connection configuration
β β
β βββ controllers/ # Request handlers
β β βββ authController.js
β β βββ modulesController.js
β β βββ tablesController.js
β β βββ columnsController.js
β β βββ columnOptionsController.js
β β βββ recordsController.js
β β βββ recordAssignedUsersController.js
β β βββ recordCommentsController.js
β β βββ recordSubscriptionsController.js
β β βββ usersController.js
β β βββ rolesController.js
β β βββ permissionsController.js
β β βββ notificationsController.js
β β βββ scheduledNotificationsController.js
β β βββ filesController.js
β β βββ viewsController.js
β β βββ viewSortController.js
β β βββ tableCollaboratorsController.js
β β βββ auditLogController.js
β β
β βββ services/ # Business logic layer
β β βββ usersService.js
β β βββ modulesService.js
β β βββ tablesService.js
β β βββ columnsService.js
β β βββ columnOptionsService.js
β β βββ recordsService.js
β β βββ recordAssignedUsersService.js
β β βββ recordCommentsService.js
β β βββ recordSubscriptionsService.js
β β βββ rolesService.js
β β βββ permissionsService.js
β β βββ notificationsService.js
β β βββ scheduledNotificationsService.js
β β βββ filesService.js
β β βββ viewsService.js
β β βββ viewSortService.js
β β βββ tableCollaboratorsService.js
β β βββ auditLogService.js
β β
β βββ routes/ # API routes
β β βββ auth.js
β β βββ modules.js
β β βββ tables.js
β β βββ columns.js
β β βββ columnOptions.js
β β βββ records.js
β β βββ recordAssignedUsers.js
β β βββ recordComments.js
β β βββ recordSubscriptions.js
β β βββ users.js
β β βββ roles.js
β β βββ permissions.js
β β βββ notifications.js
β β βββ scheduledNotifications.js
β β βββ files.js
β β βββ views.js
β β βββ viewSortRoutes.js
β β βββ tableCollaborators.js
β β βββ auditLog.js
β β
β βββ middleware/ # Custom middleware
β β βββ authMiddleware.js # JWT authentication middleware
β β βββ validateFile.js # File upload validation
β β
β βββ jobs/ # Scheduled jobs
β β βββ notificationScheduler.js # Cron job for scheduled notifications
β β
β βββ utils/ # Utility functions
β βββ fileUtils.js # File handling utilities
β
βββ .env.example # Environment variables template
βββ .env # Environment variables (not in git)
βββ .gitignore # Git ignore rules
βββ LICENSE # License file
βββ package.json # Project dependencies
βββ README.md # Project documentation
POST /api/auth/register- Register a new userPOST /api/auth/login- User loginPOST /api/auth/logout- User logoutGET /api/auth/me- Get current user information
GET /api/modules- Get all modulesPOST /api/modules- Create a new moduleGET /api/modules/:id- Get a specific modulePUT /api/modules/:id- Update a moduleDELETE /api/modules/:id- Delete a moduleGET /api/modules/exists/table-name- Check if table name exists in module
GET /api/tables/module/:module_id- Get all tables in a modulePOST /api/tables- Create a new tableGET /api/tables/:table_id- Get a specific tablePUT /api/tables/:table_id- Update a tableDELETE /api/tables/:table_id- Delete a tableGET /api/tables/exists/name- Check if table name exists in module
GET /api/columns- Get all columnsPOST /api/columns- Create a new columnGET /api/columns/table/:table_id- Get columns by tableGET /api/columns/:column_id- Get a specific columnPUT /api/columns/:column_id- Update a columnDELETE /api/columns/:column_id- Delete a columnGET /api/columns/table/:table_id/exists-name- Check if column name exists in tableGET /api/columns/:column_id/has-records- Check if column has records
GET /api/column-options/column/:column_id- Get options for a columnPOST /api/column-options- Create column optionsPUT /api/column-options/:id- Update column optionsDELETE /api/column-options/:id- Delete column options
GET /api/records/table/:table_id- Get all records for a tablePOST /api/records- Create a new recordGET /api/records/:record_id- Get a specific recordPUT /api/records/:record_id- Update a recordDELETE /api/records/:record_id- Delete a recordGET /api/records/table/:table_id/search- Search records by valueGET /api/records/table/:table_id/count- Count records in a tableGET /api/records/table/:table_id/exists-field- Check if field exists in records
GET /api/record-assigned-users/record/:record_id- Get assigned users for a recordPOST /api/record-assigned-users- Assign users to a recordDELETE /api/record-assigned-users/:id- Remove user assignment from record
GET /api/record-comments/record/:record_id- Get comments for a recordPOST /api/record-comments- Create a comment on a recordPUT /api/record-comments/:id- Update a commentDELETE /api/record-comments/:id- Delete a comment
GET /api/record-subscriptions/record/:record_id- Get subscriptions for a recordPOST /api/record-subscriptions- Subscribe to record notificationsDELETE /api/record-subscriptions/:id- Unsubscribe from record notifications
GET /api/users- Get all usersPOST /api/users- Create a new userGET /api/users/:id- Get a specific userPUT /api/users/:id- Update a userPUT /api/users/:id/password- Update user passwordDELETE /api/users/:id- Delete a userPUT /api/users/:id/block- Block a userPUT /api/users/:id/unblock- Unblock a userPUT /api/users/:id/active- Set user active statusPUT /api/users/:id/reset-password- Reset password (admin only)GET /api/users/exists/email- Check if email existsPUT /api/users/:id/avatar- Set user avatar
GET /api/roles- Get all rolesPOST /api/roles- Create a new roleGET /api/roles/:id- Get a specific rolePOST /api/roles/:id/assign- Assign role to userDELETE /api/roles/:id/remove- Remove role from userGET /api/roles/user/:user_id- Get roles for a userPOST /api/roles/:id/permissions- Set role permissionsPUT /api/roles/:id/permissions- Update role permissionsGET /api/roles/:id/permissions/:table_id- Get role permissions for a tableDELETE /api/roles/:id/permissions/:table_id- Delete role permissions
GET /api/permissions- Get all permissionsPOST /api/permissions- Create a new permissionGET /api/permissions/role/:role_id/table/:table_id- Get role-table permissionsDELETE /api/permissions/role/:role_id/table/:table_id- Delete role-table permissionsGET /api/permissions/table/:table_id/users- Get users with permissions for a tablePOST /api/permissions/table/:table_id/roles- Assign massive permissionsDELETE /api/permissions/table/:table_id- Delete all permissions for a table
GET /api/notifications- Get all notificationsPOST /api/notifications- Create a new notificationPOST /api/notifications/massive- Create massive notificationsGET /api/notifications/user/:user_id- Get notifications for a userPUT /api/notifications/:notification_id/read- Mark notification as readPUT /api/notifications/user/:user_id/read-all- Mark all notifications as readDELETE /api/notifications/:notification_id- Delete a notificationDELETE /api/notifications/user/:user_id- Delete all notifications for a userGET /api/notifications/user/:user_id/unread-count- Get unread notification count
GET /api/scheduled-notifications- Get all scheduled notificationsPOST /api/scheduled-notifications- Create a scheduled notificationGET /api/scheduled-notifications/:id- Get a specific scheduled notificationPUT /api/scheduled-notifications/:id- Update a scheduled notificationDELETE /api/scheduled-notifications/:id- Delete a scheduled notificationGET /api/scheduled-notifications/user/:user_id- Get scheduled notifications for a user
GET /api/views- Get all viewsPOST /api/views- Create a new viewGET /api/views/:id- Get a specific viewPUT /api/views/:id- Update a viewDELETE /api/views/:id- Delete a viewGET /api/views/table/:table_id- Get views for a table
GET /api/view-sorts/view/:view_id- Get sorts for a viewPOST /api/view-sorts- Create a view sortPUT /api/view-sorts/:id- Update a view sortDELETE /api/view-sorts/:id- Delete a view sort
GET /api/table-collaborators/table/:table_id- Get collaborators for a tablePOST /api/table-collaborators- Add a collaborator to a tableDELETE /api/table-collaborators/:id- Remove a collaborator from a table
POST /api/files/upload- Upload a fileGET /api/files/:id- Get file metadataGET /api/files/:id/download- Download a fileDELETE /api/files/:id- Delete a file
GET /api/audit-log- Get audit logsGET /api/audit-log/record/:record_id- Get audit logs for a recordGET /api/audit-log/user/:user_id- Get audit logs for a userGET /api/audit-log/table/:table_id- Get audit logs for a table
- JWT-based authentication with secure cookie storage
- Password hashing using bcryptjs
- Role-based access control (RBAC)
- CORS configuration for allowed origins
- SQL injection prevention through parameterized queries
- Input validation and sanitization
- Audit logging for security monitoring
- File upload validation and size limits
- Protected routes with authentication middleware
- Render: Easy deployment with PostgreSQL support
- Railway: Simple setup with automatic database provisioning
- Heroku: Traditional PaaS with add-on support
- AWS: Full control with EC2, RDS, and Elastic Beanstalk
- DigitalOcean: App Platform or Droplets
- Vercel: Serverless functions (may require adjustments)
- Set
NODE_ENV=productionin environment variables - Configure production database credentials
- Set a strong
JWT_SECRET(minimum 32 characters) - Configure
DB_SSLappropriately for your database provider - Update CORS allowed origins in
src/app.jsor viaCORS_ORIGINenvironment variable - Ensure database migrations are run
- Set up environment variables on your hosting platform
- Configure automatic restarts (PM2, systemd, etc.)
- Set up file storage directory with proper permissions
- Configure cron job for scheduled notifications
- Connect your GitHub repository to Render
- Create a new Web Service
- Set build command:
npm install - Set start command:
npm start - Add environment variables from your
.envfile - Create a PostgreSQL database on Render
- Update database connection variables
- Deploy
npm start- Start the production servernpm run dev- Start the development server with nodemon
- Use environment variables for all configuration
- Follow the existing code structure and patterns
- Add appropriate error handling
- Write meaningful commit messages
- Test API endpoints before committing
- Use parameterized queries for all database operations
- Implement proper logging for debugging
- Follow RESTful API conventions
This project is proprietary and confidential. All rights reserved.
Redistribution, modification, reproduction, sublicensing, or any form of transaction (including commercial, educational, or promotional use) involving this repository, its source code, or derived works is strictly prohibited without the explicit and personal written authorization of the Lead Developer, Steven Morales Fallas.
Unauthorized commercial use, resale, or licensing of this repository or its contents is strictly forbidden and will be subject to applicable legal action.
For licensing inquiries, please contact: Steven Morales Fallas
- Full Stack Developer
- Specialized in Node.js, Express, PostgreSQL, and modern web technologies
This is a proprietary project. Contributions are not accepted at this time. For collaboration inquiries, please contact the author.
For issues, questions, or licensing inquiries, please contact the project maintainer.
Note: This API is designed to work with a frontend application (novaera-saas-erp-web) and database (novaera-saas-erp-db). Ensure proper CORS configuration and authentication flow when integrating with client applications.