From 629adccd30869ff87ae0610c020933570b3c1f2f Mon Sep 17 00:00:00 2001 From: Suraj-Encoding Date: Wed, 31 Dec 2025 20:27:45 +0530 Subject: [PATCH 01/39] docs: updated the readme --- README.md | 113 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 80 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 0080721..aa8e7b6 100644 --- a/README.md +++ b/README.md @@ -1,61 +1,108 @@ - +# 🕸️ Welcome To Shortify - Modern URL Shortener 🕸️ -# URL Shortener +Shortify is a modern, full‑stack URL shortening service built with Go (backend), MongoDB (data store), Clerk (authentication), and Next.js (frontend). It's designed for rapid development and production readiness with clean APIs and a polished UI. -A simple URL shortening service built in Go +--- -## Overview +## Tech Stack -This project provides a basic URL-shortening service implemented in Go. It allows users to shorten long URLs into more manageable and shareable links. The service also includes a redirect feature to redirect users from the shortened URL to the original long URL. +- **Backend:** Go +- **Database:** MongoDB +- **Auth:** Clerk +- **Frontend:** Next.js -## Installation +--- -To use the URL shortener, you need to have Go installed on your system. You can download and install Go from the [official Go website](https://go.dev/). +## Key Features -Clone the repository to your local machine: +- Shorten URLs into vanity links (username + slug) +- Fast redirect service for shortened links +- User management and authentication via Clerk +- MongoDB for reliable storage of users and links +- Next.js frontend with responsive UI and Clerk integration -```sh -git clone https://github.com/Suraj-Encoding/Shortify.git -``` +--- + +## Project Structure (high level) + +- `Server/` — Go backend, API handlers, app logic and MongoDB integration +- `Client/` — Next.js frontend, components, and Clerk auth routes +- `README.md` — This file + +--- -## Usage +## Quick Start -### Running the Server +Prerequisites: -Navigate to the project directory and run the following command to start the server: +- Go 1.20+ installed +- MongoDB accessible (local or hosted) +- Clerk account and API keys (for auth) -```sh -go run main.go +1. Clone the repo + +```bash +git clone https://github.com/Suraj-Encoding/Shortify.git +cd Shortify ``` -The server will start listening on port `8080` by default. You can change the port in the `main.go` file if needed. +2. Backend: configure environment -### Shortening a URL +- Copy or create `Server/.env` (or set env vars) with MongoDB URI, Clerk keys, and other settings used by `Server/env`. -To shorten a URL, send a POST request to the `/shorten` endpoint with a JSON payload containing the original URL: +3. Run the backend -```sh -curl -X POST http://localhost:8080/shorten -H "Content-Type: application/json" -d '{"url": "https://www.linkedin.com/username"}' +```bash +cd Server +go build ./... +./main ``` -The response will contain a JSON object with the shortened URL: +4. Frontend: install and run -```json -{ - "short_url": "http://localhost:8080/redirect/a2352b" -} +```bash +cd Client +npm install +npm run dev ``` -### Redirecting to the Original URL +The frontend typically runs on `http://localhost:3000` and the backend on `http://localhost:8080` (configurable). -To redirect to the original URL, visit the shortened URL in your browser or send a GET request to the `/redirect/{id}` endpoint, where `{id}` is the shortened URL ID: +--- -```sh -curl http://localhost:8080/redirect/a2352b -``` +## Common Endpoints + +- Redirect (public): `GET /{username}/{slug}` — redirects to the destination URL +- API base: `/api/v1` + - User webhook: `POST /api/v1/user/webhook` (Clerk) + - Update username: `PUT /api/v1/user/username` + - Links CRUD: under `/api/v1/link` -This will redirect you to the original URL associated with the shortened URL. +--- + +## Testing & Development Tips + +- Use `curl -v http://localhost:8080/alice/abc123` to test redirects. +- Run `go build ./...` to check for backend compile errors. +- Ensure Clerk webhooks point to the server's `/api/v1/user/webhook` during integration. + +--- ## Contributing -Contributions are welcome! Feel free to fork the repository and submit pull requests. \ No newline at end of file +Contributions welcome — open issues or submit PRs. Follow these steps: + +1. Fork the repo +2. Create a feature branch +3. Make changes and run `go build` and `npm run dev` locally +4. Open a PR with a clear description + +--- + +## License + +This project uses the license in the repository. Feel free to adapt as needed. + +--- + +Enjoy Shortify — let me know if you want a README badge, deployment guide, or CI steps added. \ No newline at end of file From d832b1eaada3add760350b7e2fb855e323348fd6 Mon Sep 17 00:00:00 2001 From: Suraj-Encoding Date: Wed, 31 Dec 2025 20:40:39 +0530 Subject: [PATCH 02/39] docs: updated the readme --- README.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index aa8e7b6..d85424a 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,9 @@ Prerequisites: 1. Clone the repo ```bash -git clone https://github.com/Suraj-Encoding/Shortify.git +mkdir Shortify cd Shortify +git clone https://github.com/Suraj-Encoding/Shortify.git . ``` 2. Backend: configure environment @@ -54,7 +55,8 @@ cd Shortify ```bash cd Server -go build ./... +go mod tidy +go build main.go ./main ``` @@ -63,16 +65,17 @@ go build ./... ```bash cd Client npm install +npm run build npm run dev ``` -The frontend typically runs on `http://localhost:3000` and the backend on `http://localhost:8080` (configurable). +The frontend typically runs on `http://localhost:3000` and the backend on `http://localhost:3001` (configurable). --- ## Common Endpoints -- Redirect (public): `GET /{username}/{slug}` — redirects to the destination URL +- Redirect (public): `GET /{username}/{slug}` — redirects to the destination URL of the link - API base: `/api/v1` - User webhook: `POST /api/v1/user/webhook` (Clerk) - Update username: `PUT /api/v1/user/username` @@ -82,8 +85,8 @@ The frontend typically runs on `http://localhost:3000` and the backend on `http: ## Testing & Development Tips -- Use `curl -v http://localhost:8080/alice/abc123` to test redirects. -- Run `go build ./...` to check for backend compile errors. +- Use `curl -v http://localhost:3001/surajdalvi1/github` to test redirects. +- Run `go build main.go` to check for backend compile errors. - Ensure Clerk webhooks point to the server's `/api/v1/user/webhook` during integration. --- From 991b3d7c53c080034c271822e876eb9efd7f4493 Mon Sep 17 00:00:00 2001 From: Suraj-Encoding Date: Wed, 31 Dec 2025 20:53:07 +0530 Subject: [PATCH 03/39] feat: added the example env for client --- Client/.env.example | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Client/.env.example diff --git a/Client/.env.example b/Client/.env.example new file mode 100644 index 0000000..a76fc60 --- /dev/null +++ b/Client/.env.example @@ -0,0 +1,11 @@ +## Environment Variables ## + +# Clerk 'Service' +NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY = "Your_Clerk_Publishable_Key" +CLERK_SECRET_KEY = "Your_Clerk_Secret_Key" + +# Clerk 'Routes' +NEXT_PUBLIC_CLERK_SIGN_IN_URL = "/sign-in" +NEXT_PUBLIC_CLERK_SIGN_UP_URL = "/sign-up" +NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL = "/" +NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL = "/" \ No newline at end of file From 14a004454df95543a2d0a4308eea951cbe2a463f Mon Sep 17 00:00:00 2001 From: Suraj-Encoding Date: Wed, 31 Dec 2025 20:54:28 +0530 Subject: [PATCH 04/39] docs: updated the readme --- README.md | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d85424a..ccbbe21 100644 --- a/README.md +++ b/README.md @@ -47,9 +47,9 @@ cd Shortify git clone https://github.com/Suraj-Encoding/Shortify.git . ``` -2. Backend: configure environment +2. Backend: configure application settings -- Copy or create `Server/.env` (or set env vars) with MongoDB URI, Clerk keys, and other settings used by `Server/env`. +- Configure the backend with your deployment-specific settings (database, auth, and server URL). See the Server package docs for details. 3. Run the backend @@ -91,6 +91,37 @@ The frontend typically runs on `http://localhost:3000` and the backend on `http: --- +## Deployment + +Below are quick deployment flows for the frontend (Vercel) and backend (Render). These are minimal steps — adapt them for your environment and secrets manager. + +- Vercel (Frontend) + + 1. Create a Vercel project and connect it to this repository. + 2. Set the Project Root to `Client` (or import as a monorepo and point the app to `Client`). + 3. Build command: `npm run build` + 4. Output directory: leave default (Next.js handled by Vercel). + 5. Configure required settings and secrets in Vercel (Dashboard → Settings → Environment Variables). + 6. Deploy — Vercel will run builds on every push. + +- Render (Backend) + + 1. Create a new Web Service on Render and connect it to the repository. + 2. Set the root directory to `Server`. + 3. Environment & Build: + - Build command: `go build main.go` + - Start command: `./main` + 4. Configure required settings and secrets in Render (Service settings → Environment). + 5. Deploy — Render will build and start the service; check logs for startup errors. + +Tips: + +- Use Vercel for the Next.js frontend (serverless/edge‑optimized) and Render (or similar) for the Go backend. +- Keep production secrets in the platform's environment manager — never commit them. +- If using webhooks (Clerk), configure callback URLs in Clerk to point to your deployed `POST /api/v1/user/webhook` endpoint. + +--- + ## Contributing Contributions welcome — open issues or submit PRs. Follow these steps: @@ -108,4 +139,7 @@ This project uses the license in the repository. Feel free to adapt as needed. --- -Enjoy Shortify — let me know if you want a README badge, deployment guide, or CI steps added. \ No newline at end of file +## Acknowledgments +Enjoy Shortify — deployment and CI-CD guidance have been added above. Open an issue or PR if you want badges, examples, or more detailed deployment templates. + +--- \ No newline at end of file From 85c91f97cd677e5be6bb8a31792119bd5efce8d2 Mon Sep 17 00:00:00 2001 From: Suraj-Encoding Date: Wed, 31 Dec 2025 21:04:30 +0530 Subject: [PATCH 05/39] docs: updated the readme --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ccbbe21..5002461 100644 --- a/README.md +++ b/README.md @@ -47,9 +47,15 @@ cd Shortify git clone https://github.com/Suraj-Encoding/Shortify.git . ``` -2. Backend: configure application settings +2. Configure application settings (local & production) -- Configure the backend with your deployment-specific settings (database, auth, and server URL). See the Server package docs for details. +Before running the app locally or deploying, make sure your runtime configuration is in place: + +- Local development: copy `Server/.env.example` to `Server/.env` and `Client/.env.example` to `Client/.env`, then open those files and fill in values specific to your environment. Keep sensitive values out of version control. + +- Production: configure required settings and secrets in your hosting platform's environment manager (Vercel, Render, etc.). Ensure callback/webhook URLs (for Clerk and other services) point to your deployed URLs. + +Use the example files in `Server/.env.example` and `Client/.env.example` as the authoritative list of keys to provide; the README avoids enumerating individual variable names to keep configuration details centralized in the example files. 3. Run the backend From d7588ef0829eaccbd8dce87d2efee909539e882e Mon Sep 17 00:00:00 2001 From: Suraj-Encoding Date: Wed, 31 Dec 2025 21:33:27 +0530 Subject: [PATCH 06/39] removed footer compoment --- Client/app/contact/page.tsx | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 Client/app/contact/page.tsx diff --git a/Client/app/contact/page.tsx b/Client/app/contact/page.tsx deleted file mode 100644 index 53a4a72..0000000 --- a/Client/app/contact/page.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import React from "react"; -import Footer from '@/Components/Footer/Footer'; - - - -// # Contact Page -const page = () => { - return ( -
-
-
- ); -}; - -export default page; From ce93b189779efa7db507f7433fd7ca7a6d8ba2cd Mon Sep 17 00:00:00 2001 From: Suraj-Encoding Date: Wed, 31 Dec 2025 21:44:48 +0530 Subject: [PATCH 07/39] env updated --- Client/.env.example | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Client/.env.example b/Client/.env.example index a76fc60..20564a8 100644 --- a/Client/.env.example +++ b/Client/.env.example @@ -1,5 +1,8 @@ ## Environment Variables ## +# Shortify Server 'Base URL' +NEXT_PUBLIC_SHORTIFY_SERVER_BASE_URL = "Your_Shortify_Server_Base_URL" + # Clerk 'Service' NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY = "Your_Clerk_Publishable_Key" CLERK_SECRET_KEY = "Your_Clerk_Secret_Key" From a28fb8ae51a9323340f30fd52b33016f5d798435 Mon Sep 17 00:00:00 2001 From: Suraj-Encoding Date: Thu, 1 Jan 2026 00:03:06 +0530 Subject: [PATCH 08/39] feat: converted next js from ts to js --- Client/Components/Footer/Footer.tsx | 17 -- .../Interface/constant/{data.ts => data.js} | 4 +- .../constant/{metadata.ts => metadata.js} | 4 +- Client/Interface/types/data.ts | 7 - Client/Interface/types/metadata.ts | 8 - .../[[...sign-in]]/{page.tsx => page.jsx} | 0 .../[[...sign-up]]/{page.tsx => page.jsx} | 0 Client/app/(auth)/{layout.tsx => layout.jsx} | 2 +- Client/app/{layout.tsx => layout.jsx} | 4 +- Client/app/{page.tsx => page.jsx} | 3 +- Client/{middleware.ts => middleware.js} | 0 Client/package-lock.json | 249 +----------------- Client/package.json | 12 +- Client/tsconfig.json | 41 --- 14 files changed, 21 insertions(+), 330 deletions(-) delete mode 100644 Client/Components/Footer/Footer.tsx rename Client/Interface/constant/{data.ts => data.js} (58%) rename Client/Interface/constant/{metadata.ts => metadata.js} (67%) delete mode 100644 Client/Interface/types/data.ts delete mode 100644 Client/Interface/types/metadata.ts rename Client/app/(auth)/(routes)/sign-in/[[...sign-in]]/{page.tsx => page.jsx} (100%) rename Client/app/(auth)/(routes)/sign-up/[[...sign-up]]/{page.tsx => page.jsx} (100%) rename Client/app/(auth)/{layout.tsx => layout.jsx} (69%) rename Client/app/{layout.tsx => layout.jsx} (86%) rename Client/app/{page.tsx => page.jsx} (69%) rename Client/{middleware.ts => middleware.js} (100%) delete mode 100644 Client/tsconfig.json diff --git a/Client/Components/Footer/Footer.tsx b/Client/Components/Footer/Footer.tsx deleted file mode 100644 index 9da0a97..0000000 --- a/Client/Components/Footer/Footer.tsx +++ /dev/null @@ -1,17 +0,0 @@ -"use client"; - -import React from 'react'; -import Data from '@/Interface/constant/data'; - -// # Footer Component -const Footer = () => { - return ( -
- Copyright - © - {new Date().getFullYear()} {Data.author} -
- ); -}; - -export default Footer; diff --git a/Client/Interface/constant/data.ts b/Client/Interface/constant/data.js similarity index 58% rename from Client/Interface/constant/data.ts rename to Client/Interface/constant/data.js index 7d58645..b7b6594 100644 --- a/Client/Interface/constant/data.ts +++ b/Client/Interface/constant/data.js @@ -1,7 +1,5 @@ -import { DataProp } from '../types/data'; - // # 'Data' Constant -const Data: DataProp = { +const Data = { name: "Suraj Dalvi", author: "Suraj Dalvi" }; diff --git a/Client/Interface/constant/metadata.ts b/Client/Interface/constant/metadata.js similarity index 67% rename from Client/Interface/constant/metadata.ts rename to Client/Interface/constant/metadata.js index 5112987..edbe20a 100644 --- a/Client/Interface/constant/metadata.ts +++ b/Client/Interface/constant/metadata.js @@ -1,7 +1,5 @@ -import { MetaDataProp } from '../types/metadata'; - // # 'MetaData' Constant -const MetaData: MetaDataProp = { +const MetaData = { title: "Shortify - URL Shortener", description: "💲Shortify💲 ~ 🕸️ URL Shortener 🕸️", icons: "/Logo.png" diff --git a/Client/Interface/types/data.ts b/Client/Interface/types/data.ts deleted file mode 100644 index 5ca2666..0000000 --- a/Client/Interface/types/data.ts +++ /dev/null @@ -1,7 +0,0 @@ -// # 'Data' Type -type DataProp = { - name: string; - author: string; -}; - -export type { DataProp }; diff --git a/Client/Interface/types/metadata.ts b/Client/Interface/types/metadata.ts deleted file mode 100644 index a861195..0000000 --- a/Client/Interface/types/metadata.ts +++ /dev/null @@ -1,8 +0,0 @@ -// # 'MetaData' Type -type MetaDataProp = { - title: string; - description: string; - icons: string; -}; - -export type { MetaDataProp }; \ No newline at end of file diff --git a/Client/app/(auth)/(routes)/sign-in/[[...sign-in]]/page.tsx b/Client/app/(auth)/(routes)/sign-in/[[...sign-in]]/page.jsx similarity index 100% rename from Client/app/(auth)/(routes)/sign-in/[[...sign-in]]/page.tsx rename to Client/app/(auth)/(routes)/sign-in/[[...sign-in]]/page.jsx diff --git a/Client/app/(auth)/(routes)/sign-up/[[...sign-up]]/page.tsx b/Client/app/(auth)/(routes)/sign-up/[[...sign-up]]/page.jsx similarity index 100% rename from Client/app/(auth)/(routes)/sign-up/[[...sign-up]]/page.tsx rename to Client/app/(auth)/(routes)/sign-up/[[...sign-up]]/page.jsx diff --git a/Client/app/(auth)/layout.tsx b/Client/app/(auth)/layout.jsx similarity index 69% rename from Client/app/(auth)/layout.tsx rename to Client/app/(auth)/layout.jsx index 614811f..b3a5c6d 100644 --- a/Client/app/(auth)/layout.tsx +++ b/Client/app/(auth)/layout.jsx @@ -1,4 +1,4 @@ -const AuthLayout = ({ children }: { children: React.ReactNode }) => { +const AuthLayout = ({ children }) => { return ( <>
diff --git a/Client/app/layout.tsx b/Client/app/layout.jsx similarity index 86% rename from Client/app/layout.tsx rename to Client/app/layout.jsx index 1f75169..9bac711 100644 --- a/Client/app/layout.tsx +++ b/Client/app/layout.jsx @@ -1,7 +1,7 @@ import './globals.css' import { Inter } from 'next/font/google' import { ToastContainer } from "react-toastify"; -import MetaData from '@/Interface/constant/metadata'; +import MetaData from '../Interface/constant/metadata'; import { ClerkProvider } from '@clerk/nextjs'; import "react-toastify/dist/ReactToastify.css"; @@ -11,8 +11,6 @@ export const metadata = MetaData export default function RootLayout({ children -}: { - children: React.ReactNode }) { return ( diff --git a/Client/app/page.tsx b/Client/app/page.jsx similarity index 69% rename from Client/app/page.tsx rename to Client/app/page.jsx index a128a1e..2b0b82f 100644 --- a/Client/app/page.tsx +++ b/Client/app/page.jsx @@ -1,13 +1,12 @@ "use client"; import React from "react"; -import Footer from '@/Components/Footer/Footer'; // # Shortify Page - Entry Point const page = () => { return ( <> -