Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions backend/models/events.js

This file was deleted.

5 changes: 0 additions & 5 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"license": "ISC",
"dependencies": {
"axios": "^1.7.9",
"backend": "file:",
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
"dotenv": "^16.4.7",
Expand Down
16 changes: 16 additions & 0 deletions backend/routes/event.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const express = require('express');
const router = express.Router();
const mongoose = require('mongoose');
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable mongoose.

Suggested change
const mongoose = require('mongoose');

Copilot uses AI. Check for mistakes.

const Event = require('../models/event_registration');

router.get("/events-count", async (req, res) => {
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The endpoint path is /events-count but in dashboard.js the frontend is calling /event-count (singular). This mismatch will cause the API request to fail with a 404 error.

Suggested change
router.get("/events-count", async (req, res) => {
router.get("/event-count", async (req, res) => {

Copilot uses AI. Check for mistakes.
try {
const count = await Event.countDocuments();
res.status(200).json({ count: count });
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The response field is named count but in dashboard.js the frontend expects totalUsers. This mismatch means eventCount will always be set to 0 (the fallback value), even when the API call succeeds.

Suggested change
res.status(200).json({ count: count });
res.status(200).json({ totalUsers: count });

Copilot uses AI. Check for mistakes.
} catch (error) {
res.status(500).json({ error: error.message });
}
});

module.exports = router;
77 changes: 45 additions & 32 deletions backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ require("dotenv").config(); // Load environment variables
const express = require("express"); // Import Express.js
const session = require("express-session"); // Import Express Session
const crypto = require("crypto"); // Import Crypto.js
const { Server } = require("socket.io"); // Socket.io for realtime updates
const { Server } = require("socket.io"); // Using the Server class from the socket.io module for realtime update
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in comment: "Using the Server class from the socket.io module for realtime update" should be "real-time updates" (hyphenated and plural).

Suggested change
const { Server } = require("socket.io"); // Using the Server class from the socket.io module for realtime update
const { Server } = require("socket.io"); // Using the Server class from the socket.io module for real-time updates

Copilot uses AI. Check for mistakes.
const cors = require("cors"); // Import CORS middleware
const https = require("https"); // Import HTTPS module
const http = require("http"); // Import HTTP module
Expand All @@ -16,26 +16,24 @@ const PORT = process.env.PORT || 5000;
// Generate a secure secret for session signing
const sessionSecret = crypto.randomBytes(64).toString("hex");

// Only run these production checks if NODE_ENV is "production"
// Force HTTPS redirect (Only if using Cloudflare Full mode)
if (process.env.NODE_ENV === "production") {
// Force HTTPS redirect
app.use((req, res, next) => {
if (req.headers["x-forwarded-proto"] !== "https") {
return res.redirect("https://" + req.headers.host + req.url);
}
next();
});

// Check for allowed origin header
app.use((req, res, next) => {
if (req.headers['X-Allowed-Origin'] !== 'testsavi.amritaiedc.site') {
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The header check uses req.headers['X-Allowed-Origin'] but HTTP headers are case-insensitive and typically normalized to lowercase by Express. This should be req.headers['x-allowed-origin'] (lowercase) to work correctly.

Suggested change
if (req.headers['X-Allowed-Origin'] !== 'testsavi.amritaiedc.site') {
if (req.headers['x-allowed-origin'] !== 'testsavi.amritaiedc.site') {

Copilot uses AI. Check for mistakes.
return res.status(403).json({ error: 'Forbidden' });
return res.status(403).json({ error: 'Forbidden' });
}
next();
});
}

// Session middleware
// Middleware for sessions
app.use(
session({
secret: sessionSecret,
Expand All @@ -44,79 +42,94 @@ app.use(
name: "pookie",
cookie: {
maxAge: 1000 * 60 * 60 * 6, // 6 hour expiration
secure: process.env.NODE_ENV === "production", // Only over HTTPS in production
secure: process.env.NODE_ENV === "production", // Ensure cookies are only sent over HTTPS in production
httpOnly: true,
},
})
);

// Configure CORS dynamically
// Import routes
const AuthenticationRoutes = require("./routes/auth"); // Import authentication routes
const RealTimeRoutes = require("./routes/realTime");
const VerificationRoutes = require("./routes/verify");
const EventRoutes = require("./routes/event");

// Define allowed origins
const allowedOrigins = [
"https://testsavi.amritaiedc.site",
"http://localhost:3000",
"https://savicontrol.amritaiedc.site",
];

// Configure CORS dynamically
app.use(
cors({
origin: function (origin, callback) {
// Allow requests with no origin (e.g., mobile apps, Postman)
if (!origin) return callback(null, true);

// Check if the origin is allowed
// Check if the origin is in the allowed list
if (allowedOrigins.indexOf(origin) === -1) {
const msg = `The CORS policy for this site does not allow access from: ${origin}`;
const msg = `The CORS policy for this site does not allow access from the specified origin: ${origin}`;
return callback(new Error(msg), false);
}

// Allow the request
return callback(null, true);
},
methods: ["GET", "POST"],
credentials: true,
credentials: true, // Enable credentials (cookies, authorization headers, etc.)
})
);

// Parse JSON bodies
// Middleware
app.use(express.json());

// Import and mount routes
const AuthenticationRoutes = require("./routes/auth");
const EventRoutes = require("./routes/eventManager");
const UserAdd = require("./routes/addusers");
const RealTimeRoutes = require("./routes/realTime");
const VerificationRoutes = require("./routes/verify");

app.use("/", AuthenticationRoutes);
app.use("/", EventRoutes);
app.use("/", UserAdd);
app.use("/", RealTimeRoutes);
app.use("/", VerificationRoutes);
app.use("/", EventRoutes);
Comment on lines +51 to +90
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The route imports have been reordered, but the critical issue is that EventRoutes now points to ./routes/event instead of the previous ./routes/eventManager. Additionally, UserAdd route import (from ./routes/addusers) has been completely removed without adding equivalent functionality elsewhere. This will break any endpoints that were defined in those files.

Copilot uses AI. Check for mistakes.

// Optional: Log public IP
// Fetch public IP
https.get("https://api.ipify.org", (res) => {
let data = "";
res.on("data", (chunk) => { data += chunk; });
res.on("end", () => { console.log("Your public IP address is: " + data); });
}).on("error", (e) => { console.log("Error: " + e.message); });
res.on("data", (chunk) => {
data += chunk;
});
res.on("end", () => {
console.log("Your public IP address is: " + data);
});
}).on("error", (e) => {
console.log("Error: " + e.message);
});

// Connect to MongoDB
// MongoDB connection
mongoConnect();

// Create HTTP server and configure Socket.io
// Create HTTP server using Express
const server = http.createServer(app);

// Configure Socket.io with dynamic CORS
const io = new Server(server, {
cors: {
origin: function (origin, callback) {
// Allow requests with no origin (e.g., mobile apps, Postman)
if (!origin) return callback(null, true);

// Check if the origin is in the allowed list
if (allowedOrigins.indexOf(origin) === -1) {
const msg = `The CORS policy for this site does not allow access from: ${origin}`;
const msg = `The CORS policy for this site does not allow access from the specified origin: ${origin}`;
return callback(new Error(msg), false);
}

// Allow the request
return callback(null, true);
},
methods: ["GET", "POST"],
credentials: true,
credentials: true, // Enable credentials
},
});

// Export the `io` object
module.exports.io = io;

// Initialize room updater
Expand All @@ -131,11 +144,11 @@ server.listen(PORT, () => {
\\___ \\ / _\` \\ \\ / / / __| '_ \\| |/ / _\` |/ _\` | '__/ _\` |_____| | / _ \\| '_ \\| __| '__/ _ \\| |____\\___ \\ / _ \\ '__\\ \\ / / _ \\ '__|
___) | (_| |\\ V /| \\__ \\ | | | < (_| | (_| | | | (_| |_____| |__| (_) | | | | |_| | | (_) | |_____|__) | __/ | \\ V / __/ |
|____/ \\__,_| \\_/ |_|___/_| |_|_|\\_\\__,_|\\__,_|_| \\__,_| \\____\\___/|_| |_|\\__|_| \\___/|_| |____/ \\___|_| \\_/ \\___|_|
`);
`);
console.log("\nWelcome to Savishkaara-Control-Server\n");
console.log(`Date: `, new Date().toLocaleDateString());
console.log(`Time: `, new Date().toLocaleTimeString());
console.log(`TimeStamp: `, new Date(), `\n`);
console.log(`HTTP server running on port ${PORT}`);
console.log(`Socket.io server initialized`);
});
});
5 changes: 0 additions & 5 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"chart.js": "^4.4.7",
"cra-template": "1.2.0",
"d3": "^7.9.0",
"frontend": "file:",
"js-cookie": "^3.0.5",
"react": "^18.2.0",
"react-chartjs-2": "^5.3.0",
Expand Down
28 changes: 12 additions & 16 deletions frontend/src/components/metricCard.js
Original file line number Diff line number Diff line change
@@ -1,60 +1,56 @@
import React from "react";
import { Card, CardContent, Typography } from "@mui/material";
import { ArrowForward } from "@mui/icons-material"; // Import Arrow Icon
import { ArrowForward } from "@mui/icons-material";
import CountUp from "react-countup";

const MetricCard = ({ title, value, darkMode, height, width, description, additionalInfo }) => {
const MetricCard = ({ title, value, darkMode, height, width, description, additionalInfo, bgColor }) => {
const isNumeric = !isNaN(Number(value));

return (
<Card
sx={{
backgroundColor: darkMode ? "#1b1c1e" : "#f7f7f7",
backgroundColor: bgColor || (darkMode ? "#1b1c1e" : "#f7f7f7"),
borderRadius: 2,
boxShadow: "0px 4px 8px rgba(0, 0, 0, 0.1)",
boxShadow: "0px 4px 8px rgba(32, 24, 24, 0.1)",
padding: "20px",
height: height,
width: width,
transition: "all 0.3s ease",
transition: "all 0.3s ease-in-out",
"&:hover": {
boxShadow: "0px 6px 12px rgba(0, 0, 0, 0.15)",
backgroundColor: "#2f3134",
boxShadow: `0px 0px 15px ${bgColor ? bgColor : "#00e676"}`,
transform: "scale(1.05)",
},
}}
>
<CardContent>
{/* Event Name */}
<Typography variant="h6" sx={{ fontSize: "20px", fontWeight: "600", color: darkMode ? "#787878" : "#8d8c8c" }}>
<Typography variant="h6" sx={{ fontSize: "20px", fontWeight: "600", color: "#fff" }}>
{title}
</Typography>

{/* Venue or Numeric Value */}
<Typography variant="h5" sx={{ fontSize: "16px", fontWeight: "600", color: darkMode ? "#a9a9a9" : "#000" }}>
<Typography variant="h5" sx={{ fontSize: "16px", fontWeight: "600", color: "#fff" }}>
{isNumeric ? <CountUp end={Number(value)} duration={2} separator="," /> : value}
</Typography>

{/* Coordinator */}
{description && (
<Typography variant="body2" sx={{ color: darkMode ? "#a9a9a9" : "#000", marginTop: "8px" }}>
<Typography variant="body2" sx={{ color: "#fff", marginTop: "8px" }}>
{description}
</Typography>
)}

{/* Additional Info (View Link Aligned to Right with Bright Blue Color and Arrow) */}
{additionalInfo && (
<div style={{ marginTop: "10px", display: "flex", justifyContent: "flex-end", alignItems: "center" }}>
<a
href={`/events/${title.toLowerCase().replace(/\s+/g, "-")}`}
style={{
textDecoration: "none",
color: "#007BFF", // Bright Blue Color
color: "#fff",
fontWeight: "bold",
display: "flex",
alignItems: "center",
}}
>
View
<ArrowForward sx={{ marginLeft: "5px", color: "#007BFF" }} /> {/* Bright Blue Arrow */}
<ArrowForward sx={{ marginLeft: "5px", color: "#fff" }} />
Comment on lines +26 to +53
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All text colors have been changed to white (#fff), which will make the text invisible or hard to read when the bgColor is light or when no bgColor is provided (defaulting to light gray #f7f7f7). This removes the original dynamic color logic that adapted to dark/light modes.

Copilot uses AI. Check for mistakes.
</a>
</div>
)}
Expand Down
Loading