Skip to content

nodeNINJAr/nexus-tech-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nexus Tech – Server

🚀 Introduction

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.


📑 Table of Contents


🌟 Features

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.


🛠 Tech Stack

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

📥 Installation

Prerequisites

  • Node.js (>=16.0.0)
  • MongoDB Atlas or Local MongoDB Instance

Steps

  1. Clone the repository:
    git clone https://github.com/nodeNINJAr/nexus-tech-server
    cd nexus-tech-server
  2. Install dependencies:
    npm install
  3. Create a .env file and configure the environment variables (see Environment Variables).
  4. Start the development server:
    npm run dev

▶️ Usage

  • Start the production server:
    npm start
  • Start the development server with live reload:
    npm run dev

📜 Available Scripts

Command Description
npm start Start the production server
npm run dev Start the server with Nodemon for live reload

⚙️ Environment Variables

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-key

MongoDB Connection

Ensure your MongoDB URI is correctly configured in your .env file.
For local MongoDB, use:

MONGODB_URI=mongodb://localhost:27017/nexus-tech

For MongoDB Atlas, replace it with your cloud connection string.


🔗 API Endpoints

Authentication

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

Employee Management

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

Payment Processing

Method Endpoint Description
POST /api/payments/create Create a new payment session
GET /api/payments/status Check payment status

AI-Powered Features

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).


🛠 Troubleshooting

  • Server Not Starting?
    Ensure MongoDB is running and your .env variables are set up correctly.

  • CORS Issues?
    Update your cors configuration in index.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_KEY is correctly set in .env.
  • Google Gemini API Not Working?

    • Ensure GEMINI_API_KEY is correctly set in .env.
    • Verify that your Google AI API quota is not exceeded.

About

Nexus Tech (employee management website)- server side code

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published