An url shortener with analytics.
Check it out on: https://peek-url.vercel.app
To run locally you require to have:
-
Of course
NodeJS
. -
Docker to run the docker compose.
-
IP Stack API key and set it in the
.env
asIP_STACK_API_KEY
, this is used for get the geolocation information from the requests, the app can work without this but you will not get any geolocation information. -
Firebase account.
-
Set the secrets in a
.env
(checkout .env.sample). -
Also you need the firebase credentials for the firebase admin. You need to provide the credentials implementing the interface
IFirebaseSecretProvider
and returning the implementation:// src/services/firebase-secret-provider.ts export function getSecretProvider(): IFirebaseSecretProvider { return new FirebaseSecretProvider(); }
The current implementation is pulling the credentials from a remote server and decrypting them using
AES
.Some options for implementing the
IFirebaseSecretProvider
are:- You can set the credentials
JSON
in a.env
asFIRE_BASE_SECRET
. Check the commented code in firebase-secret-provider.ts - Import the credentials as a
JSON
.
- You can set the credentials
-
You should NOT expose the credentials do not push it to git!
Also set the connection strings of the database and redis in the .env
file:
DATABASE_URL="postgresql://root:password123@localhost:6000/sample"
REDIS_URL="redis://default:redispassword123@localhost:6030
After having all that setup run:
-
docker compose up -d
This will create the database and the redis instance. -
npx prisma generate
To create the prisma client -
npx prisma migrate deploy
To apply the migrations to the database -
yarn dev
To start the application -
Then you can go to http://localhost:3000.
- Improve UI
- Add breadcrumbs or improved navigation
- Add transition animations
- Add entrance animation for items
- Filters for "My URLs"
- By domain
- By access count
- Filters for url access logs
- By datetime
- By country
- Options for short URL
- Include domain
- Include top-level-domain
- Localization
- Dropdown to change language
- Spanish 🇪🇸
- Allow anonymous to shorten url without login but without access to logs
- Allow to disable shorten URL
Not sure about letting to disable URL, maybe after X time, for example 1 hour or week.
- Check performance when shortening URL, the bottleneck may be the database.
- More clean user errors
- Error when accessing URL with new user
- Infinite scrolling to access logs