A fast, lightweight URL shortener with click analytics, custom aliases, and link expiry. Built with Node.js, Express, and PostgreSQL.
| Layer | Technology | Hosted On |
|---|---|---|
| Frontend | HTML, CSS, JavaScript | Vercel (free) |
| Backend | Node.js + Express | Hugging Face Spaces (free) |
| Database | PostgreSQL | Neon (free) |
snip/
├── client/
│ ├── index.html
│ ├── style.css
│ └── app.js
├── server/
│ ├── index.js # Entry point
│ ├── routes/
│ │ └── url.js # API routes
│ ├── controllers/
│ │ └── urlController.js
│ └── db/
│ ├── index.js # DB connection
│ └── schema.sql # Table definitions
├── assets/
│ └── preview.webp # UI Demo
├── .env.example
├── .gitignore
└── package.json
- Node.js v18+
- PostgreSQL v15+
- Navigate to the project directory
cd snip- Install dependencies
npm install- Set up environment variables
cp .env.example .envThen fill in your .env file:
PORT=3000
DATABASE_URL=postgresql://user:password@localhost:5432/snip
BASE_URL=http://localhost:3000
CORS_ORIGIN=http://localhost:3000- Set up the database
psql -U your_user -d snip -f server/db/schema.sql- Start the server
npm run devVisit http://localhost:3000 in your browser.
This project is optimized for a 100% free stack. Here is the exact mapping:
Files Used: server/db/schema.sql
- Action: Copy the content of
server/db/schema.sqland run it in the Neon SQL Editor to create your table. - Result: You get a
DATABASE_URL(connection string).
Files Used: server/, Dockerfile, package.json
- Action: Create a new Space on Hugging Face with Docker SDK. The GitHub Action (
.github/workflows/deploy-hf.yml) auto-deploys on every push tomain. - Environment Variables (add as Secrets/Variables in Space settings):
DATABASE_URL: Your Neon connection string (secret).BASE_URL: Your HF Space URL (e.g.,https://username-snip-url-backend.hf.space).CORS_ORIGIN: Your Frontend URL (e.g.,https://snip.vercel.app).
- Result: You get a Backend URL (e.g.,
https://username-snip-url-backend.hf.space).
Files Used: client/
- Action:
- Update
client/app.js: Setconst API_BASE_URLto your Hugging Face Space backend URL. - Deploy the
clientfolder to Vercel.
- Update
- Result: You get a live Frontend URL.
Contributions are welcome! Feel free to open an issue or submit a pull request.
