{"id":23970587,"url":"https://github.com/ahmed122000/url_shortener","last_synced_at":"2026-04-13T13:04:54.859Z","repository":{"id":269496942,"uuid":"903218095","full_name":"Ahmed122000/URL_Shortener","owner":"Ahmed122000","description":"SAH Shortener is a URL-shortening website that provides users with a simple and efficient way to shorten and manage URLs. Built with a lightweight front-end and a robust Java Spring Boot back-end, the system ensures idempotency and handles hash collisions effectively.","archived":false,"fork":false,"pushed_at":"2025-02-05T00:21:52.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-05T01:24:01.734Z","etag":null,"topics":["api","css","html","java","javascript","jpa","jpa-hibernate","mysql","rest-api","spring-boot"],"latest_commit_sha":null,"homepage":"https://url-shortener-bice-xi.vercel.app","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ahmed122000.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-12-14T02:56:57.000Z","updated_at":"2025-02-05T00:36:53.000Z","dependencies_parsed_at":"2024-12-24T02:19:37.667Z","dependency_job_id":"491d8aa6-fb50-41db-b1f4-595707447015","html_url":"https://github.com/Ahmed122000/URL_Shortener","commit_stats":null,"previous_names":["ahmed122000/url_shortener"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ahmed122000%2FURL_Shortener","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ahmed122000%2FURL_Shortener/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ahmed122000%2FURL_Shortener/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ahmed122000%2FURL_Shortener/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ahmed122000","download_url":"https://codeload.github.com/Ahmed122000/URL_Shortener/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240500195,"owners_count":19811555,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["api","css","html","java","javascript","jpa","jpa-hibernate","mysql","rest-api","spring-boot"],"created_at":"2025-01-07T02:07:30.123Z","updated_at":"2026-04-13T13:04:49.807Z","avatar_url":"https://github.com/Ahmed122000.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SAH Shortener\n\nSAH Shortener is a URL-shortening website that enables users to convert long URLs into short, manageable links. The project is built with a clean separation between the front-end and back-end for optimal performance and maintainability. It now includes Docker support for easy deployment and has been deployed on Render (back-end) and Vercel (front-end).\n\n## Features\n\n### Front-End\n- **HTML**: Provides the structure and skeleton of the web page.\n- **CSS**: Adds styling for an appealing user interface.\n- **JavaScript**: Handles user interactions, sends requests to the server, and updates the UI dynamically.\n\n### Back-End\n- **Java Spring Boot**: Serves as the core framework for the back-end.\n- **MySQL**: Used for persistent storage of URLs.\n- **JPA Repository**: Facilitates database operations.\n- **Service Layer**: Connects the controller with the repository for a clean architecture.\n\n## API Endpoints\n\n### 1. **POST /api/url**\n   - **Description**: Shortens a given URL and saves it in the system.\n   - **Request Body**:\n     ```Raw String:\n       https://example.com     \n     ```\n   - **Response**:\n     ```json\n     {\n       \"urlKey\": \"abc123\",\n       \"fullUrl\": \"https://example.com\",\n       \"shortUrl\": \"http://localhost:8080/api/abc123\"\n     }\n     ```\n\n### 2. **GET /api/{key}**\n   - **Description**: Redirects to the original URL using the short URL key.\n   - **Response**:\n      - **302 FOUND**: Redirects to the full URL if the key is valid.\n      - **404 NOT FOUND**:the page is not found .\n\n### 3. **DELETE /api/{key}**\n   - **Description**: Deletes a URL mapping from the system (admin only).\n   - **Response**:\n     - **200 OK**: URL deleted successfully.\n     - **404 NOT FOUND**: URL key not found.\n\n\n## Technical Details\n- The system uses SHA-256 hashing to generate unique keys for URLs.\n- To handle hash collisions, the key length increases dynamically.\n- The back-end ensures that duplicate URLs are not stored by checking for existing entries before saving.\n- Idempotency is a key feature, ensuring that the same input URL always results in the same short URL.\n\n## Getting Started\n\n### Prerequisites\n- Java Development Kit (JDK) 17+\n- MySQL Database\n- Docker (optional for containerized deployment)\n- Docker comopse (optional for multi-container setup)\n\n### Installation\n\n#### Clone the Repository\n```bash\n$ git clone https://github.com/yourusername/SAH-Shortener.git\n$ cd SAH-Shortener\n```\n#### Docker Setup\n1. Build and Run with Docker compose\n   1. Navigate to the project root directory\n   2. Update the `docker-compose.yml` file with your environment variables:\n     - `DATABASE_URL`: MySQL database url (e.g., `jdbc:mysql://mysql-db:3306/URLs`).\n     - `DATABASE_USERNAME`: MySQL username.  \n     - `DATABASE_PASSWORD`: MySQL password.\n     - `CURRENT_DOMAIN`: Domain for the server (e.g., `http://localhost:8080/api`).\n     - `MYSQL_ROOT_PASSWORD`: MySQL root password. \n     - `MYSQL_DATABASE`: MySQL database name. \n     - `MYSQL_USER`: MySQL user (optional)\n     - `MYSQL_PASSWORD`: MySQL user password (optional)\n   3. Run Docker Compose:\n      ```bash\n      $ docker-compose up --build\n      ```\n   this will start the backend, front-end, and MySQL database containers\n\n#### Manual Setup (Without Docker)\n**Back-End Setup**\n1. Configure MySQL:\n   - Create a database named `URLs`.\n   - Use the provided SQL script in the `database` folder to set up the schema.\n\n2. Run the Spring Boot application:\n   ```bash\n   $ ./mvnw spring-boot:run\n   ```\n\n**Front-End Setup**\n1. Open the `index.html` file in a browser.\n2. Ensure the back-end server is running to test the full functionality.\n\n## Usage\n- Use the main page to input long URLs and receive shortened URLs.\n- Access the short URL to redirect to the original page.\n- Admin users can delete URLs via the delete API.\n\n## Acknowledgments\nThis project was inspired by the [Coding Challenges](https://codingchallenges.fyi/challenges/challenge-url-shortener).\n\n---\n\nHappy shortening!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmed122000%2Furl_shortener","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahmed122000%2Furl_shortener","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmed122000%2Furl_shortener/lists"}