Skip to content

ErickXavier-dev/Savishkaara-Control-Panel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

209 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Savishkaara Control Panel

License: MIT Node.js React MongoDB

A comprehensive administrative control panel for event management, user administration, and real-time system monitoring. Built with React, Node.js, Express, and MongoDB.

πŸ“‹ Table of Contents

✨ Features

Event Management

  • Event Creation & Management: Create, update, and delete events
  • Event Registration System: Handle participant registrations
  • Event Overview Dashboard: Monitor all events at a glance
  • Event Coordinator Panel: Specialized view for event coordinators

User Management

  • User Authentication: Secure login and session management
  • Role-Based Access Control: Different access levels (admin, coordinator, etc.)
  • User Overview: Comprehensive user management dashboard
  • Bulk User Operations: Add and manage multiple users efficiently

Real-Time Features

  • Live Dashboard Updates: Real-time metrics and statistics via WebSocket
  • System Monitoring: Track server health, CPU, memory usage, and uptime
  • Live Event Updates: Automatic updates for event changes
  • Room Management: Real-time room allocation and updates

Administrative Tools

  • Server Status Control: Dynamic server mode switching (online, restricted, offline)
  • Email Management: Built-in mailing system
  • Analytics Dashboard: Visualizations with charts and graphs
  • Samridhi Integration: Special module for Samridhi event management

πŸ›  Tech Stack

Frontend

  • Framework: React 18.2
  • UI Components: Material-UI (MUI)
  • Routing: React Router DOM
  • Real-time Communication: Socket.io Client
  • Charts & Visualizations:
    • Chart.js with React-Chartjs-2
    • D3.js
    • Recharts
  • Animations: React Spring
  • State Management: React Context API
  • HTTP Client: Axios
  • Build Tool: Next.js 14

Backend

  • Runtime: Node.js
  • Framework: Express.js
  • Database: MongoDB with Mongoose ODM
  • Real-time: Socket.io
  • Authentication: Express Session with bcryptjs
  • File Upload: Multer
  • System Monitoring:
    • pidusage
    • systeminformation
  • Security: CORS, HTTPS enforcement

Development Tools

  • Process Management: Concurrently, Nodemon
  • Linting: ESLint
  • Environment Management: dotenv

πŸ— Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Frontend (React)                    β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚  Dashboard   β”‚  β”‚    Events    β”‚  β”‚    Users     β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                          β”‚                              β”‚
β”‚                   WebSocket / REST API                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Backend (Express.js)                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚     Auth     β”‚  β”‚    Events    β”‚  β”‚  Real-time   β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                          β”‚                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
                    β”‚   MongoDB   β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“¦ Prerequisites

  • Node.js: v18.0.0 or higher
  • npm: v8.0.0 or higher
  • MongoDB: v6.0 or higher (local or cloud instance)
  • Git: For version control

πŸš€ Installation

1. Clone the Repository

git clone https://github.com/ErickXavier-dev/Savishkaara-Control-Panel.git
cd Savishkaara-Control-Panel

2. Install Dependencies

Install root dependencies:

npm install

Install backend dependencies:

cd backend
npm install
cd ..

Install frontend dependencies:

cd frontend
npm install
cd ..

Or use the convenient update script:

npm run update

βš™οΈ Configuration

1. Backend Configuration

Create a .env file in the backend directory:

# Server Configuration
PORT=5000
NODE_ENV=development

# MongoDB Connection
MONGO_URI=mongodb://localhost:27017/savishkaara
# Or for MongoDB Atlas:
# MONGO_URI=mongodb+srv://<username>:<password>@cluster.mongodb.net/savishkaara

# Session Configuration
COOKIE_NAME=savishkaara_session
SESSION_SECRET=your-secure-session-secret-here

# CORS Origins (comma-separated)
ALLOWED_ORIGINS=http://localhost:3000,https://control.savishkaara.in

# Production Settings (if applicable)
# FORCE_HTTPS=true

2. Frontend Configuration

Create a .env file in the frontend directory:

# API Configuration
REACT_APP_API_URL=http://localhost:5000
REACT_APP_PROD_API_URL=https://testapi.amritaiedc.site

# WebSocket Configuration
REACT_APP_SOCKET_URL=http://localhost:5000

3. MongoDB Setup

Ensure MongoDB is running:

Local MongoDB:

mongod --dbpath /path/to/your/data/directory

Or use MongoDB Atlas (cloud) and update the MONGO_URI in your .env file.

πŸƒ Running the Application

Development Mode

Run both frontend and backend concurrently:

npm start

This will start:

  • Backend server on http://localhost:5000
  • Frontend development server on http://localhost:3000

Run backend only:

npm run server

Run frontend only:

npm run client

Production Mode

Build and run in production:

npm run test

This will:

  1. Set NODE_ENV=production for the backend
  2. Build the frontend for production
  3. Serve the built frontend using serve

πŸ“ Project Structure

Savishkaara-Control-Panel/
β”œβ”€β”€ backend/                      # Backend application
β”‚   β”œβ”€β”€ db/
β”‚   β”‚   └── mongodb.js           # MongoDB connection setup
β”‚   β”œβ”€β”€ models/                  # Mongoose models
β”‚   β”‚   β”œβ”€β”€ event_registration.js
β”‚   β”‚   β”œβ”€β”€ events.js
β”‚   β”‚   └── User.js
β”‚   β”œβ”€β”€ routes/                  # API routes
β”‚   β”‚   β”œβ”€β”€ addusers.js         # User creation routes
β”‚   β”‚   β”œβ”€β”€ auth.js             # Authentication routes
β”‚   β”‚   β”œβ”€β”€ eventManager.js     # Event management routes
β”‚   β”‚   β”œβ”€β”€ realTime.js         # Real-time WebSocket handlers
β”‚   β”‚   β”œβ”€β”€ roomUpdater.js      # Room management
β”‚   β”‚   β”œβ”€β”€ userOVERVIEW.js     # User overview routes
β”‚   β”‚   β”œβ”€β”€ users.js            # User management routes
β”‚   β”‚   └── verify.js           # Verification routes
β”‚   β”œβ”€β”€ server.js               # Express server entry point
β”‚   └── package.json
β”‚
β”œβ”€β”€ frontend/                    # Frontend application
β”‚   β”œβ”€β”€ public/                 # Static files
β”‚   β”‚   β”œβ”€β”€ icons/
β”‚   β”‚   β”œβ”€β”€ images/
β”‚   β”‚   └── profile/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/         # Reusable components
β”‚   β”‚   β”‚   β”œβ”€β”€ blurText.js
β”‚   β”‚   β”‚   β”œβ”€β”€ header.js
β”‚   β”‚   β”‚   β”œβ”€β”€ metricCard.js
β”‚   β”‚   β”‚   β”œβ”€β”€ metricCardData.js
β”‚   β”‚   β”‚   β”œβ”€β”€ sidebar.js
β”‚   β”‚   β”‚   └── visualizationCard.js
β”‚   β”‚   β”œβ”€β”€ css/                # Component styles
β”‚   β”‚   β”œβ”€β”€ layouts/            # Layout components
β”‚   β”‚   β”‚   └── layout.js
β”‚   β”‚   β”œβ”€β”€ pages/              # Page components
β”‚   β”‚   β”‚   β”œβ”€β”€ addEvent.js
β”‚   β”‚   β”‚   β”œβ”€β”€ addUser.js
β”‚   β”‚   β”‚   β”œβ”€β”€ dashboard.js
β”‚   β”‚   β”‚   β”œβ”€β”€ eventOverview.js
β”‚   β”‚   β”‚   β”œβ”€β”€ eventReg.js
β”‚   β”‚   β”‚   β”œβ”€β”€ forbidden.js
β”‚   β”‚   β”‚   β”œβ”€β”€ login.js
β”‚   β”‚   β”‚   β”œβ”€β”€ mailer.js
β”‚   β”‚   β”‚   β”œβ”€β”€ myEvent.js
β”‚   β”‚   β”‚   β”œβ”€β”€ samridhi.js
β”‚   β”‚   β”‚   β”œβ”€β”€ server.js
β”‚   β”‚   β”‚   β”œβ”€β”€ updatePassword.js
β”‚   β”‚   β”‚   └── userOverview.js
β”‚   β”‚   β”œβ”€β”€ utils/              # Utility functions
β”‚   β”‚   β”‚   β”œβ”€β”€ roomManager.js
β”‚   β”‚   β”‚   └── socketConnector.js
β”‚   β”‚   β”œβ”€β”€ App.js              # Main application component
β”‚   β”‚   └── index.js            # React entry point
β”‚   └── package.json
β”‚
β”œβ”€β”€ package.json                # Root package.json
β”œβ”€β”€ LICENSE                     # MIT License
└── README.md                   # This file

πŸ”Œ API Documentation

The API follows RESTful principles and uses JSON for request/response bodies. All endpoints require appropriate authentication unless otherwise specified.

Base URL

  • Development: http://localhost:5000
  • Production: https://testapi.amritaiedc.site

Common Headers

{
  "Content-Type": "application/json",
  "X-Allowed-Origin": "savishkaara.in" // Required in production
}

πŸ” Authentication Endpoints

Login

Authenticate a user and create a session.

Endpoint: POST /login-auth

Request Body:

{
  "username": "string",
  "password": "string"
}

Success Response (200 OK):

{
  "message": "Login successful",
  "objectID": "507f1f77bcf86cd799439011",
  "name": "John Doe",
  "gender": "male",
  "department": "CSE",
  "role": "admin"
}

Password Reset Required (200 OK):

{
  "redirectToUpdatePassword": true,
  "objectID": "507f1f77bcf86cd799439011",
  "name": "John Doe",
  "gender": "male",
  "department": "CSE",
  "role": "coor"
}

Error Response (401 Unauthorized):

{
  "error": "Invalid username or password"
}

Check Authentication Status

Verify if the current session is authenticated.

Endpoint: GET /check-auth

Success Response (200 OK):

{
  "isAuthenticated": true,
  "objectID": "507f1f77bcf86cd799439011",
  "name": "John Doe",
  "gender": "male",
  "department": "CSE",
  "role": "admin"
}

Unauthenticated Response (200 OK):

{
  "isAuthenticated": false
}

Update Password

Update user password (typically after first login).

Endpoint: POST /update-password

Authentication: Required (Session-based)

Request Body:

{
  "password": "newSecurePassword123"
}

Success Response (200 OK):

{
  "message": "Password updated successfully"
}

Error Response (404 Not Found):

{
  "error": "User not found"
}

Logout

End the current user session.

Endpoint: POST /logout

Authentication: Required

Success Response (200 OK):

{
  "message": "Logged out successfully"
}

πŸŽ‰ Event Management Endpoints

Get All Events

Retrieve list of all events with basic information.

Endpoint: GET /events

Success Response (200 OK):

[
  {
    "_id": "507f1f77bcf86cd799439011",
    "name": "Tech Fest 2025",
    "venue": "Main Auditorium",
    "coordinators": ["John Doe", "Jane Smith"],
    "status": "upcoming",
    "date_time": "2025-12-20T10:00:00.000Z"
  }
]

Get Event by ID

Retrieve detailed information about a specific event.

Endpoint: GET /events/:eventId

Parameters:

  • eventId (string, required): MongoDB ObjectId of the event

Success Response (200 OK):

{
  "_id": "507f1f77bcf86cd799439011",
  "name": "Tech Fest 2025",
  "venue": "Main Auditorium",
  "date_time": "2025-12-20T10:00:00.000Z",
  "fee": 500,
  "coordinators": ["John Doe", "Jane Smith"],
  "faculty_coordinators": ["Dr. Kumar", "Prof. Sharma"],
  "form_link": "https://forms.example.com/techfest",
  "excel_link": "https://docs.example.com/excel",
  "status": "upcoming"
}

Error Response (400 Bad Request):

{
  "error": "Invalid event ID"
}

Error Response (404 Not Found):

{
  "error": "Event not found"
}

Get Event by Name

Retrieve event details by event name.

Endpoint: GET /events/by-name/:name

Parameters:

  • name (string, required): Event name

Success Response (200 OK):

{
  "_id": "507f1f77bcf86cd799439011",
  "name": "Tech Fest 2025",
  "venue": "Main Auditorium",
  "date_time": "2025-12-20T10:00:00.000Z",
  "fee": 500,
  "coordinators": ["John Doe", "Jane Smith"],
  "faculty_coordinators": ["Dr. Kumar", "Prof. Sharma"],
  "status": "upcoming"
}

Get Events by Coordinator

Retrieve all events managed by a specific coordinator.

Endpoint: GET /events/by-coordinator/:username

Parameters:

  • username (string, required): Coordinator's username

Success Response (200 OK):

[
  {
    "_id": "507f1f77bcf86cd799439011",
    "name": "Tech Fest 2025",
    "venue": "Main Auditorium",
    "coordinators": ["johncoord"],
    "faculty_coordinators": ["Dr. Kumar"],
    "status": "upcoming"
  }
]

Error Response (404 Not Found):

{
  "error": "No events found for this username",
  "details": "Username 'john' not found in coordinators or faculty coordinators"
}

Create Event

Add a new event to the system.

Endpoint: POST /addEvent

Authentication: Required (Admin/Super role)

Request Body:

{
  "name": "Tech Fest 2025",
  "venue": "Main Auditorium",
  "dateAndTime": "2025-12-20T10:00:00.000Z",
  "fee": 500,
  "coordinators": ["John Doe", "Jane Smith"],
  "facultyCoordinators": ["Dr. Kumar", "Prof. Sharma"],
  "registrationLink": "https://forms.example.com/techfest",
  "excelLink": "https://docs.example.com/excel"
}

Success Response (201 Created):

{
  "message": "Event added successfully",
  "event": {
    "_id": "507f1f77bcf86cd799439011",
    "name": "Tech Fest 2025",
    "venue": "Main Auditorium",
    "date_time": "2025-12-20T10:00:00.000Z",
    "fee": 500,
    "coordinators": ["John Doe", "Jane Smith"],
    "faculty_coordinators": ["Dr. Kumar", "Prof. Sharma"],
    "form_link": "https://forms.example.com/techfest",
    "excel_link": "https://docs.example.com/excel",
    "status": "upcoming"
  }
}

Error Response (400 Bad Request):

{
  "error": "All required fields must be provided"
}

Update Event Status

Change the status of an event (upcoming, ongoing, completed).

Endpoint: POST /events/update-status-by-name

Authentication: Required

Request Body:

{
  "name": "Tech Fest 2025",
  "status": "ongoing"
}

Success Response (200 OK):

{
  "_id": "507f1f77bcf86cd799439011",
  "name": "Tech Fest 2025",
  "status": "ongoing",
  "venue": "Main Auditorium"
}

Update Event Details

Update comprehensive event information.

Endpoint: POST /events/update-details-by-name

Authentication: Required

Request Body:

{
  "name": "Tech Fest 2025",
  "venue": "New Auditorium",
  "date_time": "2025-12-21T10:00:00.000Z",
  "fee": 600,
  "coordinators": ["John Doe", "Jane Smith", "Bob Wilson"],
  "faculty_coordinators": ["Dr. Kumar"],
  "form_link": "https://forms.example.com/techfest-updated",
  "excel_link": "https://docs.example.com/excel-updated"
}

Success Response (200 OK):

{
  "message": "Event updated successfully",
  "event": {
    "_id": "507f1f77bcf86cd799439011",
    "name": "Tech Fest 2025",
    "venue": "New Auditorium",
    "date_time": "2025-12-21T10:00:00.000Z",
    "fee": 600
  }
}

Get Event Summary

Get registration and revenue summary for a specific event.

Endpoint: GET /events/summary/:eventName

Parameters:

  • eventName (string, required): URL-encoded event name

Success Response (200 OK):

{
  "totalRegistrations": 150,
  "totalRevenue": 75000
}

πŸ“Š Event Analytics Endpoints

Get Events Count

Retrieve total and verified registration counts.

Endpoint: GET /events-count

Success Response (200 OK):

{
  "totalRegistrations": 500,
  "verifiedRegistrations": 450
}

Get Events Revenue

Calculate revenue for all events.

Endpoint: GET /events-revenue

Success Response (200 OK):

[
  {
    "name": "Tech Fest 2025",
    "revenue": 75000
  },
  {
    "name": "Cultural Night",
    "revenue": 45000
  }
]

Get Event Revenue by Name

Get total revenue for a specific event.

Endpoint: GET /events-revenueper/:eventName

Parameters:

  • eventName (string, required): URL-encoded event name

Success Response (200 OK):

{
  "eventName": "Tech Fest 2025",
  "totalRevenue": 75000
}

Get Registration Trend

Get registration counts grouped by event.

Endpoint: GET /registration-trend

Success Response (200 OK):

[
  {
    "event": "Tech Fest 2025",
    "count": 150
  },
  {
    "event": "Cultural Night",
    "count": 90
  }
]

Get Top Events

Retrieve top 5 events by registration count.

Endpoint: GET /top-events

Success Response (200 OK):

[
  {
    "event": "Tech Fest 2025",
    "count": 150
  },
  {
    "event": "Cultural Night",
    "count": 90
  }
]

Get Ongoing Events

Retrieve all currently ongoing events.

Endpoint: GET /ongoing-events

Success Response (200 OK):

[
  {
    "name": "Tech Fest 2025",
    "venue": "Main Auditorium"
  }
]

🎫 Event Registration Endpoints

Get All Event Registrations

Retrieve all event registrations.

Endpoint: GET /event-registrations

Success Response (200 OK):

[
  {
    "_id": "507f1f77bcf86cd799439011",
    "ticket_number": "TKT001",
    "timestamp": "2025-12-15T10:30:00.000Z",
    "ticket_details": {
      "event": "Tech Fest 2025",
      "amount": "500"
    },
    "verified": true
  }
]

Delete Event Registration

Remove a specific registration.

Endpoint: POST /delete-event-registrations/:id

Parameters:

  • id (string, required): MongoDB ObjectId of the registration

Success Response (200 OK):

{
  "message": "Registration deleted successfully",
  "deletedId": "507f1f77bcf86cd799439011"
}

Error Response (400 Bad Request):

{
  "error": "Invalid registration ID format"
}

Request Ticket Generation

Forward ticket generation request to ticket service.

Endpoint: POST /request_ticket

Request Body:

{
  "name": "John Doe",
  "email": "john@example.com",
  "event": "Tech Fest 2025",
  "amount": 500
}

Success Response: Forwards response from ticket generation service


Verify Ticket

Mark participant attendance for an event.

Endpoint: POST /verify-ticket

Request Body:

{
  "ticketID": "TKT001"
}

Success Response (200 OK):

{
  "message": "Participant attendance marked successfully"
}

Error Response (404 Not Found):

{
  "error": "Participant not found"
}

πŸ‘₯ User Management Endpoints

Get Coordinators

Retrieve all users with coordinator role.

Endpoint: GET /coordinators

Success Response (200 OK):

{
  "coordinators": [
    {
      "name": "John Doe",
      "username": "johndoe"
    },
    {
      "name": "Jane Smith",
      "username": "janesmith"
    }
  ]
}

Get Distinct Events

Retrieve list of all unique event names.

Endpoint: GET /distinctEvents

Success Response (200 OK):

{
  "events": [
    "Tech Fest 2025",
    "Cultural Night",
    "Sports Day"
  ]
}

Add User

Create a new user account.

Endpoint: POST /addUser

Authentication: Required (Admin/Super role)

Request Body (Admin/Super):

{
  "name": "John Doe",
  "username": "johndoe",
  "gender": "male",
  "role": "admin",
  "mobile": "9876543210",
  "dept": "CSE"
}

Request Body (Coordinator):

{
  "name": "Jane Smith",
  "username": "janesmith",
  "gender": "female",
  "role": "coor",
  "mobile": "9876543211",
  "event_relation": "Tech Fest 2025"
}

Success Response (201 Created):

{
  "message": "User added successfully",
  "user": {
    "_id": "507f1f77bcf86cd799439011",
    "name": "John Doe",
    "username": "johndoe",
    "mobile": 9876543210,
    "role": "admin",
    "dept": "CSE",
    "status": -1,
    "gender": "male"
  }
}

Error Response (400 Bad Request):

{
  "error": "Name, username, gender, role, and mobile are required."
}

Error Response (400 Bad Request - Duplicate):

{
  "error": "User already exists"
}

Get User Details

Retrieve details for all admins and coordinators.

Endpoint: GET /overview/details

Success Response (200 OK):

{
  "users": [
    {
      "_id": "507f1f77bcf86cd799439011",
      "name": "John Doe",
      "role": "admin",
      "event_relation": "none",
      "mobile": "9876543210"
    },
    {
      "_id": "507f1f77bcf86cd799439012",
      "name": "Jane Smith",
      "role": "coor",
      "event_relation": "Tech Fest 2025",
      "mobile": "9876543211"
    }
  ]
}

Get Departments by Names

Retrieve department information for multiple users.

Endpoint: POST /users/depts-by-name

Request Body:

{
  "names": ["John Doe", "Jane Smith", "Bob Wilson"]
}

Success Response (200 OK):

{
  "John Doe": "CSE",
  "Jane Smith": "ECE",
  "Bob Wilson": "ME"
}

Reset User Status

Reset user status and password to default.

Endpoint: POST /overview/reset-status/:mobile

Parameters:

  • mobile (string, required): User's mobile number

Success Response (200 OK):

{
  "message": "Status reset and password updated for 9876543210"
}

Error Response (404 Not Found):

{
  "error": "User not found"
}

πŸ–₯️ System Monitoring Endpoints

Get Server Status

Retrieve comprehensive server health metrics.

Endpoint: GET /status

Success Response (200 OK):

{
  "status": "online",
  "uptime": "2d 5h 30m",
  "cpu": {
    "usage": 45.2,
    "cores": 8
  },
  "memory": {
    "total": 16384,
    "used": 8192,
    "free": 8192,
    "usagePercent": 50
  },
  "process": {
    "cpu": 12.5,
    "memory": 256
  }
}

Update Server Status

Change server operational mode.

Endpoint: POST /update-server-status

Authentication: Required (Admin/Super role)

Request Body:

{
  "status": "restricted"
}

Allowed Values:

  • online - Full access to all pages
  • restricted - Limited access to specific pages only
  • offline - API only, all pages blocked

Success Response (200 OK):

Status code 200 with no body

πŸ”Œ WebSocket Events

The application uses Socket.io for real-time communication.

Connection

Client connects to WebSocket server.

Event: connection

Server acknowledges:

socket.emit('connected', { message: 'Connected to WebSocket server' });

Room Updates

Subscribe to specific room for updates.

Event: join-room

Emit:

socket.emit('join-room', { room: 'dashboard' });

Available Rooms:

  • dashboard - Main dashboard updates
  • samridhi - Samridhi event updates
  • server - Server status updates
  • eventso - Events overview updates
  • eventsa - Events admin updates
  • userso - Users overview updates
  • usersa - Users admin updates
  • vevents - Verified events updates
  • myevent - Individual event updates

Receive Updates

Listen for real-time updates in subscribed room.

Event: update

Server emits:

socket.on('update', (data) => {
  // Handle update data
  console.log('Received update:', data);
});

πŸ“ Error Responses

All error responses follow a consistent format:

{
  "error": "Human-readable error message",
  "details": "Technical details (optional)"
}

Common HTTP Status Codes

  • 200 OK - Request successful
  • 201 Created - Resource created successfully
  • 400 Bad Request - Invalid request parameters
  • 401 Unauthorized - Authentication required or failed
  • 403 Forbidden - Insufficient permissions
  • 404 Not Found - Resource not found
  • 500 Internal Server Error - Server error

πŸ”‘ Authentication & Authorization

Session-Based Authentication

The API uses Express sessions with HTTP-only cookies. After successful login, a session is created and maintained through cookies.

Role-Based Access Control (RBAC)

Roles:

  • super - Full system access, can manage all resources
  • admin - Administrative access, can manage events and users
  • coor / coordinator - Limited access to assigned events only

Protected Endpoints: All endpoints except /login-auth and /check-auth require authentication.

Required Session Variables

  • objectID - User's MongoDB ObjectId
  • username - User's username
  • user_role - User's role (super/admin/coor)
  • name - User's full name
  • department - User's department
  • event - Assigned event (for coordinators)
  • gender - User's gender

πŸ” Environment Variables

Backend (.env)

Variable Description Required Default
PORT Server port No 5000
NODE_ENV Environment (development/production) No development
MONGO_URI MongoDB connection string Yes -
COOKIE_NAME Session cookie name No default
SESSION_SECRET Session encryption secret Yes (auto-generated) -
ALLOWED_ORIGINS CORS allowed origins No -

Frontend (.env)

Variable Description Required Default
REACT_APP_API_URL Backend API URL (dev) Yes http://localhost:5000
REACT_APP_PROD_API_URL Backend API URL (prod) Yes -
REACT_APP_SOCKET_URL WebSocket server URL Yes http://localhost:5000

πŸ”’ Security Features

  1. HTTPS Enforcement: Automatic redirect to HTTPS in production
  2. Session Management: Secure session handling with HTTP-only cookies
  3. Password Hashing: bcryptjs for password encryption
  4. CORS Protection: Configurable CORS policy
  5. Origin Validation: Custom origin header validation
  6. Role-Based Access Control: Different permission levels
  7. Protected Routes: Authentication-required routes in frontend
  8. Server Mode Control: Restrict access during maintenance

πŸ’» Development

Available Scripts

Root Level

  • npm start - Run both frontend and backend
  • npm run server - Run backend only
  • npm run client - Run frontend only
  • npm run update - Install all dependencies
  • npm run test - Run production build and test

Backend

  • npm start - Start production server
  • npm run demo - Start development server with nodemon

Frontend

  • npm run dev - Start Next.js development server
  • npm run build - Build for production
  • npm start - Run Next.js development server
  • npm run start:prod - Run production server

Code Style

This project uses ESLint for code quality. Run linting with:

npm run lint

Adding New Features

  1. Create a new route in backend/routes/
  2. Add model if needed in backend/models/
  3. Create page component in frontend/src/pages/
  4. Update routing in frontend/src/App.js
  5. Add to sidebar if needed in frontend/src/components/sidebar.js

🀝 Contributing

Contributions are welcome! Please follow these steps:

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

Contribution Guidelines

  • Follow the existing code style
  • Write clear commit messages
  • Add tests for new features
  • Update documentation as needed
  • Ensure all tests pass before submitting PR

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘₯ Authors

πŸ™ Acknowledgments

  • Material-UI for the component library
  • MongoDB team for the excellent database
  • Socket.io for real-time functionality
  • All contributors who have helped shape this project

πŸ“ž Support

For support, email: support@savishkaara.in

πŸ”— Links


Made with ❀️ by the Savishkaara Team

About

Full Scale control system for managing events, finance and more

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5