A comprehensive Data Structures and Algorithms (DSA) project that provides an interactive web-based visualization tool for various shortest path algorithms. This full-stack application allows users to create graphs, run different algorithms, and visualize the results in real-time.
- Dijkstra's Algorithm - Finds shortest paths from a source node to all other nodes in a weighted graph
- Bellman-Ford Algorithm - Handles graphs with negative edge weights and detects negative cycles
- Floyd-Warshall Algorithm - Finds shortest paths between all pairs of nodes
- Prim's Algorithm - Constructs minimum spanning trees
- Kruskal's Algorithm - Another approach for minimum spanning trees
- Interactive Graph Editor - Create and modify graphs with drag-and-drop nodes and edges
- Real-time Visualization - Watch algorithms execute step-by-step with animated highlights
- User Authentication - Register and login to save your graphs and results
- Graph Library - Save and manage multiple graphs
- Result History - View past algorithm executions and their results
- Algorithm Comparison - Run multiple algorithms on the same graph for comparison
- Node.js with Express.js framework
- MongoDB with Mongoose ODM
- Python for algorithm implementations
- JWT Authentication with bcrypt password hashing
- CORS enabled for cross-origin requests
- React 18 with modern hooks and functional components
- React Router for client-side routing
- Vis.js Network for interactive graph visualization
- Tailwind CSS for responsive styling
- Context API for state management
- Nodemon for backend development
- Concurrently for running multiple services
- ESLint for code linting
Before running this application, make sure you have the following installed:
- Node.js (v16 or higher)
- Python 3.x (for running algorithms)
- MongoDB (local installation or cloud service like MongoDB Atlas)
- npm or yarn package manager
git clone <repository-url>
cd shortest-path-project# Install all dependencies (backend + frontend)
npm run install-all
# Or install manually:
# Backend dependencies
npm run install-server
# Frontend dependencies
npm run install-clientCreate a .env file in the backend directory with the following variables:
MONGO_URI=mongodb://localhost:27017/shortest-path-db
# Or for MongoDB Atlas: mongodb+srv://username:password@cluster.mongodb.net/shortest-path-db
JWT_SECRET=your-super-secret-jwt-key-here
PORT=5000Make sure MongoDB is running on your system:
# For local MongoDB installation
mongod
# Or use MongoDB Compass/Atlas for cloud database# Development mode (runs both frontend and backend concurrently)
npm run dev
# Or run services separately:
# Terminal 1: Start backend server
npm run server
# Terminal 2: Start frontend client
npm run clientThe application will be available at:
- Frontend: http://localhost:3000 (React app)
- Backend API: http://localhost:5000 (Express server)
- Open the application in your browser
- Use the graph editor to add nodes (click on empty space)
- Add edges by dragging from one node to another
- Set edge weights by clicking on edges and entering values
- Select an algorithm from the dropdown menu
- Choose a starting node (for applicable algorithms)
- Click "Run Algorithm" to execute and visualize
- View the results in the output panel
- Register/Login to save your work
- Save Graphs to your personal library
- View History of previous algorithm runs
- Compare Results across different algorithms
shortest-path-project/
βββ backend/ # Express.js server
β βββ algorithms/ # Python algorithm implementations
β β βββ dijkstra.py
β β βββ bellman_ford.py
β β βββ floyd_warshall.py
β β βββ kruskal.py
β β βββ prims.py
β βββ config/ # Database configuration
β βββ controllers/ # Route controllers
β βββ middleware/ # Authentication middleware
β βββ models/ # MongoDB schemas
β βββ routes/ # API routes
β βββ utils/ # Utility functions
β βββ server.js # Main server file
β βββ package.json
βββ frontend/ # React application
β βββ public/ # Static assets
β βββ src/
β β βββ components/ # React components
β β βββ contexts/ # React context providers
β β βββ api.js # API service functions
β β βββ App.jsx # Main app component
β βββ package.json
βββ package.json # Root package.json
βββ README.md
POST /api/auth/register- User registrationPOST /api/auth/login- User loginGET /api/auth/profile- Get user profile
POST /api/graphs/dijkstra- Run Dijkstra's algorithmPOST /api/graphs/bellman-ford- Run Bellman-Ford algorithmPOST /api/graphs/floyd-warshall- Run Floyd-Warshall algorithmPOST /api/graphs/prims- Run Prim's algorithmPOST /api/graphs/kruskal- Run Kruskal's algorithmPOST /api/graphs/save- Save a graphGET /api/graphs/library- Get user's saved graphsGET /api/graphs/history- Get algorithm execution history
cd backend
npm testcd frontend
npm test- Set up environment variables on your hosting platform
- Ensure Python is available on the server
- Deploy to services like Heroku, Railway, or Vercel
npm run buildDeploy the build folder to services like Netlify, Vercel, or GitHub Pages.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the ISC License - see the LICENSE file for details.
- Built as a comprehensive DSA learning tool
- Uses Vis.js for graph visualization
- Python algorithms for computational efficiency
- React ecosystem for modern web development
If you encounter any issues or have questions:
- Check the existing issues on GitHub
- Create a new issue with detailed information
- Include error messages, screenshots, and steps to reproduce
Happy Learning! π Explore the fascinating world of graph algorithms through interactive visualization.