GitHub - TheJisus28/dijkstra-pathfinder: 🚀 Modern web application implementing Dijkstra's shortest path algorithm with interactive graph visualization. Built with Go backend and Tailwind CSS frontend. · GitHub
Skip to content

About

🚀 Modern web application implementing Dijkstra's shortest path algorithm with interactive graph visualization. Built with Go backend and Tailwind CSS frontend.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Dijkstra Pathfinder Web Application

A modern web application that implements Dijkstra's shortest path algorithm with an interactive graph visualization interface.

🚀 Features

  • 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

🏗️ Architecture

Backend (Go)

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

Frontend (JavaScript + Tailwind CSS)

statics/
  ├── index.html           # Main web interface with Tailwind CSS
  └── app.js              # Frontend logic and API integration

💻 Technologies Used

Backend

  • Go 1.21+: Main programming language
  • Standard Library: HTTP server, JSON handling, logging
  • Container/Heap: Priority queue for Dijkstra's algorithm

Frontend

  • 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

Architecture Patterns

  • 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

🛠️ Installation & Setup

Prerequisites

  • Go 1.19 or higher
  • Modern web browser

Running the Application

  1. Clone the repository

    git clone https://github.com/TheJisus28/dijkstra-pathfinder.git
    cd dijkstra-pathfinder
  2. Choose your preferred method:

    Option A: Native Go (Recommended for development)

    go run cmd/server/main.go

    Or use the Makefile:

    make run

    Option B: Docker (Cross-platform, production-ready)

    # Build and run with Docker
    make docker-run

    Option C: Docker commands directly

    # Build image
    docker build -t dijkstra-pathfinder .
    
    # Run container
    docker run -p 8080:8080 dijkstra-pathfinder
  3. Access the application

🧪 Testing

Run the comprehensive test suite to verify algorithm correctness:

make test             # Run all tests

💡 Available Commands

For a complete list of available development commands:

make help             # Show all available Makefile commands

📖 Usage

Web Interface

  1. Add Nodes: Enter node names and click "Add Node" - nodes appear as removable tags
  2. Create Connections: Select source and destination nodes, specify distance
  3. Find Path: Choose start and end nodes, click "Find Path"
  4. Visualize: View the interactive graph with highlighted shortest path in real-time
  5. Manage Graph: Remove nodes and connections with intuitive UI controls

API Usage

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"
}

🔧 Configuration

Environment Variables

  • PORT: Server port (default: 8080)

Custom Configuration

You can modify the following constants in cmd/server/main.go:

  • defaultPort: Default server port
  • staticDir: Static files directory

🐳 Docker Deployment

The application is fully containerized and can run on any system with Docker installed.

Docker Features

  • 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

Available Docker Commands

# 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-pathfinder

Environment Variables

  • PORT: Server port (default: 8080)

🧪 API Endpoints

Method Endpoint Description
GET / Serve web interface
POST /solve Find shortest path
GET /health Health check

🏃‍♂️ Performance

  • 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

🛡️ Error Handling

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

📈 Future Enhancements

  • Persistent graph storage
  • Graph templates and presets
  • Export/Import functionality
  • Performance metrics dashboard

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

👨‍💻 Author

Jesús Carrascal (@TheJisus28)

Built with ❤️ for academic and professional presentations.

🌟 Project Highlights

  • 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

About

🚀 Modern web application implementing Dijkstra's shortest path algorithm with interactive graph visualization. Built with Go backend and Tailwind CSS frontend.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages