Problem

We need to provide different payment links for customers from different countries.

Solution

With Geo Redirector I can give a single link to all my customers from around the world.

How

Geo Redirector is a self-hosted URL redirection application. Add unique URL for each country and get a single URL to share with others. The URL will be redirected to the unique URL according to the visitor's country.

Demo

Multiple Payment Links for each country (w.r.t currencies) on Stripe

Payment links on Stripe

Add Product on Geo Redirector

Add Product on Geo Redirector

Single Geo Redirector link generated for the product

Products page on Geo Redirector

Automatic redirection to Stripe payment page according to the country

Stripe Payment Page

Analytics to know where our customers are from

Analytics page on Geo Redirector

How we built it

Frontend

Frontend for Geo Redirector was built using Svelte, Tailwind CSS with Daisy UI and Chart JS.

Backend

Backend for Geo Redirector was built using Svelte Kit and Node JS.

Database

MySQL compatible serverless database cluster from TiDB was used for its scalability, reliability and cost-effectiveness. The low response times of queries from TiDB is crucial for redirection of URLs in Geo Redirector with minimal latency and for storing/retrieval of visitor's country for analytics.

Entity Relationship Diagram

Entity Relationship Diagram of Geo Redirector

ORM

Prisma library was used to provide ORM for Geo Redirector.

Hosting & Deployment

Vercel is being used for seamless deployment and hosting of Geo Redirector.

Testing

  1. Go to https://geo-redirector.vercel.app .
  2. Register an account using 'Click here to register'.
  3. Login using that account.
  4. Click 'ADD PRODUCTS'.
  5. Enter 'Product Name', select your country using 'Select country', enter a URL e.g. 'https://google.com' .
  6. Click 'ADD' and Repeat step 5 with another country.
  7. Click 'ADD PRODUCT'.
  8. Click the generated Geo Redirector link, you should be redirected to the URL you entered for your country.
  9. Click Analytics in Geo Redirector, to see the locations of the visitors to the Geo Redirector link.

Note: If the unique URL for a specific country is not set, it will resolve to 404 page by default but if DEFAULT_COUNTRY with ISO 3166-1 alpha-2 country code is set in the environment variable it will redirect to that country URL.

Sample Geo Redirector link : https://geo-redirector.vercel.app/product/Sunglass/1860003 (Works with US, UK, IN only).

Challenges we ran into

Since Geo Redirector is a self-hosted application we needed a seamless integration with a serverless database, TiDB's serverless platform helped us integrate MySQL compatible database seamlessly into Geo Redirector.

We needed to obtain the geo-location of the visitor in order to redirect them, Vercel's IP Geo Location headers helped us to achieve it.

Accomplishments that we're proud of

We were able to ideate, develop and deploy Geo Redirector within the stipulated time of the TiDB future app hackathon.

What we learned

This is our first ever Svelte Kit project and we learnt how to build a full-stack application in Svelte Kit using TypeScript, Prisma, Tailwind CSS, TiDB and Vercel.

What's next for Geo Redirector [Updated]

Implementing analytics by taking advantage of TiDB's distributed, cluster-native, MySQL-Compatible Hybrid Transactional and Analytical Processing database.

Since Geo Redirector is used for redirecting URLs according to the country, knowing which country gets the most redirections would help our users to focus more on that market and to add the payment link for countries which they haven’t added yet.

TiDB’s low latency queries and scalability would be crucial to implement this feature. Initial version of this feature has been implemented during the final push phase. We plan to implement real-time update of analytics map in the future versions.

Built With

Share this project:

Updates