A powerful and scalable URL shortener with integrated bio pages built using Spring Boot.
Find a file
2024-02-15 22:57:09 +05:30
.github/workflows github actions support 2024-02-15 22:57:09 +05:30
.m2 added maven central package deployment support 2024-02-15 22:32:42 +05:30
.mvn/wrapper t 2024-02-01 23:44:46 +05:30
logs k8s complaint 2024-02-15 20:19:55 +05:30
META-INF Cloud Native Impl 2024-02-15 03:02:13 +05:30
out/artifacts/shortener_jar k8s complaint 2024-02-15 20:19:55 +05:30
src gig changes 2024-02-15 16:50:39 +05:30
test-output t 2024-02-01 23:44:46 +05:30
.gitignore modified gitignore to add exclusion rule for file C:\Users\bigwiz\IdeaProjects\URLShortener\shortener_db_schema.sql which is located in the root of the git repo 2024-02-15 20:23:50 +05:30
create.sql Cloud Native Impl 2024-02-15 03:02:13 +05:30
docker-compose.yml gig changes 2024-02-15 16:50:39 +05:30
Dockerfile gig changes 2024-02-15 16:50:39 +05:30
image.png t 2024-02-01 23:44:46 +05:30
mvnw t 2024-02-01 23:44:46 +05:30
mvnw.cmd t 2024-02-01 23:44:46 +05:30
pom.xml added maven central package deployment support 2024-02-15 22:32:42 +05:30
README.md k8s complaint 2024-02-15 20:19:55 +05:30
server.xml Cloud Native Impl 2024-02-15 03:02:13 +05:30
shortener-deployment.yaml k8s complaint 2024-02-15 20:19:55 +05:30
shortener-service.yaml k8s complaint 2024-02-15 20:19:55 +05:30
shortener.sh Cloud Native Impl 2024-02-15 03:02:13 +05:30
testng.xml t 2024-02-01 23:44:46 +05:30

TUSC - The URL Shortener Company

buddy pipeline
LicenseGitHub last commitGitHub issuesGitHub pull requestsGitHub contributors
Twitter

An enterprise-grade, powerful and scalable URL shortener with integrated bio pages built using Spring Boot.

Maven PackageFree Collaborative Markdown Editor - onlinemarkdowneditor.dev
Docker ImageFree Collaborative Markdown Editor - onlinemarkdowneditor.dev

Table of Contents

Overview

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.

Features

  • Shorten URLs and create custom short URLs.
  • Integrated bio pages for users.
  • Analytics tracking for each shortened URL.
  • User management with registration, login, and profile updates.
  • Subscription plans for premium features.
  • Rate limiting to prevent abuse.
  • Forgot password and username recovery functionality.
  • OPEN API 3.0 Complaint REST API set, with extensive docs.

Getting Started

Prerequisites

Before you begin, ensure you have the following installed:

  • Java (JDK 11 or later)
  • Maven
  • MySQL
  • Your favorite IDE (IntelliJ, Eclipse, etc.)

Local Setup

  1. Clone the repository:

    git clone https://github.com/aamitn/URLShortener.git
    
  2. Apply the Database Schema:

    Execute the provided db_schema.sql file to set up the necessary tables and schema for the application. This script will also create the required database.

    mysql -u your_username -p < path/to/db_schema.sql
    
  3. Update the application.properties file:

    Update the application.properties file in the src/main/resources directory with your database configuration.

  4. Build and run the application:

       cd URLShortener
       mvn spring-boot:run
    
  5. Access the application at http://localhost:8080

Deployment

  1. Build a deployable WAR:

    mvn clean install
    
  2. 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.

      cp 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:

      • Access the Tomcat Manager web interface at http://localhost:8080/manager/html (replace with your Tomcat server address).
      • Log in with your Tomcat manager credentials.
      • Navigate to the "WAR file to deploy" section.
      • Choose the shorten.war file using the file upload button.
      • Click the "Deploy" button.
  3. Configure environment variables:

    Set environment variables for cloud-specific settings.

  4. 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:

    <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.

  5. Start Tomcat:

    Start your Tomcat server.

    /path/to/tomcat/bin/startup.sh   # for Linux
    /path/to/tomcat/bin/startup.bat  # for Windows
    

    Access the application at http://localhost:8080/.

  6. 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 :

    vi /path/to/tomcat/webapps/your-app/WEB-INF/classes/application.properties
    

Cloud Native Deployment

To deploy the URL Shortener application on your cloud environment, follow the steps below:

Prerequisites

  1. Clone the Repository:

    git clone https://github.com/your-username/URLShortener.git
    cd URLShortener
    
  2. Build and Run Your Own Image:

    docker build -t shortener:latest .
    docker run -p 8080:8080 -p 3306:3306 shortener:latest
    
  3. Use Our Pre-built Image with Docker Compose:

    docker compose build
    docker compose up
    
  4. Customizing Docker Compose Configuration:

    In the docker-compose.yml file, you can customize the build source for the Shortener service:

        #Build from docker hub image .Comment/Uncomment Below
        image: nmpl/shortener:latest
    
     #Build from local Dockerfile.Comment/Uncomment Below
     #   build:
     #     context: .
     #     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.

  5. Deploy Using K8s

  • Setup Kubernetes Deployment and Service:

    kubectl apply -f shortener-deployment.yaml
    kubectl apply -f shortener-service.yaml        
    
  • 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:

     kubectl get service shortener-service
    

    Access your application using the provided external IP.

App Health

Usage Cases

  1. Shorten URLs by visiting the URL Shortener page.
  2. Access analytics for each shortened URL.
  3. Create and manage bio pages in the Bio section.

Contributing

Contributions are welcome! Please follow the contribution guidelines.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.