Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dhairyagothi committed Oct 9, 2024
2 parents b1f0a65 + ca6b4b2 commit aa913c2
Show file tree
Hide file tree
Showing 32 changed files with 1,175 additions and 419 deletions.
99 changes: 61 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ Welcome to repository of Station Guide

- To check UI Prototype Figma design :- [StationGuideFigma.md](https://github.com/dhairyagothi/StationGuide/blob/f2d4795cf3d3c57ffafb6ce007f47173d7010b1e/StationGuideFigma.md)

<!--Line-->
<img src="https://user-images.githubusercontent.com/74038190/212284100-561aa473-3905-4a80-b561-0d28506553ee.gif" width="900">

<!-- Added the GSSoc Accepted image -->
### This project is now OFFICIALLY accepted for

<div align="center">
<img src="https://github.com/apu52/METAVERSE/assets/114172928/e79eb6de-81b1-4ffb-b6ed-f018bb977e88" alt="GSSoC 2024 Extd" width="80%">
</div>
<br>

<!--Line-->
<img src="https://user-images.githubusercontent.com/74038190/212284100-561aa473-3905-4a80-b561-0d28506553ee.gif" width="900">

## Table of Content

- **[Using Station Guide](#using-station-guide)**
Expand All @@ -27,6 +41,9 @@ Welcome to repository of Station Guide
- **[Contributors](#contributors)**
- **[Contact Information](#contact-information)**

<!--Line-->
<img src="https://user-images.githubusercontent.com/74038190/212284100-561aa473-3905-4a80-b561-0d28506553ee.gif" width="900">

## Using Station Guide

This project utilizes React for the frontend and Express for the backend, providing a robust foundation for your web application development.
Expand All @@ -38,6 +55,11 @@ To get started, you'll need the following:
- Node.js (version 14 or later): https://nodejs.org/en/
- npm (Node Package Manager) comes bundled with Node.js

<br>

<!--Line-->
<img src="https://user-images.githubusercontent.com/74038190/212284100-561aa473-3905-4a80-b561-0d28506553ee.gif" width="900">

## Getting Started

### 1. Clone the Repository
Expand Down Expand Up @@ -91,6 +113,9 @@ Start the backend development server (typically using nodemon server.js or a sim
npm run start
```

<!--Line-->
<img src="https://user-images.githubusercontent.com/74038190/212284100-561aa473-3905-4a80-b561-0d28506553ee.gif" width="900">

## Project Structure

```
Expand All @@ -112,6 +137,9 @@ StationGuide/
└── ... # Other project configuration files (e.g., .gitignore)
```

<!--Line-->
<img src="https://user-images.githubusercontent.com/74038190/212284100-561aa473-3905-4a80-b561-0d28506553ee.gif" width="900">

## How to Contribute

Contributions are always welcome!
Expand Down Expand Up @@ -169,6 +197,9 @@ To ensure a smooth collaboration process, Follow these steps:
Please refer to the detailed [contribution guidelines](CONTRIBUTING.md) for more information.
<!--Line-->
<img src="https://user-images.githubusercontent.com/74038190/212284100-561aa473-3905-4a80-b561-0d28506553ee.gif" width="900">
## Code of Conduct
To foster a positive and inclusive community, please adhere to the following guidelines:
Expand All @@ -179,6 +210,9 @@ To foster a positive and inclusive community, please adhere to the following gui
Please read the [code of Conduct](CODE_OF_CONDUCT.md) for more clear understanding.
<!--Line-->
<img src="https://user-images.githubusercontent.com/74038190/212284100-561aa473-3905-4a80-b561-0d28506553ee.gif" width="900">
## How to Fork
Forking allows you to create a personal copy of the repository, where you can experiment and make changes without affecting the original project. Here’s how to do it:
Expand All @@ -201,44 +235,33 @@ Forking allows you to create a personal copy of the repository, where you can ex
```bash
git clone https://github.com/YOUR_USERNAME/Awesome-Github-Profiles.git
```
<br>
<!--Line-->
<img src="https://user-images.githubusercontent.com/74038190/212284100-561aa473-3905-4a80-b561-0d28506553ee.gif" width="900">
## Our Valuable Contributors ❤️✨
[![Contributors](https://contrib.rocks/image?repo=dhairyagothi/StationGuide)](https://github.com/dhairyagothi/StationGuide/graphs/contributors)
<!--Line-->
<img src="https://user-images.githubusercontent.com/74038190/212284100-561aa473-3905-4a80-b561-0d28506553ee.gif" width="900">
## Contributors
Thanks goes to these wonderful people ( [emoji key](https://allcontributors.org/docs/en/emoji-key) ):
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/dhairyagothi"><img src="https://avatars.githubusercontent.com/dhairyagothi?s=30" width="30px;" alt="Dhairya Gothi"/><br /><sub><b>Dhairya Gothi</b></sub></a><br /><a href="https://github.com//Dhairya Gothi/StationGuide/commits?author=dhairyagothi" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/tarunkumar2005"><img src="https://avatars.githubusercontent.com/tarunkumar2005?s=30" width="30px;" alt="Tarun Kumar"/><br /><sub><b>Tarun Kumar</b></sub></a><br /><a href="https://github.com//Dhairya Gothi/StationGuide/commits?author=tarunkumar2005" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ShivaniNikam1"><img src="https://avatars.githubusercontent.com/ShivaniNikam1?s=30" width="30px;" alt="Shivani Nikam"/><br /><sub><b>Shivani Nikam</b></sub></a><br /><a href="https://github.com//Dhairya Gothi/StationGuide/commits?author=ShivaniNikam1" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/1-SubhamSingh"><img src="https://avatars.githubusercontent.com/1-SubhamSingh?s=30" width="30px;" alt="Subham Singh"/><br /><sub><b>Subham Singh</b></sub></a><br /><a href="https://github.com//Dhairya Gothi/StationGuide/commits?author=1-SubhamSingh" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Premkolte"><img src="https://avatars.githubusercontent.com/Premkolte?s=30" width="30px;" alt="Prem Kolte"/><br /><sub><b>Prem Kolte</b></sub></a><br /><a href="https://github.com//Dhairya Gothi/StationGuide/commits?author=Premkolte" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/MihirSaiDudekula"><img src="https://avatars.githubusercontent.com/MihirSaiDudekula?s=30" width="30px;" alt="Mihir Sai Dudekula"/><br /><sub><b>Mihir Sai Dudekula</b></sub></a><br /><a href="https://github.com//Dhairya Gothi/StationGuide/commits?author=MihirSaiDudekula" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/RiddhiM170904"><img src="https://avatars.githubusercontent.com/RiddhiM170904?s=30" width="30px;" alt="Riddhi M"/><br /><sub><b>Riddhi M</b></sub></a><br /><a href="https://github.com//Dhairya Gothi/StationGuide/commits?author=RiddhiM170904" title="Code">💻</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Mehtarishita"><img src="https://avatars.githubusercontent.com/Mehtarishita?s=30" width="30px;" alt="Rishita Mehta"/><br /><sub><b>Rishita Mehta</b></sub></a><br /><a href="https://github.com//Dhairya Gothi/StationGuide/commits?author=Mehtarishita" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/shreyad2806"><img src="https://avatars.githubusercontent.com/shreyad2806?s=30" width="30px;" alt="Shreya D"/><br /><sub><b>Shreya D</b></sub></a><br /><a href="https://github.com//Dhairya Gothi/StationGuide/commits?author=shreyad2806" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/MrityunjaySingh09"><img src="https://avatars.githubusercontent.com/MrityunjaySingh09?s=30" width="30px;" alt="Mrityunjay Singh"/><br /><sub><b>Mrityunjay Singh</b></sub></a><br /><a href="https://github.com//Dhairya Gothi/StationGuide/commits?author=MrityunjaySingh09" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/itsbhh"><img src="https://avatars.githubusercontent.com/itsbhh?s=30" width="30px;" alt="itsbhh"/><br /><sub><b>itsbhh</b></sub></a><br /><a href="https://github.com//Dhairya Gothi/StationGuide/commits?author=itsbhh" title="Code">💻</a></td>
</tr>
</tbody>
</table>
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
## Contact Information
If you have questions, suggestions, or feedback, please reach out via email at dhairyag31@gmail.com. You can also join our discussion forum [here](https://github.com/dhairyagothi/StationGuide/discussions).
<!-- Added the Team section -->
## 👥 Team
| ![Dhairya Gothi](https://avatars.githubusercontent.com/u/142989448?v=4&s=80)|
|:--:|
| **Dhairya Gothi** <br> <sub>Project Admin</sub> |
| [![LinkedIn](https://img.icons8.com/fluency/32/000000/linkedin.png)](https://www.linkedin.com/in/dhairya-gothi-65945b288/) |
If you have questions, suggestions, or feedback, please reach out via email at dhairyag31@gmail.com. You can also join our [discussion forum](https://github.com/dhairyagothi/StationGuide/discussions).
We value open communication and are happy to help!
<!--Line-->
<img src="https://user-images.githubusercontent.com/74038190/212284100-561aa473-3905-4a80-b561-0d28506553ee.gif" width="900">
<!-- Added a Support section for the project README -->
## ⭐️ Support the Project
If you find this project helpful, please consider giving it a ⭐ on GitHub! Your support helps to grow the project and reach more contributors.
1 change: 1 addition & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
2 changes: 1 addition & 1 deletion backend/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dotenv.config();

const config = {
port: process.env.PORT || 3000,
mongodbUri: process.env.MONGODB_URI,
mongodbUri: process.env.MONGODB_URI || "mongodb://localhost:27017",
jwtSecret: process.env.JWT_SECRET,
nodeEnv: process.env.NODE_ENV,
};
Expand Down
31 changes: 31 additions & 0 deletions backend/controllers/WheelchairController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import WheelchairBooking from "../models/WheelChairBooking.js";
import { io } from "../index.js";

// Controller to handle booking creation
export const createWheelchairBooking = async (req, res) => {
const { station, bookingDate, bookingTime, wheelchairType } = req.body;

try {
const newBooking = new WheelchairBooking({
station,
bookingDate: new Date(bookingDate),
bookingTime,
wheelchairType: wheelchairType || "manual",
});

const savedBooking = await newBooking.save();

// Emit real-time booking confirmation to the client
io.emit("wheelchairBookingConfirmation", {
message: `Your booking at ${station} for ${bookingDate} has been confirmed.`,
booking: savedBooking,
});

// Send back HTTP response as well
res
.status(201)
.json({ message: "Booking created successfully", booking: savedBooking });
} catch (error) {
res.status(500).json({ message: "Server error." });
}
};
37 changes: 37 additions & 0 deletions backend/controllers/cloakroomController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { io } from "../index.js";
import CloakroomBooking from "../models/CloakroomBooking.js";

export const createCloakroomBooking = async (req, res) => {
const { station, items, storageStartDate, storageEndDate, charges } =
req.body;

if (!station || !items || !storageStartDate || !storageEndDate || !charges) {
return res
.status(400)
.json({ message: "Please provide all required fields" });
}

try {
const newBooking = new CloakroomBooking({
station,
items,
storageStartDate: new Date(storageStartDate),
storageEndDate: new Date(storageEndDate),
charges,
});

const savedBooking = await newBooking.save();

io.emit("cloakroomBookingConfirmation", {
message: `Your booking at ${station} for ${items} has been confirmed.`,
booking: savedBooking,
});

res.status(201).json(savedBooking);
} catch (error) {
console.error("Error creating cloakroom booking:", error);
res
.status(500)
.json({ message: "Server error. Could not create booking." });
}
};
54 changes: 54 additions & 0 deletions backend/controllers/coolieController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { io } from "../index.js";
import CoolieBooking from "../models/CoolieBooking.js";

export const createCoolieBooking = async (req, res) => {
try {
const {
station,
pickupLocation,
departureLocation,
bookingDate,
bookingTime,
price,
} = req.body;

if (
!station ||
!pickupLocation ||
!departureLocation ||
!bookingDate ||
!bookingTime ||
!price
) {
return res
.status(400)
.json({ message: "Please fill all the required fields." });
}

const coolieBooking = new CoolieBooking({
station,
pickupLocation,
departureLocation,
bookingDate,
bookingTime,
price,
});

const savedBooking = await coolieBooking.save();

io.emit("coolieBookingConfirmation", {
message: `Your booking at ${station} for coolie has been confirmed.`,
booking: savedBooking,
});

res.status(201).json({
message: "Coolie booking created successfully.",
data: savedBooking,
});
} catch (error) {
console.error("Error creating coolie booking:", error);
res
.status(500)
.json({ message: "An error occurred while creating the booking." });
}
};
12 changes: 12 additions & 0 deletions backend/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:18-alpine

WORKDIR /usr/src/app

COPY package*.json ./
RUN npm install

COPY . .

EXPOSE 3000

CMD ["npm", "start"]
73 changes: 51 additions & 22 deletions backend/index.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,63 @@
import express from 'express';
import cors from 'cors';
import connectDB from './config/dbConnection.js';
import cookieParser from 'cookie-parser';
import express from "express";
import cors from "cors";
import connectDB from "./config/dbConnection.js";
import cookieParser from "cookie-parser";
import { createServer } from "http";
import { Server } from "socket.io";

const app = express();
const server = createServer(app);

const port = process.env.PORT || 3000;

app.use(cors({
origin: 'http://localhost:5173',
methods: ['GET', 'POST'],
allowedHeaders: ['Content-Type'],
credentials: true
})); // Enable CORS
app.use(
cors({
origin: ["http://localhost:5173", "http://127.0.0.1:5500"],
methods: ["GET", "POST"],
allowedHeaders: ["Content-Type"],
credentials: true,
})
);

app.use(cookieParser()); // Parse cookies
app.use(express.json()); // Parse incoming request bodies in a middleware before your handlers
app.use(express.urlencoded({ extended: true })); // Parse URL-encoded bodies
app.use(cookieParser());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));

// Connect to MongoDB
connectDB();

// Routes
import authRoutes from './routes/authRoutes.js';
app.use('/auth', authRoutes);
import authRoutes from "./routes/authRoutes.js";

app.get('/', (req, res) => {
res.send('Working...');
app.use("/auth", authRoutes);
app.use("/api", authRoutes);

app.get("/", (req, res) => {
res.send("Working...");
});



const io = new Server(server, {
cors: {
origin: ["http://localhost:5173", "http://127.0.0.1:5500"],
methods: ["GET", "POST"],
credentials: true,
},
});

io.on("connection", (socket) => {
console.log("A user connected:", socket.id);

socket.on("disconnect", () => {
console.log("User disconnected:", socket.id);
});

socket.on("error", (err) => {
console.error("Socket error:", err);
});
});
// Start the server
app.listen(port, () => {

server.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});
});

export { io };
Loading

0 comments on commit aa913c2

Please sign in to comment.