A modern web application that implements Dijkstra's shortest path algorithm with an interactive graph visualization interface.
- Interactive Graph Builder: Create custom graphs by adding nodes and edges dynamically
- Real-time Visualization: Dynamic graph rendering with vis.js and custom styling
- Shortest Path Calculation: Efficient Dijkstra algorithm implementation in Go
- Modern UI: Beautiful, responsive interface built with Tailwind CSS
- Smart Notifications: Toast notifications for user feedback and error handling
- RESTful API: Clean HTTP API for graph operations
- Professional Architecture: Well-structured Go backend with proper separation of concerns
- CORS Support: Cross-origin requests enabled for frontend integration
- Request Logging: Comprehensive logging middleware for monitoring
cmd/
βββ server/
βββ main.go # Application entry point
pkg/
βββ models/
β βββ graph.go # Graph data structures
β βββ request.go # Request/Response models
β βββ graph_test.go # Graph tests
βββ services/
β βββ dijkstra.go # Dijkstra algorithm implementation
β βββ dijkstra_test.go # Algorithm tests
βββ handlers/
β βββ graph.go # HTTP request handlers
βββ middleware/
βββ cors.go # CORS middleware
βββ logging.go # Request logging middleware
statics/
βββ index.html # Main web interface with Tailwind CSS
βββ app.js # Frontend logic and API integration
- Go 1.21+: Main programming language
- Standard Library: HTTP server, JSON handling, logging
- Container/Heap: Priority queue for Dijkstra's algorithm
- Tailwind CSS: Modern utility-first CSS framework
- Vanilla JavaScript: Clean, dependency-free frontend logic
- Font Awesome: Icon library for UI elements
- vis.js: Network visualization library
- Clean Architecture: Separation of concerns with pkg structure
- RESTful API: Standard HTTP methods and status codes
- Middleware Pattern: CORS and logging middleware
- MVC Pattern: Models, handlers (controllers), and services
- Go 1.19 or higher
- Modern web browser
-
Clone the repository
git clone https://github.com/TheJisus28/dijkstra-pathfinder.git cd dijkstra-pathfinder -
Choose your preferred method:
go run cmd/server/main.go
Or use the Makefile:
make run
# Build and run with Docker make docker-run# Build image docker build -t dijkstra-pathfinder . # Run container docker run -p 8080:8080 dijkstra-pathfinder
-
Access the application
- Web Interface: http://localhost:8080
- API Endpoint: http://localhost:8080/solve
- Health Check: http://localhost:8080/health
Run the comprehensive test suite to verify algorithm correctness:
make test # Run all testsFor a complete list of available development commands:
make help # Show all available Makefile commands- Add Nodes: Enter node names and click "Add Node" - nodes appear as removable tags
- Create Connections: Select source and destination nodes, specify distance
- Find Path: Choose start and end nodes, click "Find Path"
- Visualize: View the interactive graph with highlighted shortest path in real-time
- Manage Graph: Remove nodes and connections with intuitive UI controls
Endpoint: POST /solve
Request Body:
{
"start": "NodeA",
"end": "NodeC",
"nodes": ["NodeA", "NodeB", "NodeC"],
"edges": [
{
"from": "NodeA",
"to": "NodeB",
"distance": 5
},
{
"from": "NodeB",
"to": "NodeC",
"distance": 8
},
{
"from": "NodeA",
"to": "NodeC",
"distance": 20
}
]
}Response:
{
"path": ["NodeA", "NodeB", "NodeC"],
"distance": 13,
"success": true,
"message": "Shortest path found with distance 13"
}PORT: Server port (default: 8080)
You can modify the following constants in cmd/server/main.go:
defaultPort: Default server portstaticDir: Static files directory
The application is fully containerized and can run on any system with Docker installed.
- Multi-stage build: Optimized image size (~10MB)
- Security: Runs as non-root user
- Health checks: Built-in container health monitoring
- Cross-platform: Works on Linux, Windows, macOS
# Development
make docker-build # Build Docker image
make docker-run # Build and run container
make docker-clean # Clean Docker resources
# Production
docker build -t dijkstra-pathfinder .
docker run -d -p 8080:8080 --name dijkstra dijkstra-pathfinderPORT: Server port (default: 8080)
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Serve web interface |
| POST | /solve |
Find shortest path |
| GET | /health |
Health check |
- Algorithm Complexity: O((V + E) log V) where V = vertices, E = edges
- Memory Usage: O(V + E) for graph storage
- Concurrent Requests: Supported via Go's goroutines
The API provides comprehensive error responses:
- 400 Bad Request: Invalid input data
- 405 Method Not Allowed: Unsupported HTTP method
- 500 Internal Server Error: Server-side errors
- Persistent graph storage
- Graph templates and presets
- Export/Import functionality
- Performance metrics dashboard
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
JesΓΊs Carrascal (@TheJisus28)
Built with β€οΈ for academic and professional presentations.
- Clean Architecture: Professional Go backend structure with proper separation of concerns
- Modern Frontend: Built with Tailwind CSS for a beautiful, responsive interface
- Custom UI Components: Styled dropdowns, notifications, and interactive elements
- Real-time Visualization: Interactive graph rendering with vis.js and path highlighting
- User Experience: Toast notifications, hover effects, and intuitive controls
- Production Ready: Includes logging, CORS support, error handling, and health checks
- Zero Dependencies: Frontend uses only CDN resources (Tailwind CSS, Font Awesome, vis.js)
- Educational Value: Perfect for demonstrating graph algorithms and web development skills