Skip to content

Suraj-Encoding/Shortify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

268 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ•ธ๏ธ Welcome to Shortify - Modern URL Shortener ๐Ÿ•ธ๏ธ

Shortify is a modern, fullโ€‘stack URL shortening service built with Go/Java (backend), MongoDB (data store), Clerk (authentication), and React.js (frontend). It's designed for rapid development and production readiness with clean APIs and a polished UI.


๐Ÿš€ Live Deployments


Tech Stack

  • Backend: Go / Java (Spring Boot)
  • Database: MongoDB
  • Auth: Clerk
  • Frontend: React.js

Key Features

  • 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
  • React.js frontend with responsive UI and Clerk integration
  • Dual backend support (Go and Java) with identical APIs

Project Structure (high level)

  • Server/Go/ โ€” Go backend, API handlers, app logic and MongoDB integration
  • Server/Java/ โ€” Java Spring Boot backend (API-compatible with Go)
  • Client/ โ€” React.js frontend, components, and Clerk auth routes
  • README.md โ€” This file

Quick Start

Prerequisites:

  • Go 1.20+ installed (for Go backend)
  • Java 17+ and Maven 3.6+ installed (for Java backend)
  • MongoDB accessible (local or hosted)
  • Clerk account and API keys (for auth)
  1. Clone the repo
mkdir Shortify
cd Shortify
git clone https://github.com/<your-github-username>/Shortify.git .
  1. Configure application settings (local & production)

Before running the app locally or deploying, make sure your runtime configuration is in place:

  • Local development: copy Server/Go/.env.example to Server/Go/.env (or Server/Java/.env.example to Server/Java/.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/Go/.env.example, Server/Java/.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.

  1. Run the backend (choose one)

Option A: Go Backend

cd Server/Go
go mod tidy
go build main.go
./main

Option B: Java Backend

cd Server/Java
mvn clean package -DskipTests
java -jar target/shortify-1.0.0.jar

Or using Maven directly:

cd Server/Java
mvn spring-boot:run
  1. Frontend: install and run
cd Client
npm install
npm run dev

To build for production:

npm run build

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 of the link
  • 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

Note: Both Go and Java backends expose identical API endpoints and response formats. No frontend changes required when switching backends.


Testing & Development Tips

  • Use curl -v http://localhost:3001/username/slug 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.

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: dist
    5. Configure required settings and secrets in Vercel (Dashboard โ†’ Settings โ†’ Environment Variables).
    6. Deploy โ€” Vercel will run builds on every push.
  • Render (Backend - Go)

    1. Create a new Web Service on Render and connect it to the repository.
    2. Set the root directory to Server/Go.
    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.
  • Render (Backend - Java)

    1. Create a new Web Service on Render and connect it to the repository.
    2. Set the root directory to Server/Java.
    3. Environment & Build:
      • Build command: mvn clean package -DskipTests
      • Start command: java -jar target/shortify-1.0.0.jar
    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 React.js frontend and Render (or similar) for the Go/Java 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:

  1. Fork the repo
  2. Create a feature branch
  3. Make changes and test locally:
    • Go backend: cd Server/Go && go build main.go
    • Java backend: cd Server/Java && mvn compile
    • Frontend: cd Client && npm run dev
  4. Open a PR with a clear description

License

This project uses the license in the repository. Feel free to adapt as needed.


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.