
A powerful and scalable URL shortener with integrated bio pages built using Spring Boot.
An enterprise-grade, powerful and scalable URL shortener with integrated bio pages built using Spring Boot.
| Maven Package | Github Packages - com.bitmutex.shortener |
| Docker Image | DockerHub - nmpl/shortener:latest |
This project is an enterprise-grade URL shortener and bio page application developed with Spring Boot. It provides a robust solution for shortening URLs and creating bio pages for users. The application is designed for scalability and includes features such as analytics, user management, and subscription plans.
Before you begin, ensure you have the following installed:
installers folder.install.bat file by double-clicking on it or using the following command:
1 lines1install.bat
install.sh using the following command:
2 lines1chmod +x install.sh 2./install.sh
Clone the repository:
2 lines1git clone https://github.com/aamitn/URLShortener.git 2cd URLShortener
Apply the Database Schema:
Execute the provided create.sql file to set up the necessary tables and schema for the application. This script will also create the required database.
1 lines1mysql -u your_username -p{your_password} < create.sql
Update the application.properties file:
application.properties file in the src/main/resources directory with your application configuration.Build and run the application:
1 lines1mvn spring-boot:run
Access the application at http://localhost:8080
Build a deployable WAR:
1 lines1mvn clean install
Deploy the WAR:
Option 1: Manual Deployment
Deploy the generated WAR file to your Tomcat server. Copy the WAR file to the webapps directory of your Tomcat installation.
1 lines1cp target/shorten.war /path/to/tomcat/webapps/
Option 2: Web Interface Upload
Alternatively, if your Tomcat server provides a web interface for WAR file deployment, follow these steps:
http://localhost:8080/manager/html (replace with your Tomcat server address).shortener.war file using the file upload button.Configure Variables on deployed war:
Set environment variables for cloud-specific settings.
Adjust Tomcat Configuration (Important):
To ensure proper functionality, it's important to run the application on the root of the servlet container. If you're using Tomcat, add the following line to your server.xml configuration file within the <Host> section:
1 lines1<Context path="" docBase="shorten" reloadable="true"></Context>
This ensures that the application runs on the root context path. Adjust the docBase attribute according to your deployment directory.
Start Tomcat:
Start your Tomcat server.
2 lines1/path/to/tomcat/bin/startup.sh # for Linux 2/path/to/tomcat/bin/startup.bat # for Windows
Access the application at http://localhost:8080/.
Adjust Configuration (Optional): If you need to customize the application configuration after deployment, you can find the application.properties file within the deployed WAR file. THe file can be accesses as :
1 lines1vi /path/to/tomcat/webapps/shortener/WEB-INF/classes/application.properties
To deploy the URL Shortener application on your cloud environment, follow the steps below:
Prerequisites
Clone the Repository:
2 lines1git clone https://github.com/your-username/URLShortener.git 2cd URLShortener
Deploy Using Docker
Build and Run Your Own Image:
2 lines1docker build -t shortener:latest . 2docker run -p 8080:8080 -p 3306:3306 shortener:latest
OR
Use Our Pre-built Image with Docker Compose:
2 lines1docker compose build 2docker compose up
Customizing Docker Compose Configuration:
In the docker-compose.yml file, you can customize the build source for the Shortener service:
7 lines1# Build from docker hub image .Comment/Uncomment Below 2image: nmpl/shortener:latest 3 4 # Build from local Dockerfile.Comment/Uncomment Below 5 # build: 6 # context: . 7 # dockerfile: Dockerfilekerfile
Comment or uncomment the relevant lines based on whether you want to use the pre-built image from Docker Hub or build from the local Dockerfile.
Setup Kubernetes Deployment and Service:
2 lines1cd k8s 2kubectl apply -f deploy.yaml,service.yaml,data.yaml
Expose the K8s service:
1 lines1kubectl port-forward service/shortener-app 8080:8080
Access Application at http://localhost:8080
1 lines1minikube service shortener-app
Use the following command to monitor the deployment:
```plaintext
kubectl get pods
```
4. Deploy Using Helm Chart
Create Deployment from helm chart named "instance" , with a service named "instance-shortener-chart" :
2 lines1cd k8s 2helm install instance shortener-chart/ --values shortener-chart/values.yaml
Expose the K8s service:
1 lines1kubectl port-forward service/instance-shortener-chart 8080:8080
1 lines1minikube service shortener-app
Use the following command to monitor the deployment:
```plaintext
kubectl get pods
```
Wait until the pod is in the "Running" state.
Access the Application
Depending on your Kubernetes setup, you might need to get the external IP of the service:
1 lines1kubectl get service instance-shortener-chart
Access your application using the provided external IP(from command output) or at : http://localhost:8080.
To configure the SMS service, you need to specify parameters related to the SMS provider in the application.properties file.
3 lines1sms.provider=managed 2 managed.sms.api.key=your_managed_sms_api_key 3 managed.sms.phone-number=123456789
4 lines1sms.provider=selfhosted 2selfhosted.gateway.url=https://your-smsgateway-url/index.php 3selfhosted.device.id=your_device_id 4selfhosted.hash=your_device_hash
Check application status from the /monitoring page at : http://localhost:8080/monitoring
Check application OpenAPI 3.0 compliant docs at: http://localhost:8080/docs-ui
Contributions are welcome! Please follow the contribution guidelines.
This project is licensed under the MIT License - see the LICENSE.md file for details.
© Bitmutex Technologies | 2024
Check out the live demo or dive into the source code to see how it's built.