├── backend ├── public │ └── temp │ │ └── .gitkeep ├── .gitignore ├── constants.js ├── Cache │ └── cache.js ├── middlewares │ └── multer.middleware.js ├── model │ ├── stationModel.js │ ├── routeModel.js │ ├── feedbackModel.js │ └── busModel.js ├── server.js ├── Database │ └── db.js ├── package.json ├── router │ └── busRoute.js ├── cloudStorage.js ├── app.js ├── controllers │ └── busController.js └── package-lock.json ├── frontend └── busApp │ ├── src │ ├── App.css │ ├── index.css │ ├── Constants │ │ ├── keys.js │ │ └── config.js │ ├── assets │ │ ├── bus.png │ │ ├── main.jpg │ │ ├── plus.png │ │ ├── reg.jpg │ │ ├── user.png │ │ ├── chatBot.png │ │ ├── minus.png │ │ └── Register.jpg │ ├── User │ │ ├── TrackVechicle │ │ │ ├── TrackVechicle.css │ │ │ ├── stop.mp4 │ │ │ └── TrackVechicle.jsx │ │ └── LookupVehicles │ │ │ ├── LookupVechicles.css │ │ │ └── LookupVehicles.jsx │ ├── Header.jsx │ ├── Driver │ │ ├── BusDashboard │ │ │ ├── BusDashboard.css │ │ │ └── BusDashboard.jsx │ │ ├── SendLocation │ │ │ ├── SendLocation.css │ │ │ └── SendLocation.jsx │ │ ├── BusStatus │ │ │ ├── BusStatusStyles.css │ │ │ └── BusStatus.jsx │ │ ├── LoginDriver │ │ │ └── LoginDriver.jsx │ │ └── RegisterDriver │ │ │ └── RegisterDriver.jsx │ ├── Shimmer │ │ └── Shimmer.jsx │ ├── constant │ │ └── constants.js │ ├── Context │ │ ├── PageContext.jsx │ │ ├── SocketContext.jsx │ │ ├── RegisterDriver.jsx │ │ └── Assets.jsx │ ├── App.jsx │ ├── main.jsx │ ├── Feedback │ │ └── Feedback.jsx │ └── TypeOfUser.jsx │ ├── postcss.config.js │ ├── vite.config.js │ ├── .gitignore │ ├── README.md │ ├── tailwind.config.js │ ├── .eslintrc.cjs │ ├── package.json │ ├── index.html │ ├── public │ └── vite.svg │ └── vite.config.js.timestamp-1694922811652-4aa50605c4999.mjs ├── .vscode ├── extensions.json └── settings.json ├── .idea ├── .gitignore ├── vcs.xml ├── inspectionProfiles │ └── Project_Default.xml ├── modules.xml └── Smart-Bharat-Hackathon.iml └── README.md /backend/public/temp/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /frontend/busApp/src/App.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /backend/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .env -------------------------------------------------------------------------------- /backend/constants.js: -------------------------------------------------------------------------------- 1 | export const DB_NAME="tracker" -------------------------------------------------------------------------------- /frontend/busApp/src/index.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; -------------------------------------------------------------------------------- /frontend/busApp/src/Constants/keys.js: -------------------------------------------------------------------------------- 1 | 2 | const MAPS_KEY = 'ENTER OWN KEY HERE'; 3 | 4 | export {MAPS_KEY}; -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "burkeholland.simple-react-snippets" 4 | ] 5 | } -------------------------------------------------------------------------------- /backend/Cache/cache.js: -------------------------------------------------------------------------------- 1 | const cache = new Map(); 2 | 3 | setInterval(() => cache.clear(), 1000*60) 4 | 5 | export {cache} -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | -------------------------------------------------------------------------------- /frontend/busApp/postcss.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /frontend/busApp/src/assets/bus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SujalDhiman/Real-Time-Bus-Tracking-System/HEAD/frontend/busApp/src/assets/bus.png -------------------------------------------------------------------------------- /frontend/busApp/src/assets/main.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SujalDhiman/Real-Time-Bus-Tracking-System/HEAD/frontend/busApp/src/assets/main.jpg -------------------------------------------------------------------------------- /frontend/busApp/src/assets/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SujalDhiman/Real-Time-Bus-Tracking-System/HEAD/frontend/busApp/src/assets/plus.png -------------------------------------------------------------------------------- /frontend/busApp/src/assets/reg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SujalDhiman/Real-Time-Bus-Tracking-System/HEAD/frontend/busApp/src/assets/reg.jpg -------------------------------------------------------------------------------- /frontend/busApp/src/assets/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SujalDhiman/Real-Time-Bus-Tracking-System/HEAD/frontend/busApp/src/assets/user.png -------------------------------------------------------------------------------- /frontend/busApp/src/User/TrackVechicle/TrackVechicle.css: -------------------------------------------------------------------------------- 1 | .container 2 | { 3 | width: 90vw; 4 | height:40vh; 5 | border-radius: 20px; 6 | } -------------------------------------------------------------------------------- /frontend/busApp/src/assets/chatBot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SujalDhiman/Real-Time-Bus-Tracking-System/HEAD/frontend/busApp/src/assets/chatBot.png -------------------------------------------------------------------------------- /frontend/busApp/src/assets/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SujalDhiman/Real-Time-Bus-Tracking-System/HEAD/frontend/busApp/src/assets/minus.png -------------------------------------------------------------------------------- /frontend/busApp/src/Header.jsx: -------------------------------------------------------------------------------- 1 | export function Header() 2 | { 3 | return

BUS TRACKER

4 | } -------------------------------------------------------------------------------- /frontend/busApp/src/assets/Register.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SujalDhiman/Real-Time-Bus-Tracking-System/HEAD/frontend/busApp/src/assets/Register.jpg -------------------------------------------------------------------------------- /frontend/busApp/src/User/TrackVechicle/stop.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SujalDhiman/Real-Time-Bus-Tracking-System/HEAD/frontend/busApp/src/User/TrackVechicle/stop.mp4 -------------------------------------------------------------------------------- /frontend/busApp/src/Driver/BusDashboard/BusDashboard.css: -------------------------------------------------------------------------------- 1 | .map-container 2 | { 3 | margin-top: 30px; 4 | width: 95%; 5 | margin-right: 50px; 6 | height:50vh; 7 | } -------------------------------------------------------------------------------- /frontend/busApp/src/Driver/SendLocation/SendLocation.css: -------------------------------------------------------------------------------- 1 | .map-container 2 | { 3 | margin-top: 1%; 4 | left: 3%; 5 | width: 80%; 6 | height:65vh; 7 | 8 | } 9 | 10 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /frontend/busApp/vite.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import react from '@vitejs/plugin-react' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | base: "/bus-real", 7 | plugins: [react()], 8 | }) 9 | -------------------------------------------------------------------------------- /frontend/busApp/src/Shimmer/Shimmer.jsx: -------------------------------------------------------------------------------- 1 | function Shimmer() 2 | { 3 | return ( 4 |
5 |
6 | ) 7 | } 8 | 9 | 10 | export default Shimmer -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "appService.defaultWebAppToDeploy": "undefined/subscriptions/51734ee8-a967-44f1-b36c-30583fac7d8d/resourceGroups/appsvc_linux_centralus/providers/Microsoft.Web/sites/bus-server", 3 | "appService.deploySubpath": "backend" 4 | } -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /backend/middlewares/multer.middleware.js: -------------------------------------------------------------------------------- 1 | import multer from "multer"; 2 | 3 | const storage=multer.diskStorage({ 4 | destination:function(req,file,cb){ 5 | cb(null,"./public/temp") 6 | }, 7 | filename:function(req,file,cb){ 8 | cb(null,file.originalname) 9 | } 10 | }) 11 | 12 | export const upload=multer({storage:storage}) -------------------------------------------------------------------------------- /frontend/busApp/src/constant/constants.js: -------------------------------------------------------------------------------- 1 | export const socket_url="http://localhost:10000/"; 2 | //export const socket_url="http://localhost:10000/"; 3 | //https://bus-server.azurewebsites.net/ 4 | 5 | export const request_url="http://localhost:10000/api/v1/" 6 | //export const request_url="http://localhost:10000/api/v1/" 7 | //https://bus-server.azurewebsites.net/api/v1/ -------------------------------------------------------------------------------- /backend/model/stationModel.js: -------------------------------------------------------------------------------- 1 | import mongoose from "mongoose" 2 | 3 | const stationSchema=new mongoose.Schema({ 4 | stationName:{ 5 | type:String, 6 | unique:[true,"Station Name Already Registered Try Other Number"] 7 | }, 8 | position:{ 9 | type:[Number], 10 | }, 11 | },) 12 | 13 | export const STATION=mongoose.model("Station",stationSchema) -------------------------------------------------------------------------------- /frontend/busApp/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | .env 15 | 16 | # Editor directories and files 17 | .vscode/* 18 | !.vscode/extensions.json 19 | .idea 20 | .DS_Store 21 | *.suo 22 | *.ntvs* 23 | *.njsproj 24 | *.sln 25 | *.sw? 26 | -------------------------------------------------------------------------------- /frontend/busApp/src/Driver/BusStatus/BusStatusStyles.css: -------------------------------------------------------------------------------- 1 | .toggle-bg:after { 2 | content: ''; 3 | @apply absolute top-0.5 left-0.5 bg-white border border-gray-300 rounded-full h-5 w-5 transition shadow-sm; 4 | } 5 | input:checked + .toggle-bg:after { 6 | transform: translateX(180%); 7 | @apply border-white; 8 | } 9 | input:checked + .toggle-bg { 10 | @apply bg-[#75C796] border-[#75C796]; 11 | } -------------------------------------------------------------------------------- /backend/server.js: -------------------------------------------------------------------------------- 1 | import dotenv from "dotenv" 2 | import httpServer from "./app.js" 3 | import connectToDB from "./Database/db.js" 4 | dotenv.config({ 5 | path:"./.env" 6 | }) 7 | 8 | connectToDB().then(()=>{ 9 | httpServer.listen(process.env.PORT,()=>{ 10 | console.log("Server running successfully") 11 | }) 12 | }).catch((err)=>{ 13 | console.log("Error in running server") 14 | }) 15 | 16 | -------------------------------------------------------------------------------- /frontend/busApp/src/Context/PageContext.jsx: -------------------------------------------------------------------------------- 1 | import { createContext,useState } from "react"; 2 | 3 | export const PageContext=createContext() 4 | 5 | 6 | const PageContextProvider=({children})=>{ 7 | 8 | const [page,setPage]=useState("Register") 9 | return ( 10 | {children} 11 | ) 12 | } 13 | 14 | export default PageContextProvider; -------------------------------------------------------------------------------- /backend/model/routeModel.js: -------------------------------------------------------------------------------- 1 | import mongoose from "mongoose" 2 | 3 | const routeSchema=new mongoose.Schema({ 4 | routeName:{ 5 | type:String, 6 | unique:[true,"Route Name Already Registered Try Other Number"] 7 | }, 8 | stations: [{ 9 | ref: "Station", 10 | type:mongoose.Schema.Types.ObjectId 11 | }], 12 | },) 13 | 14 | export const ROUTE=mongoose.model("Route",routeSchema) -------------------------------------------------------------------------------- /frontend/busApp/README.md: -------------------------------------------------------------------------------- 1 | # React + Vite 2 | 3 | This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. 4 | 5 | Currently, two official plugins are available: 6 | 7 | - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh 8 | - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh 9 | -------------------------------------------------------------------------------- /frontend/busApp/src/Constants/config.js: -------------------------------------------------------------------------------- 1 | 2 | const SERVER_URL = 'http://localhost:10000'; 3 | //const SERVER_URL = 'http://localhost:10000'; 4 | 5 | //Bypass ngrok browser warning will work with localhost as well 6 | const axiosConfig = { 7 | headers: { 8 | 'Content-Type': 'application/json', 9 | 'ngrok-skip-browser-warning': 'true' 10 | } 11 | } 12 | 13 | const adminAddress = "shreeshnautiyal3@gmail.com"; 14 | 15 | export {SERVER_URL, axiosConfig, adminAddress}; -------------------------------------------------------------------------------- /frontend/busApp/src/App.jsx: -------------------------------------------------------------------------------- 1 | import { Header } from "./Header.jsx"; 2 | import {Link, Outlet} from "react-router-dom"; 3 | import SocketProvider from "./Context/SocketContext"; 4 | import PageContextProvider from "./Context/PageContext.jsx"; 5 | 6 | 7 | function App() 8 | { 9 | return ( 10 | <> 11 | 12 | 13 | 14 | 15 | 16 | 17 | ) 18 | } 19 | 20 | export default App; -------------------------------------------------------------------------------- /.idea/Smart-Bharat-Hackathon.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /backend/Database/db.js: -------------------------------------------------------------------------------- 1 | import mongoose from "mongoose" 2 | import { DB_NAME } from "../constants.js"; 3 | 4 | const connectToDB=async function (){ 5 | try { 6 | console.log(`${process.env.MONGODB_URL}/${DB_NAME}`) 7 | const connectionInstance=await mongoose.connect(`${process.env.MONGODB_URL}/${DB_NAME}`) 8 | console.log("Database connected successfully") 9 | console.log("hello") 10 | } catch (error) { 11 | console.log(error.message) 12 | process.exit(1) 13 | } 14 | } 15 | 16 | export default connectToDB; -------------------------------------------------------------------------------- /frontend/busApp/src/User/LookupVehicles/LookupVechicles.css: -------------------------------------------------------------------------------- 1 | .progressBar::before { 2 | content: "" 3 | 4 | } 5 | 6 | .map-container2 7 | { 8 | left: 3%; 9 | margin-top: 30px; 10 | width: 95%; 11 | margin-right: 50px; 12 | height: 85vh; 13 | } 14 | 15 | ::-webkit-scrollbar { 16 | margin-left: 10px; 17 | width: 10px; 18 | } 19 | 20 | ::-webkit-scrollbar-track { 21 | border-radius: 8px; 22 | background-color: #e7e7e7; 23 | border: 1px solid #cacaca; 24 | } 25 | 26 | ::-webkit-scrollbar-thumb { 27 | border-radius: 8px; 28 | background-color: #d55959; 29 | } 30 | -------------------------------------------------------------------------------- /frontend/busApp/tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | export default { 3 | content: [ 4 | "./index.html", 5 | "./src/**/*.{js,ts,jsx,tsx}", 6 | ], 7 | theme: { 8 | extend: { 9 | fontFamily: { 10 | 'comic-neue': ['Comic Neue', 'sans'], 11 | 'lexend': ['Lexend', 'sans'] 12 | }, 13 | boxShadow: { 14 | 'custom':'6px 6px 6px rgba(0, 0, 0, 0.2), 6px 6px 6px rgba(0, 0, 0, 0.1)', 15 | 'custom2':'5px 5px 0 0 rgba(0, 0, 0, 0.2)', 16 | 'custom3':'4px 4px 0 0 rgba(0, 0, 0, 0.2)' 17 | }, 18 | }, 19 | }, 20 | plugins: [], 21 | } -------------------------------------------------------------------------------- /frontend/busApp/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { browser: true, es2020: true }, 4 | extends: [ 5 | 'eslint:recommended', 6 | 'plugin:react/recommended', 7 | 'plugin:react/jsx-runtime', 8 | 'plugin:react-hooks/recommended', 9 | ], 10 | ignorePatterns: ['dist', '.eslintrc.cjs'], 11 | parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }, 12 | settings: { react: { version: '18.2' } }, 13 | plugins: ['react-refresh'], 14 | rules: { 15 | 'react-refresh/only-export-components': [ 16 | 'warn', 17 | { allowConstantExport: true }, 18 | ], 19 | }, 20 | } 21 | -------------------------------------------------------------------------------- /frontend/busApp/src/Context/SocketContext.jsx: -------------------------------------------------------------------------------- 1 | import React, { createContext, useContext, useState } from 'react'; 2 | import { io } from 'socket.io-client'; 3 | import {SERVER_URL} from "../Constants/config.js"; 4 | 5 | export const SocketContext = createContext(); 6 | 7 | const socket = io(SERVER_URL, {extraHeaders: { 8 | 'ngrok-skip-browser-warning': 10, 9 | }}); 10 | 11 | const SocketProvider = ({ children }) => { 12 | const [busId,setBusId]=useState("") 13 | return ( 14 | {children} 15 | ); 16 | }; 17 | 18 | export default SocketProvider; -------------------------------------------------------------------------------- /backend/model/feedbackModel.js: -------------------------------------------------------------------------------- 1 | import mongoose from "mongoose" 2 | 3 | const feedbackSchema=new mongoose.Schema({ 4 | 5 | busNumber:{ 6 | type:String, 7 | required:[true,"Bus Number Is Required"], 8 | lowercase:true, 9 | }, 10 | ratings:{ 11 | type:Number, 12 | required:[true,"Rating Is Required"], 13 | min:[1,"Minimum Rating should be atleast 1"], 14 | max:[5,"Maximum Rating Should be at max 5"], 15 | default:0 16 | }, 17 | comments:{ 18 | type:String, 19 | required:[true,"Comments are required"] 20 | } 21 | }) 22 | 23 | 24 | export const FEEDBACK=mongoose.model("Feedback",feedbackSchema) -------------------------------------------------------------------------------- /backend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "backend", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "server.js", 6 | "type": "module", 7 | "scripts": { 8 | "start": "nodemon -r dotenv/config --experimental-json-modules server.js" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "bcrypt": "^5.1.1", 15 | "cloudinary": "^1.40.0", 16 | "cookie-parser": "^1.4.6", 17 | "cors": "^2.8.5", 18 | "dotenv": "^16.3.1", 19 | "express": "^4.18.2", 20 | "express-fileupload": "^1.4.0", 21 | "mongoose": "^7.5.0", 22 | "multer": "^1.4.5-lts.1", 23 | "nodemon": "^3.0.1", 24 | "socket.io": "^4.7.2" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /frontend/busApp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "busapp", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "predeploy": "npm run build", 8 | "deploy": "gh-pages -d dist", 9 | "dev": "vite", 10 | "build": "vite build --base=./", 11 | "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0", 12 | "preview": "vite preview" 13 | }, 14 | "dependencies": { 15 | "@react-google-maps/api": "^2.19.2", 16 | "axios": "^1.5.0", 17 | "react": "^18.2.0", 18 | "react-dom": "^18.2.0", 19 | "react-router-dom": "^6.15.0", 20 | "react-toastify": "^9.1.3", 21 | "socket.io-client": "^4.7.2" 22 | }, 23 | "devDependencies": { 24 | "@types/react": "^18.2.15", 25 | "@types/react-dom": "^18.2.7", 26 | "@vitejs/plugin-react": "^4.0.3", 27 | "autoprefixer": "^10.4.15", 28 | "eslint": "^8.45.0", 29 | "eslint-plugin-react": "^7.32.2", 30 | "eslint-plugin-react-hooks": "^4.6.0", 31 | "eslint-plugin-react-refresh": "^0.4.3", 32 | "gh-pages": "^6.0.0", 33 | "postcss": "^8.4.29", 34 | "tailwindcss": "^3.3.3", 35 | "vite": "^4.4.5" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /backend/router/busRoute.js: -------------------------------------------------------------------------------- 1 | import express from "express" 2 | 3 | import { upload } from "../middlewares/multer.middleware.js" 4 | import {register,login,activeBus,updateBusDetails,activeBusDetails, busRoutes,getFeedBack,allFeedBack,searchFeedBack} from "../controllers/busController.js" 5 | 6 | 7 | const router=express.Router() 8 | 9 | //route for register driver 10 | router.route("/register").post(upload.fields([{ 11 | name:"image1" 12 | }]),register) 13 | 14 | //route for login driver 15 | router.route("/login").post(login) 16 | 17 | //route for seeing list of active bus 18 | router.route("/activeBus").get(activeBus) 19 | 20 | //route for seeing detail of particular active bus 21 | router.route("/activeBus/:id").get(activeBusDetails) 22 | 23 | //route for updating details of the particular bus 24 | router.route("/bus/:id").post(updateBusDetails) 25 | 26 | //route for getting info about bus routes 27 | router.route("/busRoutes").get(busRoutes); 28 | 29 | //route for getting feedbacks 30 | router.route("/giveFeedback").post(getFeedBack) 31 | 32 | //route for getting all feedbacks 33 | router.route("/getFeedbacks").get(allFeedBack) 34 | 35 | //route for getting feedback of a particular bus 36 | router.route("/specificFeedback").post(searchFeedBack) 37 | 38 | 39 | export default router -------------------------------------------------------------------------------- /backend/cloudStorage.js: -------------------------------------------------------------------------------- 1 | import {v2 as cloudinary} from "cloudinary" 2 | import fs from "fs" 3 | 4 | cloudinary.config({ 5 | cloud_name: process.env.CLOUDINARY_CLOUD_NAME, 6 | api_key:process.env.CLOUDINARY_API_KEY, 7 | api_secret:process.env.CLOUDINARY_API_SECRET 8 | }); 9 | 10 | 11 | const uploadOnCloudinary=async (localFilePath)=>{ 12 | 13 | try { 14 | console.log("inside upload ",localFilePath ) 15 | if(!localFilePath) return null; 16 | console.log("final path is not null") 17 | const response=await cloudinary.uploader.upload(localFilePath, 18 | { 19 | folder:"graphathon", 20 | resource_type:"image" 21 | }) 22 | 23 | console.log("successfully uploaded") 24 | fs.unlinkSync(localFilePath) 25 | return response 26 | 27 | } catch (error) { 28 | return null 29 | } 30 | } 31 | 32 | const deleteFileFromCloudinary=async (fileURL)=>{ 33 | 34 | try { 35 | 36 | if(!fileURL) 37 | return null 38 | 39 | const response=await cloudinary.uploader.destroy(fileURL) 40 | 41 | fs.unlinkSync(localFilePath) 42 | return response.result 43 | 44 | } catch (error) { 45 | console.log("something went wrong while deleting file ",error.message) 46 | } 47 | 48 | } 49 | 50 | export {uploadOnCloudinary,deleteFileFromCloudinary} -------------------------------------------------------------------------------- /frontend/busApp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 18 | 19 | 20 | 21 | 22 | 23 | Real Time Tracking System 24 | 25 | 26 |
27 |
28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /frontend/busApp/public/vite.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /backend/app.js: -------------------------------------------------------------------------------- 1 | import express from "express" 2 | import cors from "cors" 3 | import cookieParser from "cookie-parser" 4 | import { Server } from "socket.io" 5 | import {cache} from "./Cache/cache.js" 6 | import {createServer} from "http" 7 | 8 | const app=express() 9 | 10 | app.use(cors({ 11 | origin:"*", 12 | })) 13 | 14 | app.use(cookieParser()); 15 | 16 | app.use( 17 | express.json({ 18 | limit: "16kb", 19 | }) 20 | ); 21 | app.use( 22 | express.urlencoded({ 23 | extended: true, 24 | }) 25 | ); 26 | app.use(express.static("public")); 27 | 28 | 29 | 30 | app.use((req, res, next) => { 31 | console.log(req.method, req.ip); 32 | next(); 33 | }) 34 | 35 | 36 | const httpServer = createServer(app); 37 | const io = new Server(httpServer, { 38 | cors:"*", 39 | }); 40 | 41 | io.on("connection", (socket) => { 42 | socket.on("busId",(payload)=>{ 43 | console.log(payload); 44 | 45 | cache.set(payload.id, payload); 46 | console.log(cache); 47 | console.log(`busLocation-${payload.id}`) 48 | io.emit(`busLocation-${payload.id}`,payload)}) 49 | 50 | socket.on("panicAlarm",(payload)=>{ 51 | socket.broadcast.emit("sendAlarm",payload) 52 | }) 53 | 54 | socket.on("count",(payload)=>{ 55 | io.emit("sendCountPassenger",{countPassenger:payload.countPassenger}) 56 | }) 57 | 58 | }); 59 | 60 | //setting up routes 61 | import busRouter from "./router/busRoute.js" 62 | app.use("/api/v1",busRouter) 63 | 64 | 65 | export default httpServer 66 | 67 | -------------------------------------------------------------------------------- /frontend/busApp/vite.config.js.timestamp-1694922811652-4aa50605c4999.mjs: -------------------------------------------------------------------------------- 1 | // vite.config.js 2 | import { defineConfig } from "file:///C:/Users/shree/WebstormProjects/Smart-Bharat-Hackathon/frontend/busApp/node_modules/vite/dist/node/index.js"; 3 | import react from "file:///C:/Users/shree/WebstormProjects/Smart-Bharat-Hackathon/frontend/busApp/node_modules/@vitejs/plugin-react/dist/index.mjs"; 4 | var vite_config_default = defineConfig({ 5 | base: "/bus-real", 6 | plugins: [react()] 7 | }); 8 | export { 9 | vite_config_default as default 10 | }; 11 | //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcuanMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCJDOlxcXFxVc2Vyc1xcXFxzaHJlZVxcXFxXZWJzdG9ybVByb2plY3RzXFxcXFNtYXJ0LUJoYXJhdC1IYWNrYXRob25cXFxcZnJvbnRlbmRcXFxcYnVzQXBwXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ZpbGVuYW1lID0gXCJDOlxcXFxVc2Vyc1xcXFxzaHJlZVxcXFxXZWJzdG9ybVByb2plY3RzXFxcXFNtYXJ0LUJoYXJhdC1IYWNrYXRob25cXFxcZnJvbnRlbmRcXFxcYnVzQXBwXFxcXHZpdGUuY29uZmlnLmpzXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ltcG9ydF9tZXRhX3VybCA9IFwiZmlsZTovLy9DOi9Vc2Vycy9zaHJlZS9XZWJzdG9ybVByb2plY3RzL1NtYXJ0LUJoYXJhdC1IYWNrYXRob24vZnJvbnRlbmQvYnVzQXBwL3ZpdGUuY29uZmlnLmpzXCI7aW1wb3J0IHsgZGVmaW5lQ29uZmlnIH0gZnJvbSAndml0ZSdcclxuaW1wb3J0IHJlYWN0IGZyb20gJ0B2aXRlanMvcGx1Z2luLXJlYWN0J1xyXG5cclxuLy8gaHR0cHM6Ly92aXRlanMuZGV2L2NvbmZpZy9cclxuZXhwb3J0IGRlZmF1bHQgZGVmaW5lQ29uZmlnKHtcclxuICBiYXNlOiBcIi9idXMtcmVhbFwiLFxyXG4gIHBsdWdpbnM6IFtyZWFjdCgpXSxcclxufSlcclxuIl0sCiAgIm1hcHBpbmdzIjogIjtBQUFrWixTQUFTLG9CQUFvQjtBQUMvYSxPQUFPLFdBQVc7QUFHbEIsSUFBTyxzQkFBUSxhQUFhO0FBQUEsRUFDMUIsTUFBTTtBQUFBLEVBQ04sU0FBUyxDQUFDLE1BQU0sQ0FBQztBQUNuQixDQUFDOyIsCiAgIm5hbWVzIjogW10KfQo= 12 | -------------------------------------------------------------------------------- /backend/model/busModel.js: -------------------------------------------------------------------------------- 1 | import mongoose from "mongoose" 2 | import bcrypt from "bcrypt" 3 | 4 | 5 | 6 | const busSchema=new mongoose.Schema({ 7 | busNumber:{ 8 | type:String, 9 | unique:[true,"Bus Number Already Registered Try Other Number"] 10 | }, 11 | busNumberPlate:{ 12 | type:String, 13 | unique:[true,"Bus Number Plate Already Registered"] 14 | }, 15 | driver:{ 16 | name:{ 17 | type:String, 18 | }, 19 | contactInfo:{ 20 | type:String, 21 | }, 22 | password:{ 23 | type:String, 24 | unique:[true,"Password Already Taken"], 25 | minlength:[6,"Password Should Contain Atleast 6 Characters"] 26 | } 27 | }, 28 | avgRating:{ 29 | type:Number, 30 | default:0 31 | }, 32 | route: { 33 | ref: "Route", 34 | type: mongoose.Schema.Types.ObjectId 35 | }, 36 | busStatus:{ 37 | type:String, 38 | enum:["active","notactive"], 39 | default:"notactive" 40 | }, 41 | photo:{ 42 | secure_url:String, 43 | photo_id:String 44 | } 45 | },{timestamps:true}) 46 | 47 | busSchema.methods.validatePassword=async function (gotPassword){ 48 | try 49 | { 50 | return await bcrypt.compare(gotPassword,this.driver.password) 51 | } 52 | catch(error) 53 | { 54 | console.log("error in validating password") 55 | } 56 | } 57 | 58 | 59 | busSchema.pre("save",async function (next){ 60 | if(!this.isModified("driver.password")) 61 | return next(); 62 | this.driver.password=await bcrypt.hash(this.driver.password,8); 63 | }) 64 | 65 | export const BUS=mongoose.model("Bus",busSchema) -------------------------------------------------------------------------------- /frontend/busApp/src/main.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom/client' 3 | import App from './App.jsx' 4 | import './index.css' 5 | import { createHashRouter, RouterProvider} from "react-router-dom" 6 | 7 | import { LookupVehicles } from './User/LookupVehicles/LookupVehicles.jsx' 8 | import { TrackVechicle } from './User/TrackVechicle/TrackVechicle.jsx' 9 | import SendLocation from './Driver/SendLocation/SendLocation.jsx' 10 | import TypeOfUser from "./TypeOfUser.jsx"; 11 | import LoginDriver from './Driver/LoginDriver/LoginDriver.jsx' 12 | import RegisterDriver from './Driver/RegisterDriver/RegisterDriver.jsx' 13 | import BusDashboard from './Driver/BusDashboard/BusDashboard.jsx' 14 | import BusStatus from './Driver/BusStatus/BusStatus.jsx' 15 | import Feedback from './Feedback/Feedback.jsx' 16 | const router=createHashRouter([ 17 | { 18 | path:"/", 19 | element:, 20 | children:[ 21 | { 22 | path: "/", 23 | element: 24 | }, 25 | { 26 | path:"/driver/registerDriver", 27 | element: 28 | }, 29 | { 30 | path:"/driver/login", 31 | element: 32 | }, 33 | { 34 | path:"/driver/dashboard", 35 | element: 36 | }, 37 | { 38 | path:"/driver/setStatus/:id", 39 | element: 40 | }, 41 | { 42 | path:"/driver/sendLocation/:id", 43 | element: 44 | }, 45 | { 46 | path:"/user/lookupVehicle", 47 | element: 48 | }, 49 | { 50 | path:"/user/trackVehicle/:id", 51 | element: 52 | }, 53 | { 54 | path:"/user/feedback/:id", 55 | element: 56 | } 57 | ] 58 | } 59 | ]) 60 | 61 | ReactDOM.createRoot(document.getElementById('root')).render( 62 | 63 | 64 | 65 | 66 | , 67 | ) 68 | -------------------------------------------------------------------------------- /frontend/busApp/src/Feedback/Feedback.jsx: -------------------------------------------------------------------------------- 1 | import {useState} from "react" 2 | import { toast,ToastContainer, Zoom } from "react-toastify"; 3 | import 'react-toastify/dist/ReactToastify.css'; 4 | import { request_url } from "../constant/constants"; 5 | import axios from "axios" 6 | import { toastPayload } from "../Context/Assets"; 7 | import { useParams } from "react-router-dom"; 8 | import {ActiveRatingSVG,InactiveRatingSVG} from "../Context/Assets" 9 | 10 | function Feedback() 11 | { 12 | const {id}=useParams() 13 | const [comments,setComments]=useState("") 14 | const [index,setIndex]=useState(0) 15 | async function submitFeedBack() 16 | { 17 | let payload={ 18 | busNumber:id, 19 | ratings:index, 20 | comments 21 | } 22 | console.log(payload) 23 | const response=await axios.post(request_url+"/giveFeedback",payload) 24 | toast.success("Fedback was submitted!", toastPayload); 25 | console.log(response) 26 | } 27 | 28 | return ( 29 |
30 |
31 |
32 |

Your Feedback

33 |
34 |

Rate your ride

35 |
36 | { 37 | Array(5).fill("").map((ele,idx)=> 38 | { 39 | if(idx+1 <= index) 40 | return

setIndex(idx+1)}>

41 | else 42 | return

setIndex(idx+1)}>

43 | }) 44 | } 45 |
46 |
47 |
48 |
49 |

Additional comments

50 |
51 |