Introducing Murls - The Advanced URL Re-director

Introducing Murls - The Advanced URL Re-director

ยท

3 min read

Brief Summary ๐Ÿ‘‹๐Ÿป

Murls is an advanced URL Re-director capable of handling huge number of URLs with some advanced redirection capabilities. I worked with Aditya Mitra to build Murls.

Actually, Murls is not an simple server redirecting URLs, or a simple app creating URLs. Actually, it is a combination of all including a Web Server, a Mobile App and a Chrome Extension.

officialLogo1024.jpg

A little about myself and the project

Hello, I am Ankit. I am Junior Computer Science Undergrad from India. To be honest, I am more of a competitive programmer than a developer. Murls is the first production grade application that I have built.

I worked with Aditya to build these applications. Both of us were busy and we did not get a lot of time except the last week to build it. We had some sleepless nights but were able to finally complete it (although we are still going to improve it).

Auth0 Above All ๐Ÿ›ก

Auth needs to be pluggable

This statement is very true when we used Auth0.

Auth0 handles all the authentication for the mobile app, the web extension and the server. Auth0 all of the heavy lifting for handling logins, signups and logouts.

The Server's Fast โšก

If you use our application, you might notice a Boost option. This is basically means this URL will have a fast redirection* over non-boosted URLs.

This is how we have done it in code:

def redirector(request, slug):

    cached_location = redis.get(slug) # this is where the 'boost' comes into play
    update_url_data(request, slug)

    if cached_location is not None:
        return HttpResponseRedirect(cached_location.decode('utf-8'))

    try:
        found_url = Url.objects.values("location").get(slug=slug)
        location = found_url.get("location")
        return HttpResponseRedirect(location)
    except:
        return HttpResponseRedirect("/")

We used Django to build and run our Web Server. It provided us with a lot of caching abilities and an easy to scale web-server in python.

The Mobile App ๐Ÿ“ฑ

We built the mobile app with Flutter.

The mobile app is the integral part when it comes to creating new urls and showing the metrics for a particular URL.

Handling The Authentication

There are some pieces of code that I wanted to share (It might be useful to Flutter developers using Auth0)

Login

Future<String> login() async { 

      final authorizationTokenRequest = AuthorizationTokenRequest( 
        AUTH0_CLIENT_ID, 
        AUTH0_REDIRECT_URI, 
        issuer: AUTH0_ISSUER, 
        scopes: ['openid', 'profile', 'offline_access', 'email'], 
        promptValues: ['login'], 
      ); 

      final AuthorizationTokenResponse? result = 
          await appAuth.authorizeAndExchangeCode( 
        authorizationTokenRequest, 
      ); 

      return await _setLocalVariables(result); 

  }

Get User

Future<Auth0User> getUserDetails(String accessToken) async { 
    final url = Uri.https( 
      AUTH0_DOMAIN, 
      '/userinfo', 
    ); 

    final response = await http.get( 
      url, 
      headers: {'Authorization': 'Bearer $accessToken'}, 
    ); 

    if (response.statusCode == 200) { 
      return Auth0User.fromJson(jsonDecode(response.body)); 
    } else { 
      throw Exception('Failed to get user details'); 
    } 
  }

image.png

The Web Extension โญ๏ธ

The Murls Web Extension is very handy when you don't want to open up the mobile app all the way to type the url. The Extension will take care of getting the page's url and getting the redirected url for you.

image.png

Tools We Used โš’๏ธ

ServerMobileWeb Extension
Django, Django Rest FrameworkFlutterPreact
NginxFlutter App_AuthMaterial-UI
PostgreSQLFlutter Secure StorageReact Icons
RedisFL_Chart-

It's Not Over Yet ๐Ÿง—๐Ÿป

Murls was builtin within a week and there a lot of features that we had thought of and could not integrate. Nevertheless, we will be working on this project more and integrate those.

Conclusion

GitHub Repo: github.com/ankit435/murls

GitHub Release: github.com/ankit435/murls/releases/tag/v1

I want to thank Hashnode and Auth0 for making this Hackathon happen. The experience I received and learnt from this Hackathon is priceless.

ย