A URL shortener is a classic backend project that reinforces routing, database design, and CRUD operations. It’s similar to services like Bit.ly or TinyURL.
Stack suggestion:
- Backend: Node.js + Express or Python + Flask
- Database: MongoDB or PostgreSQL
- Frontend: Basic HTML/CSS or React
Core features:
- Form to input a long URL.
- Generate a short ID (e.g., using
nanoid
or base62 hash). - Store long URL and short ID in the database.
- Redirect endpoint: Accessing
/abc123
redirects to the original URL. - Analytics (optional): Track click counts and timestamps.
Example Express route:
jsКопироватьРедактироватьapp.get('/:shortId', async (req, res) => {
const originalUrl = await db.find({ short: req.params.shortId });
if (originalUrl) res.redirect(originalUrl);
else res.status(404).send("Not found");
});
Bonus features:
- Expiration dates.
- Admin dashboard.
- QR code generation.
Hosting it on Heroku, Vercel, or Render makes for a strong portfolio project that demonstrates full-stack capability.
Leave a Reply