A full‑stack URL shortening service that allows users to input a long URL and receive a shortened version. The backend is built with Node.js, Express, and MongoDB (using Mongoose), while the frontend is a React application styled with Material UI (MUI). This project is highly customizable so you can adjust the BASE_URL, appearance, and functionality to suit your needs.
url-shortener/
├── backend/
│ ├── package.json
│ ├── .env
│ ├── server.js
│ ├── config/
│ │ └── db.js
│ ├── models/
│ │ └── Url.js
│ └── routes/
│ └── urls.js
├── frontend/
│ ├── package.json
│ ├── public/
│ │ └── index.html
│ └── src/
│ ├── index.js
│ ├── App.js
│ ├── config.js
│ ├── components/
│ │ ├── ShortenForm.js
│ │ └── UrlList.js
│ └── styles/
│ └── main.css
└── README.md
cd backend
npm install
.env
file in the backend directory with the following content (adjust values as needed):
PORT=5000
MONGO_URI=mongodb://localhost:27017/url_shortener_db
BASE_URL=http://localhost:5000
npm run dev
npm start
POST http://localhost:5000/api/urls
GET http://localhost:5000/api/urls
GET
request to http://localhost:5000/<shortCode>
will redirect to the original URL.GET http://localhost:5000/api/health
(if implemented)cd frontend
npm install
src/config.js
and update the following if needed:
backendUrl
: URL of your backend server.npm start
The app will run at http://localhost:3000.
npm start
npm run build
build
folder using your preferred hosting platform or integrate it with your backend.BASE_URL:
Update the BASE_URL
in the backend .env
file to reflect your domain (e.g., https://yourdomain.com
).
UI Adjustments:
Customize Material UI components in the frontend/src/components/
folder. Global styling can be modified in frontend/src/styles/main.css
.
Backend Modifications:
Extend or modify models and routes in the backend
folder to add new features or change functionality.
Feel free to fork this repository and submit pull requests with improvements or customizations. If you encounter any bugs or have feature requests, please open an issue.
This project is licensed under the MIT License.
The UNC-CH Google Developer Student Club (GDSC) team.