Home Projects Portfolio Dashboard Export PDF Log in
Python JavaScript

Simplifying Navigation: Implementing Clean Routes for TISNET Panels

The Problem with Nested Complexity

In the TISNET project, as our dashboard panels grew in number, our URL structure became increasingly convoluted. Navigating to specific analytical views required complex state parameters passed through the UI, making direct linking impossible and browser history management a nightmare.

We needed a cleaner, more predictable way to map our administrative panels to intuitive URL structures. The goal was to decouple the panel view logic from the underlying application state management.

The Refactor Approach

We decided to move toward a path-based routing strategy. By defining explicit routes for our panels, we allow the application to hydrate the correct view based purely on the URI, rather than relying on session storage or transient JavaScript state.

In our Python-based backend, we updated the router configuration to map clean slugs to our internal view controllers:

# Example of clean route definition
routes = [
    ("/panel/analytics", AnalyticsView),
    ("/panel/users", UserManagementView),
    ("/panel/settings", SystemSettingsView)
]

By centralizing these definitions, the backend can now resolve the required dependencies for each panel before rendering the template. On the frontend, we synchronized this by updating our JavaScript navigation layer to push new states to the browser history, ensuring that a user hitting "Back" returns to the previous panel accurately:

// JavaScript client-side navigation
function navigateToPanel(panelId) {
    const path = `/panel/${panelId}`;
    window.history.pushState({ panelId }, "", path);
    renderPanel(panelId);
}

The Outcome

This shift to clean routing provided three immediate benefits:

  1. Deep Linking: Users can now bookmark specific dashboard views.
  2. Browser History: The browser back/forward buttons work as expected, navigating through the history of panels rather than resetting the entire dashboard.
  3. Maintainability: Adding a new panel is now a declarative task—simply define the path and point it to the appropriate controller.

Key Takeaways

  • Prioritize URL design: Treat URLs as a first-class API for your UI.
  • Decouple state from path: Use the URL to represent where the user is, and let the application state handle how the component renders.
  • Fail fast: If a route does not exist, provide a clear 404 feedback mechanism to the user immediately.

Generated with Gitvlg.com

Simplifying Navigation: Implementing Clean Routes for TISNET Panels
A

Alejandro

Author

Share: