ShortLink is a web application that allows users to generate short URLs for their long links.
The app provides additional features such as password protection for private links and an info page to track the number of clicks and the link's visibility status (public or private)
- Short Link Generation: Convert long URLs into short, easy-to-share links
- Private Links: Protect your short links with a password for added security
- Link Analytics: Use the info page to track the number of clicks
The project is divided into two main folders:
short-link-backend: Contains the backend code built with Node.js, TypeScript, and MongoDB.short-link-frontend: Contains the frontend code built with Vite, React, and TailwindCSS.
This project includes a docker-compose.yml file to easily run the entire project with Docker. Additionally, each folder has its own Dockerfile to run the backend and frontend separately.
To run the entire project (both frontend and backend) using Docker Compose, follow these steps:
-
Ensure Docker are installed on your machine.
-
Clone the repository:
git clone https://github.com/iheb15M/shortlink cd shortlink -
Run the following command:
docker compose up --build
-
now the project is runing on http://localhost:8080/
- Node.js: Ensure that Node.js version >= 22 is installed on your machine. You can download it from here
- Docker: Make sure Docker is installed. You can download it from here
- MongoDB Compass (optional): To inspect and interact with the MongoDB database, you can use MongoDB Compass. Download it from here
To run the project in devMode, follow these steps:
First, start the MongoDB container using Docker Compose:
docker compose up shortlink.dbThis will start the MongoDB container, which is required for the backend to function.
Navigate to the short-link-backend directory:
cd ./short-link-backendInstall the required dependencies:
npm install # or npm iRun the backend in development mode:
npm run start:devNavigate to the short-link-frontend directory:
cd ./short-link-frontendInstall the required dependencies:
npm install # or npm iRun the frontend in development mode:
npm run devIf you want to inspect the MongoDB database using MongoDB Compass, follow these steps:
-
Open MongoDB Compass.
-
In the connection string field, use the following URI to connect to your local MongoDB instance:
mongodb://root:azerty@localhost:27017/shortlink?authSource=adminThis connects to the MongoDB instance running in the Docker container. -
Click Connect to access the database
