So the tech stack used in this project is :
- next js for the frontend
- express + typescript with prisma orm in the backend
- i have used bun in this project because its faster than npm also at the rntime it seems better
in local i was using postgres in docker, but in deployment, i used neon db
If trying local :
BACKEND;
.env file in apps/api
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/sniply?schema=public&sslmode=disable"
ACCESS_TOKEN_SECRET=something
REFRESH_TOKEN_SECRET=something
docker compose up -d #in rootcd apps/api
bun install
bunx --bun prisma migrate dev --name init
bunx --bun prisma generate
bun run index.tsFRONTEND: .env file in apps/web
NEXT_PUBLIC_API_URL="http://localhost:4000"
NEXT_PUBLIC_BRAND_NAME=something # this name will be used in frontend default will be sniply cd apps/web
bun install
bun devfor deployment i have used :
- render web service for the backend
- vercel for the frontend
- Neon for the postgres db
The data model :
-
User -to store the account info and the owned links
-
Link -to store the original url , the alias , time duration , cap info and all and just click count
-
Click - this is only for analytics , i thought it would be better to seperate it from link table
-
refresh Token - this is used for authentication and session management
If i had only 4 hours i would have built only these :
- auth
- basic short url generation with redirect
- click count
Assumptions :
- unique clicks i assumed it to be like if the same user open the link more than once only his first click is considered unique
This project was created using bun init in bun v1.3.14. Bun is a fast all-in-one JavaScript runtime.
