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
54 changes: 54 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
pipeline {
agent any
environment {
SONARQUBE_SCANNER_HOME = tool 'SonarQubeScanner'

}

stages {
stage('Clone') {
steps {
git url: 'https://github.com/Lokendram10/Indore-Route-Pathfinder-cicd.git', branch: 'main'
}
}
stage('SonarQube Scan') {
steps {
withSonarQubeEnv('SonarQubeServer') {
sh ''' ${SONARQUBE_SCANNER_HOME}/bin/sonar-scanner \
-Dsonar.projectName=Indore-Route-Pathfinder-cicd \
-Dsonar.projectKey=Indore-Route-Pathfinder-cicd
'''
}

}
}
stage('OWASP Dependency Check') {
steps {
echo "OWASP Dependency Check"
dependencyCheck (
additionalArguments: '--scan ./'
, odcInstallation: 'owasp'
)
echo "OWASP Dependency Check"
dependencyCheckPublisher pattern: '**/dependency-check-report.xml'
}
}
stage('Trivy Scan') {
steps {
sh 'trivy fs --severity HIGH,CRITICAL -f json -o trivy-report.json . '
}
}
stage('Quality Gate') {
steps {
timeout(time: 1, unit: 'HOURS') {
waitForQualityGate abortPipeline: true
}
}
}
stage('Docker Build') {
steps {
sh 'docker compose up --build -d'
}
}
}
}
132 changes: 79 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,93 @@

<div align="center">

![React](https://img.shields.io/badge/React-20232A?style=for-the-badge&logo=react&logoColor=61DAFB)
![Node.js](https://img.shields.io/badge/Node.js-43853D?style=for-the-badge&logo=node.js&logoColor=white)
![MongoDB](https://img.shields.io/badge/MongoDB-4EA94B?style=for-the-badge&logo=mongodb&logoColor=white)
![React](https://img.shields.io/badge/React-20232A?style=for-the-badge\&logo=react\&logoColor=61DAFB)
![Node.js](https://img.shields.io/badge/Node.js-43853D?style=for-the-badge\&logo=node.js\&logoColor=white)
![MongoDB](https://img.shields.io/badge/MongoDB-4EA94B?style=for-the-badge\&logo=mongodb\&logoColor=white)
![Docker](https://img.shields.io/badge/Docker-2496ED?style=for-the-badge\&logo=docker\&logoColor=white)
![Jenkins](https://img.shields.io/badge/Jenkins-D24939?style=for-the-badge\&logo=jenkins\&logoColor=white)

**A simple web application to plan routes between stations in Indore using Dijkstra's Algorithm**
**A web application to plan routes between stations in Indore using Dijkstra's Algorithm**

[🚀 Live Demo](https://indore-route.vercel.app)

</div>

---

## ✨ What it does
> **Note**: This project was originally created by Harshit Singh. I forked the repository and made additional changes (Docker, Docker Compose, and Jenkins pipeline) in the **main** branch. The **master** branch contains the original code.

- 📍 **Add Stations**: Create new stations/locations
- 🔗 **Connect Stations**: Link stations with distance and cost
- 🧭 **Find Routes**: Calculate shortest path by distance OR cheapest path by cost
- 📊 **View All**: See all stations and connections in one place
---

## ✨ Features

* 📍 **Add Stations**: Create new stations/locations
* 🔗 **Connect Stations**: Link stations with distance and cost
* 🧭 **Find Routes**: Calculate shortest path by distance or cheapest path by cost
* 📊 **View All**: See all stations and connections at a glance
* 🐳 **Dockerized**: Run frontend and backend with Docker & Docker Compose
* 🤖 **CI/CD**: Automated deployment pipeline with Jenkins

---

## 🛠️ Tech Stack

- **Frontend**: React.js, Tailwind CSS
- **Backend**: Node.js, Express.js
- **Database**: MongoDB
- **Algorithm**: Dijkstra's Shortest Path
* **Frontend**: React.js, Tailwind CSS
* **Backend**: Node.js, Express.js
* **Database**: MongoDB
* **Algorithm**: Dijkstra's Shortest Path
* **Containerization**: Docker, Docker Compose
* **CI/CD**: Jenkins

---

## 🏃‍♂️ Quick Start

### 1. Clone & Install
### 1. Clone Repository

```bash
git clone https://github.com/harshitsingh4321/indore-route-planner.git
cd indore-route-planner
git clone https://github.com/Lokendram10/Indore-Route-Pathfinder-cicd
cd Indore-Route-Pathfinder-cicd
```

# Backend
cd backend && npm install
### 2. Install Docker & Docker Compose (Linux)

# Frontend
cd ../frontend && npm install
```
```bash
sudo apt-get update
sudo apt-get install docker.io -y
sudo apt-get install docker-compose -y

### 2. Setup Environment
Create `.env` in backend folder:
```env
MONGO_URI=your_mongodb_connection_string
PORT=5000
# Give permission to current user to run docker without sudo
sudo usermod -aG docker $USER && newgrp docker
```

### 3. Run Application
```bash
# Start backend (Terminal 1)
cd backend && npm run dev
>⚠️ Logout and login again for group changes to take effect if newgrp docker does not work.

# Start frontend (Terminal 2)
cd frontend && npm run dev
### 3. Docker Setup

```bash
# Build and run containers
docker-compose up -d --build
```

Open `http://localhost:3000` 🎉
* Backend API: `http://localhost:5000`
* Frontend App: `http://localhost:3000`

### 4. Environment Variables

Create a `.env` file inside the `backend` folder:

```env
MONGO_URI=your_mongodb_connection_string
PORT=5000
```

---

## 🎯 How to Use

1. **Add Stations**: Enter station name and click "Add Station"
2. **Connect Stations**: Select two stations, enter distance (km) and cost (₹), click "Add Connection"
2. **Connect Stations**: Select two stations, enter distance (km) and cost (₹), click "Add Connection"
3. **Find Route**: Choose start/end stations, select "Distance" or "Cost" optimization, click "Find Route"
4. **View Results**: See the optimal path with total distance and cost

Expand All @@ -79,15 +98,18 @@ Open `http://localhost:3000` 🎉

```
indore-route-planner/
├── frontend/ # React app
├── frontend/ # React app
│ ├── Dockerfile # Dockerfile for frontend
│ ├── src/
│ │ └── App.jsx # Main component
│ └── package.json
├── backend/ # Express API
│ ├── models/ # MongoDB schemas
│ ├── routes/ # API routes
│ ├── utils/ # Dijkstra algorithm
│ └── server.js # Main server
├── backend/ # Express API
│ ├── Dockerfile # Dockerfile for backend
│ ├── models/ # MongoDB schemas
│ ├── routes/ # API routes
│ ├── utils/ # Dijkstra algorithm
│ └── server.js
├── docker-compose.yml # Docker Compose setup
├── Jenkinsfile # CI/CD pipeline configuration
└── README.md
```

Expand All @@ -96,28 +118,31 @@ indore-route-planner/
## 🔌 API Endpoints

```bash
GET /api/stations # Get all stations
POST /api/stations # Add new station
GET /api/connections # Get all connections
POST /api/connections # Add new connection
POST /api/route # Calculate optimal route
GET /api/stations # Get all stations
POST /api/stations # Add new station
GET /api/connections # Get all connections
POST /api/connections # Add new connection
POST /api/route # Calculate optimal route
```

---

## 🧮 Algorithm

Uses **Dijkstra's Algorithm** to find:
- **Shortest Distance**: Minimum total kilometers
- **Cheapest Cost**: Minimum total rupees

* **Shortest Distance**: Minimum total kilometers
* **Cheapest Cost**: Minimum total rupees

---

## 🚀 Deployment

- **Frontend**: Deploy to Vercel : https://indore-metro.vercel.app
- **Backend**: Deploy to Render : https://indore-metro.onrender.com
- Set environment variables in deployment platforms
* **Docker**: Run frontend and backend via Docker Compose
* **CI/CD**: Jenkins pipeline automates building, testing, and deployment
* **Frontend**: Vercel - [https://indore-metro.vercel.app](https://indore-metro.vercel.app)
* **Backend**: Render - [https://indore-metro.onrender.com](https://indore-metro.onrender.com)
* Configure `.env` in deployment environments

---

Expand All @@ -135,11 +160,12 @@ Uses **Dijkstra's Algorithm** to find:

**Made by Harshit Singh**

- 📧 Email: [email protected]
- 💻 GitHub: [harshitsingh4321](https://github.com/harshitsingh4321)
* 📧 Email: [[email protected]](mailto:[email protected])
* 💻 GitHub: [harshitsingh4321](https://github.com/harshitsingh4321)

---

## 📄 License

MIT License - feel free to use this project!

7 changes: 7 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node:18
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
EXPOSE 5000
CMD [ "npm", "start" ]
39 changes: 39 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
services:
mongo:
image: mongo:latest
container_name: mongodb
ports:
- "27017:27017"
volumes:
- my-mongo-data:/data/db
networks:
- mern
backend:
build:
context: ./backend
ports:
- "5000:5000"
volumes:
- ./backend:/usr/src/app
networks:
- mern
depends_on:
- mongo


frontend:
build:
context: ./frontend
container_name: frontend
ports:
- "5173:5173"
networks:
- mern
depends_on:
- backend

networks:
mern:
driver: bridge
volumes:
my-mongo-data:
7 changes: 7 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node:18
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
EXPOSE 5173
CMD ["npm", "run", "dev"]
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"dev": "vite --host 0.0.0.0",
"build": "vite build",
"lint": "eslint .",
"preview": "vite preview"
Expand Down