https://github.com/nitzanpap/url-shortener
A simple URL shortener service, written in Go & Next.js
https://github.com/nitzanpap/url-shortener
gin-gonic go nextjs postgresql react typescript
Last synced: 3 months ago
JSON representation
A simple URL shortener service, written in Go & Next.js
- Host: GitHub
- URL: https://github.com/nitzanpap/url-shortener
- Owner: nitzanpap
- License: gpl-3.0
- Created: 2024-06-09T14:22:03.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2026-02-07T16:24:30.000Z (5 months ago)
- Last Synced: 2026-02-07T23:19:05.063Z (5 months ago)
- Topics: gin-gonic, go, nextjs, postgresql, react, typescript
- Language: Go
- Homepage: https://usni.vercel.app
- Size: 7.3 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license.md
Awesome Lists containing this project
README
# URL Shortener
## Introduction
This is a simple URL shortener project, made for learning purposes.
It is similar to Bit.ly or TinyURL, and allows users to input a long URL and receive a shortened version of it. This makes sharing links easier and helps in tracking and managing URLs.
[View the live application here](https://usni.vercel.app/) 👈.
## Features
- **Shorten URLs:** Convert long URLs into manageable short links.
- **Easy to use:** Simple interface for creating and managing URLs.
- **PWA:** Easily install the application on Windows, macOS, Android, and iOS. [Click here to see how](https://www.google.com/search?q=how+to+download+pwa)
## Technologies
- **Backend:** Go, Gin
- **Database:** PostgreSQL
- **Frontend:** Next.js, TypeScript, SCSS.modules
## Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
### Prerequisites
What things you need to install the software and how to install them:
For the server:
- Go: [Download and install Go](https://golang.org/doc/install)
- Air: [Install Air](https://github.com/air-verse/air?tab=readme-ov-file#installation) if you want to use live reload
- PostgreSQL: [Download and install PostgreSQL](https://www.postgresql.org/download/)
For the client:
- Bun: [Download and install Bun](https://bun.sh/docs/installation)
### Installing
A step by step series of examples that tell you how to get a development env running:
1. Clone the repository:
```bash
git clone github.com/nitzanpap/url-shortener
```
2. Change into the project directory:
```bash
cd url-shortener
```
3. Install root dependencies:
```bash
bun install
```
### Running Both Server and Client Together
The easiest way to run both the server and client simultaneously is using the root-level script:
```bash
bun run dev
```
This uses `concurrently` to run both the server (with live reload) and the client development server in a single terminal with labeled output.
Alternatively, you can run the server and client separately in different terminals as described below.
#### Server Setup
- **Note:** If you are using VS Code, you can use the `Go` extension to install the necessary tools and dependencies.
1. Change into the server directory:
```bash
cd server
```
2. Create a `.env` file in the server directory:
```bash
touch .env
```
Make sure to populate the `.env` file according to the `.env.example` file.
3. Run the server via make:
- For development, run with live reload:
```bash
make run/live
```
- Or build and run the server:
1. Manually:
```bash
make build && make run
```
2. Via Docker:
```bash
docker compose up
```
#### Client Setup
1. Change into the client directory:
```bash
cd client
```
2. Create a `.env.local` file in the client directory:
```bash
touch .env.local
```
Make sure to populate the `.env.local` file according to the `.env.example` file.
3. Install the dependencies:
```bash
bun install
```
4. Run the development server:
- For development:
```bash
bun run dev
```
- For production:
```bash
bun run build && bun start
```
## Debugging
If you are using VS Code, you can use the `launch.json` configurations to debug the server and client code.
## Deployment
I am deploying the server to render.com and the client to Vercel. You can deploy the server and client to any platform of your choice.