https://github.com/bervproject/shorten-url
Shorten URL App using Redis as Primary Databases
https://github.com/bervproject/shorten-url
Last synced: 4 months ago
JSON representation
Shorten URL App using Redis as Primary Databases
- Host: GitHub
- URL: https://github.com/bervproject/shorten-url
- Owner: bervProject
- License: mit
- Created: 2022-08-03T00:38:46.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-15T17:43:03.000Z (almost 2 years ago)
- Last Synced: 2024-04-17T00:58:37.854Z (almost 2 years ago)
- Language: C#
- Size: 1.05 MB
- Stars: 2
- Watchers: 5
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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

* Login - Home Page

* URL List - By Users

* Edit URL

# Overview video
Here's a short video that explains the project and how it uses Redis:
[](https://youtu.be/BAVv3r51VKA)
## 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}`.

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](https://github.com/redis-developer/basic-analytics-dashboard-redis-bitmaps-nodejs#how-the-data-is-accessed) 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.

### Prerequisites
1. [.NET 6](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)
2. Docker (Optional)
### Local installation
0. Clone the project
1. Restore/Install Dependencies. `dotnet restore`.
2. Setup the environment example: `export RedisConnectionString=...` or update section `RedisConnectionString` of `ShortenUrl/appsettings.json`.
3. Now your project is ready!
## Deployment
To make deploys work, you need to create free account on [Redis Cloud](https://redis.info/try-free-dev-to)
### Heroku
[](https://heroku.com/deploy?template=https://github.com/bervProject/shorten-url)
## 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](https://discord.gg/redis) or on [Twitter](https://twitter.com/redisinc).
### Getting Started
1. Sign up for a [free Redis Cloud account using this link](https://redis.info/try-free-dev-to) and use the [Redis Stack database in the cloud](https://developer.redis.com/create/rediscloud).
1. Based on the language/framework you want to use, you will find the following client libraries:
- [Redis OM .NET (C#)](https://github.com/redis/redis-om-dotnet)
- Watch this [getting started video](https://www.youtube.com/watch?v=ZHPXKrJCYNA)
- Follow this [getting started guide](https://redis.io/docs/stack/get-started/tutorials/stack-dotnet/)
- [Redis OM Node (JS)](https://github.com/redis/redis-om-node)
- Watch this [getting started video](https://www.youtube.com/watch?v=KUfufrwpBkM)
- Follow this [getting started guide](https://redis.io/docs/stack/get-started/tutorials/stack-node/)
- [Redis OM Python](https://github.com/redis/redis-om-python)
- Watch this [getting started video](https://www.youtube.com/watch?v=PPT1FElAS84)
- Follow this [getting started guide](https://redis.io/docs/stack/get-started/tutorials/stack-python/)
- [Redis OM Spring (Java)](https://github.com/redis/redis-om-spring)
- Watch this [getting started video](https://www.youtube.com/watch?v=YhQX8pHy3hk)
- Follow this [getting started guide](https://redis.io/docs/stack/get-started/tutorials/stack-spring/)
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](https://redis.info/devhub) - The main developer page for Redis, where you can find information on building using Redis with sample projects, guides, and tutorials.
1. [Redis Stack getting started page](https://redis.io/docs/stack/) - Lists all the Redis Stack features. From there you can find relevant docs and tutorials for all the capabilities of Redis Stack.
1. [Redis Rediscover](https://redis.com/rediscover/) - Provides use-cases for Redis as well as real-world examples and educational material
1. [RedisInsight - Desktop GUI tool](https://redis.info/redisinsight) - 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
1. Youtube Videos
- [Official Redis Youtube channel](https://redis.info/youtube)
- [Redis Stack videos](https://www.youtube.com/watch?v=LaiQFZ5bXaM&list=PL83Wfqi-zYZFIQyTMUU6X7rPW2kVV-Ppb) - Help you get started modeling data, using Redis OM, and exploring Redis Stack
- [Redis Stack Real-Time Stock App](https://www.youtube.com/watch?v=mUNFvyrsl8Q) from Ahmad Bazzi
- [Build a Fullstack Next.js app](https://www.youtube.com/watch?v=DOIWQddRD5M) with Fireship.io
- [Microservices with Redis Course](https://www.youtube.com/watch?v=Cy9fAvsXGZA) by Scalable Scripts on freeCodeCamp