The Nexus Tech Server is the backend for the Nexus Tech Employee Management System (EMS). It provides robust APIs for managing employees, handling authentication, processing payments, and interacting with the database.
This backend is built using Node.js and Express, with MongoDB as the database. It ensures secure authentication with JWT, manages real-time data, and integrates Stripe for payment processing.
✅ User Authentication – Secure login & signup with JWT-based authentication.
✅ Employee Management – Manage employee records, attendance, and HR-related data.
✅ Role-Based Access Control (RBAC) – Secure different access levels for admins, HR, and employees.
✅ Database Management – Uses MongoDB for efficient and scalable data storage.
✅ Secure API Communication – Implements CORS, cookie-parser, and dotenv for secure data flow.
✅ Payment Integration – Processes transactions securely using Stripe.
✅ Google Gemini AI Integration – Leverages Google AI API for smart automation.
✅ Logging & Monitoring – Uses Morgan for detailed request logging.
| Technology | Purpose |
|---|---|
| Node.js | JavaScript Runtime |
| Express.js | Web Framework |
| MongoDB | NoSQL Database |
| JWT (jsonwebtoken) | Authentication |
| Stripe API | Payment Processing |
| Google Gemini AI API | AI-powered automation |
| Dotenv | Environment Configuration |
| Morgan | HTTP Request Logging |
| CORS | Cross-Origin Requests Handling |
- Node.js (>=16.0.0)
- MongoDB Atlas or Local MongoDB Instance
- Clone the repository:
git clone https://github.com/nodeNINJAr/nexus-tech-server cd nexus-tech-server - Install dependencies:
npm install
- Create a
.envfile and configure the environment variables (see Environment Variables). - Start the development server:
npm run dev
- Start the production server:
npm start
- Start the development server with live reload:
npm run dev
| Command | Description |
|---|---|
npm start |
Start the production server |
npm run dev |
Start the server with Nodemon for live reload |
Create a .env file in the root directory and configure the following:
PORT=5000
# MongoDB Database
DB_USER=your-db-username
DB_PASS=your-db-password
MONGODB_URI=mongodb+srv://$(DB_USER):$(DB_PASS)@cluster.mongodb.net/nexus-tech?retryWrites=true&w=majority
# Authentication
JWT_SECRET_KEY=your-secret-key
# Stripe Payment Integration
STRIPE_SECRET=your-stripe-secret-key
# Google Gemini AI API
GEMINI_API_KEY=your-google-gemini-api-keyEnsure your MongoDB URI is correctly configured in your .env file.
For local MongoDB, use:
MONGODB_URI=mongodb://localhost:27017/nexus-techFor MongoDB Atlas, replace it with your cloud connection string.
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/auth/register |
Register a new user |
POST |
/api/auth/login |
Login user & generate JWT |
GET |
/api/auth/user |
Get user profile |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/employees |
Get all employees |
POST |
/api/employees |
Add a new employee |
PUT |
/api/employees/:id |
Update employee details |
DELETE |
/api/employees/:id |
Remove an employee |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/payments/create |
Create a new payment session |
GET |
/api/payments/status |
Check payment status |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/ai/generate-summary |
Generate employee performance summary using Gemini AI |
POST |
/api/ai/automate-tasks |
AI-powered HR task automation |
For full API documentation, refer to api-docs.md (if available).
-
Server Not Starting?
Ensure MongoDB is running and your.envvariables are set up correctly. -
CORS Issues?
Update yourcorsconfiguration inindex.js:app.use(cors({ origin: "http://localhost:5173", credentials: true }));
-
Invalid JWT Token?
- Make sure the token is correctly passed in the Authorization header.
- Check if
JWT_SECRET_KEYis correctly set in.env.
-
Google Gemini API Not Working?
- Ensure
GEMINI_API_KEYis correctly set in.env. - Verify that your Google AI API quota is not exceeded.
- Ensure