Skip to content

Latest commit

 

History

History
127 lines (80 loc) · 6.84 KB

README.md

File metadata and controls

127 lines (80 loc) · 6.84 KB

Simple Shorten URL using Redis and Auth0

Simple App for Shorten your URL and using Redis as the main databases.

Screenshots

  • Non Login - Home Page

non login - home page

  • Login - Home Page

login - home page

  • URL List - By Users

url list

  • Edit URL

edit

Overview video

Here's a short video that explains the project and how it uses Redis:

short video

How it works

How the data is stored:

The data is stored as JSON values and only has a single structure.

  • Each JSON values have properties:

    • Id : Generated id, used for the key too.
    • ShortenUrl: The shorten URL, will be used to find the original URL. (Indexed)
    • OriginalUrl: The original URL, will be used to redirect the pages.
    • CreatedBy: To know the creator, will allow editing for entries that are created by authenticated users. (Indexed)
    • VisitedCounter: To know how many "clicks" or visited the shortened url.

The key is generated ShortenUrl.Models.Urls:{urlId}.

keys

Also generate index "FT.CREATE" "Urls" "ON" "Json" "PREFIX" "1" "ShortenUrl.Models.Urls:" "SCHEMA" "$.Id" "AS" "Id" "TAG" "SEPARATOR" "|" "$.ShortenUrl" "AS" "ShortenUrl" "TAG" "SEPARATOR" "|" "$.CreatedBy" "AS" "CreatedBy" "TAG" "SEPARATOR" "|" "$.VisitedCounter" "AS" "VisitedCounter" "NUMERIC" "SORTABLE"

How the data is accessed:

Refer to this example for a more detailed example of what you need for this section.

  • MyURL list (search using index). FT.SEARCH Urls (@CreatedBy:{username/email}) LIMIT 0 100

    • Example: "FT.SEARCH" "Urls" "(@CreatedBy:{bervianto\\.leo\\@gmail\\.com})" "LIMIT" "0" "100"
  • Validate url uniques/find the shortened url. FT.SEARCH Urls (@ShortenUrl:{shortened-url}) LIMIT 0 100

    • Example: "FT.SEARCH" "Urls" "(@ShortenUrl:{okeoke})" "LIMIT" "0" "1"
  • Store the JSON value.

    • Example: "JSON.SET" "ShortenUrl.Models.Urls:01GBJAJ5CQMZRFC6D2MZQ3QBAD" "." "{"Id":"01GBJAJ5CQMZRFC6D2MZQ3QBAD","ShortenUrl":"okeoke","OriginalUrl":"https://google.com","CreatedBy":"bervianto.leo@gmail.com","VisitedCounter":0}"

Performance Benchmarks

N/A

How to run it locally?

  1. Run using dotnet run --project ShortenUrl
  2. Access the web using the link from the console output. As example, please see the picture below.

local url

Prerequisites

  1. .NET 6
  2. Docker (Optional)

Local installation

  1. Clone the project
  2. Restore/Install Dependencies. dotnet restore.
  3. Setup the environment example: export RedisConnectionString=... or update section RedisConnectionString of ShortenUrl/appsettings.json.
  4. Now your project is ready!

Deployment

To make deploys work, you need to create free account on Redis Cloud

Heroku

Deploy

More Information about Redis Stack

Here some resources to help you quickly get started using Redis Stack. If you still have questions, feel free to ask them in the Redis Discord or on Twitter.

Getting Started

  1. Sign up for a free Redis Cloud account using this link and use the Redis Stack database in the cloud.
  2. Based on the language/framework you want to use, you will find the following client libraries:

The above videos and guides should be enough to get you started in your desired language/framework. From there you can expand and develop your app. Use the resources below to help guide you further:

  1. Developer Hub - The main developer page for Redis, where you can find information on building using Redis with sample projects, guides, and tutorials.
  2. Redis Stack getting started page - Lists all the Redis Stack features. From there you can find relevant docs and tutorials for all the capabilities of Redis Stack.
  3. Redis Rediscover - Provides use-cases for Redis as well as real-world examples and educational material
  4. RedisInsight - Desktop GUI tool - Use this to connect to Redis to visually see the data. It also has a CLI inside it that lets you send Redis CLI commands. It also has a profiler so you can see commands that are run on your Redis instance in real-time
  5. Youtube Videos