{"id":15211314,"url":"https://github.com/emmanuel-owusu/shortlink","last_synced_at":"2026-01-31T12:31:35.853Z","repository":{"id":239102571,"uuid":"798470868","full_name":"emmanuel-owusu/shortlink","owner":"emmanuel-owusu","description":"ShortLink is a URL-shortening service","archived":false,"fork":false,"pushed_at":"2024-05-13T09:54:32.000Z","size":96,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-15T14:14:54.390Z","etag":null,"topics":["docker","gradle","java","spring","springboot","springmvc","springweb"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emmanuel-owusu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-09T21:01:29.000Z","updated_at":"2024-05-13T09:54:37.000Z","dependencies_parsed_at":"2024-05-11T23:19:16.307Z","dependency_job_id":"fc45ad89-3457-4cfe-b528-5be66393eeee","html_url":"https://github.com/emmanuel-owusu/shortlink","commit_stats":{"total_commits":4,"total_committers":1,"mean_commits":4.0,"dds":0.0,"last_synced_commit":"f439751b8756f83547a2209854357c1918762f52"},"previous_names":["emmanuel-owusu/shortlink"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/emmanuel-owusu/shortlink","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emmanuel-owusu%2Fshortlink","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emmanuel-owusu%2Fshortlink/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emmanuel-owusu%2Fshortlink/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emmanuel-owusu%2Fshortlink/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emmanuel-owusu","download_url":"https://codeload.github.com/emmanuel-owusu/shortlink/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emmanuel-owusu%2Fshortlink/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28942893,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T12:10:04.904Z","status":"ssl_error","status_checked_at":"2026-01-31T12:09:58.894Z","response_time":128,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","gradle","java","spring","springboot","springmvc","springweb"],"created_at":"2024-09-28T08:22:49.237Z","updated_at":"2026-01-31T12:31:35.838Z","avatar_url":"https://github.com/emmanuel-owusu.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ShortLink ✨🔗\n[![java-version-badge](https://img.shields.io/badge/Java-21-blue)](https://www.oracle.com/java/technologies/downloads/#java21)\n[![spring-boot-version-badge](https://img.shields.io/badge/Spring_Boot-3.2.5-green)](https://spring.io/projects/spring-boot)\n[![license-badge](https://img.shields.io/badge/License-MIT-yellow)](LICENSE)\n\n## About ShortLink\nShortLink is a URL-shortening service.\n\n* [Quick Start](#quick-start)\n  * [Run as Spring Application](#run-as-spring-app)\n  * [Using the ShortLink Service](#using-the-shortlink-service)\n  * [Run Unit Tests](#run-unit-test)\n  * [Run as Docker Container](#run-as-docker-container)\n  * [Viewing the API Documentation](#api-documentaion)\n* [Additional Design Considerations](#design-considerations)\n* [Built With](#frameworks)\n* [Project Links](#project-links)\n\n## Quick Start \u003ca name=\"quick-start\"\u003e\u003c/a\u003e\n\n### Run as Spring Application \u003ca name=\"run-as-spring-app\"\u003e\u003c/a\u003e\nThis section guides developers on launching the ShortLink URL-shortening service as a standalone Spring application.\n\n**Prerequisites:**\n\n* Git installed on your system\n* Java Development Kit (JDK) 11 or above\n\n**Steps:**\n1. **Clone the Project:**\n```bash\ngit clone git@github.com:emmanuel-owusu/shortlink.git\n```\n2. **Build and Run the Application:**\n\nNavigate to the project root directory and execute the following command:\n```bash\n./gradlew bootRun\n```\nThis command downloads dependencies, builds the application, and starts it as a Spring Boot application.\n\n3. **Verify Application Health (Optional):**\n  \nOnce the application starts, you can verify its health using a tool like CURL:\n\n```bash\ncurl http://localhost:8080/actuator/health\n```\nA successful response indicates the application is running properly.\n```json\n{\n  \"status\": \"UP\"\n}\n```\n\nFollow the steps in the '[Using the ShortLink Service](#using-the-shortlink-service)' section for more details on using the service once it's running.\n\n### Using the ShortLink Service \u003ca name=\"using-the-shortlink-service\"\u003e\u003c/a\u003e\n\nThe ShortLink service exposes two main functionalities:\n* **Encoding URLs (Shortening)**:\n    * The `/service/shortlink/encode` endpoint accepts a URL as a query parameter named `url`.\n    * The request should use URL encoding for the `url` parameter.\n\n**Example Encode Request:**\n```bash\ncurl --get --data-urlencode \"url=https://en.wikipedia.org/wiki/Astronomy\" http://localhost:8080/service/shortlink/encode\n```\n\n**Example Encode Response (JSON):**\n```json\n{\n  \"data\": {\n    \"original_url\": \"https://en.wikipedia.org/wiki/Astronomy\",\n    \"short_url\": \"http://short.link/000000\"\n  },\n  \"message\": \"URL shortened successfully.\",\n  \"status\": \"success\"\n}\n```\n* **Decoding URLs (Expanding):**\n    * The `/service/shortlink/decode` endpoint accepts a shortened URL as a query parameter named `url`.\n    * The request should use URL encoding for the `url` parameter.\n\n**Example Decode Request:**\n\n```bash\ncurl --get --data-urlencode \"url=http://short.link/000000\" http://localhost:8080/service/shortlink/decode\n```\n\n**Example Decode Response (JSON):**\n\n```json\n{\n  \"data\": {\n    \"original_url\": \"https://en.wikipedia.org/wiki/Astronomy\",\n    \"short_url\": \"http://short.link/000000\"\n  },\n  \"message\": \"original URL retrieved successfully.\",\n  \"status\": \"success\"\n}\n```\n**Additional Notes:**\n\n* Replace http://short.link/000000 with the actual shortened URL returned by the service in your responses.\n\n### Run Unit Tests \u003ca name=\"run-unit-test\"\u003e\u003c/a\u003e\nThis project uses JUnit for unit testing. To run the tests, follow these steps:\n\n1. **Prerequisites:**\n* Ensure you have Java installed and configured on your system. You can verify this by running `java -version` in your terminal.\n* Make sure you have Gradle set up for dependency management.\n\n2. **Run Tests:**\n\n* Open a terminal and navigate to your project directory.\n* Run `gradle test`:\n\n```bash\n./gradlew test\n```\n\n3. **View Results:**\n* The test results will be displayed in the terminal, indicating successful or failed tests and any associated error messages.\n* To view the HTML test result files, navigate to: `path_to_your_project/module_name/build/reports/tests/` directory.\n\n### Run as Docker Container \u003ca name=\"run-as-docker-container\"\u003e\u003c/a\u003e\nHere's how to quickly build and run the ShortLink URL-shortening service in a Docker container:\n\n**Prerequisites:**\n\n* Docker installed on your system \n  * Install: https://www.docker.com/products/docker-desktop/\n  * Check if installed: `docker --version`\n* Git installed on your system\n  * Install: https://git-scm.com/downloads\n  * Check if installed: `git --version`\n\n**Steps:**\n\n1. **Clone the Project:**\n```bash\ngit clone git@github.com:emmanuel-owusu/shortlink.git\n```\n\n2. **Navigate to the Project Directory:**\n\nNavigate to the project root directory and execute the following command:\n```bash\ncd shortlink\n```\n\n3. **Build the Docker Image**:\nThis builds a Docker image named `shortlink` based on the included Dockerfile:\n```bash\ndocker build -t shortlink .\n```\n\n4. **Run the Application:**\n\nThis starts a container from the shortlink image, exposes port 8080, and runs the application in the background:\n\n```bash\ndocker run -d --name shortlink_container -p 8080:8080 shortlink\n```\n\n5. **Verify Application Health (Optional):**\nOnce the container is running, you should be able to access the ShortLink service through your web browser at http://localhost:8080/actuator/health.\n\nA successful response indicates the application is running properly.\n```json\n{\n  \"status\": \"UP\"\n}\n```\nFollow the steps in the '[Using the ShortLink Service](#using-the-shortlink-service)' section for more details on using the service once it's running.\n\n### Viewing the API Documentation \u003ca name=\"api-documentaion\"\u003e\u003c/a\u003e\nThis API provides an interactive Swagger UI for exploring available endpoints and their details. To access the documentation:\n\n1. **Start the Application:** Ensure your Spring application is running.\n2. **Open the Swagger UI:** Navigate to http://localhost:8080/swagger-ui/index.html in your web browser, replacing port `8080` with the port your application is running on (usually 8080 by default).\n\nThe Swagger UI will display a comprehensive view of your API, including:\n\n* **List of Endpoints:** Explore all available API endpoints with clear descriptions.\n* **Detailed Information:** View detailed information for each endpoint, including request parameters, response structures, and supported HTTP methods.\n* **Interactive Testing:** The UI allows you to directly test API calls with various parameters and view the corresponding responses.\n\n\nThis interactive documentation should provide a clear understanding of how to interact with the API and its functionalities.\n\n## Additional Design Considerations \u003ca name=\"design-considerations\"\u003e\u003c/a\u003e\nThis is a simple implementation for demonstration purposes. For a production-ready URL shortener, consider:\n\n* Persistence \u0026 Scalability: Store URL mappings in a scalable database like MySQL or Redis for high availability.\n* Conflict Resolution: Implement strategies like adding random characters to the shortcode to handle collisions during generation.\n* Security:\n  * Validate user input to prevent malicious URLs.\n  * Implement rate limiting to avoid abuse.\n  * Consider password protection for managing shortened links (optional).\n\n## Built With \u003ca name=\"frameworks\"\u003e\u003c/a\u003e\n* [Spring Boot 3.2.5 with Spring Web](https://start.spring.io/#!type=gradle-project\u0026language=java\u0026platformVersion=3.2.5\u0026packaging=jar\u0026jvmVersion=21\u0026groupId=com.github.emmanuel-owusu\u0026artifactId=shortlink\u0026name=ShortLink\u0026description=ShortLink%20is%20a%20URL%20shortening%20service\u0026packageName=com.github.emmanuel-owusu.shortlink\u0026dependencies=web)\n* [Java 21](https://www.oracle.com/java/technologies/downloads/#java21)\n* [OpenAPI Specification (OAS) / Swagger](https://www.openapis.org/)\n* [Docker](https://www.docker.com/)\n\n[![Frameworks:java](https://skillicons.dev/icons?i=java)](https://www.oracle.com/java/)\n[![Frameworks:spring](https://skillicons.dev/icons?i=spring)](https://spring.io/)\n[![Frameworks:docker](https://skillicons.dev/icons?i=docker)](https://www.docker.com/)\n\n## Project Links \u003ca name=\"project-links\"\u003e\u003c/a\u003e\n* Author Profile - [github.com/emmanuel-owusu](https://github.com/emmanuel-owusu)\n* Code Repository - [https://github.com/emmanuel-owusu/shortlink](https://github.com/emmanuel-owusu/shortlink)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femmanuel-owusu%2Fshortlink","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femmanuel-owusu%2Fshortlink","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femmanuel-owusu%2Fshortlink/lists"}