{"id":24912687,"url":"https://github.com/thanthtooaung-coding/url-shortener","last_synced_at":"2025-03-28T04:36:15.994Z","repository":{"id":274258111,"uuid":"922375723","full_name":"thanthtooaung-coding/url-shortener","owner":"thanthtooaung-coding","description":"Url Shortener with Spring Boot","archived":false,"fork":false,"pushed_at":"2025-01-26T03:34:22.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-02T05:28:21.500Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/thanthtooaung-coding.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":"2025-01-26T02:56:43.000Z","updated_at":"2025-01-26T03:34:25.000Z","dependencies_parsed_at":"2025-01-26T04:33:08.041Z","dependency_job_id":null,"html_url":"https://github.com/thanthtooaung-coding/url-shortener","commit_stats":null,"previous_names":["thanthtooaung-coding/url-shortener"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanthtooaung-coding%2Furl-shortener","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanthtooaung-coding%2Furl-shortener/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanthtooaung-coding%2Furl-shortener/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanthtooaung-coding%2Furl-shortener/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thanthtooaung-coding","download_url":"https://codeload.github.com/thanthtooaung-coding/url-shortener/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245972635,"owners_count":20702710,"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":[],"created_at":"2025-02-02T05:28:23.067Z","updated_at":"2025-03-28T04:36:15.973Z","avatar_url":"https://github.com/thanthtooaung-coding.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# URL Shortener with Spring Boot\n\n## Overview\nThis is a URL Shortener application built using **Spring Boot**, following a clean software architecture with best practices such as Layered Architecture, SOLID principles, and proper exception handling.\n\n## Features\n- Shorten long URLs into unique short URLs.\n- Retrieve original URLs using shortened versions.\n- Basic validation and error handling.\n- H2 in-memory database for development.\n- RESTful API with structured responses.\n\n---\n\n## Technologies Used\n- **Java 21**\n- **Spring Boot 3.4.2**\n    - Spring Web\n    - Spring Data JPA\n    - H2 Database\n    - Spring Security\n- **Maven**\n- **Lombok**\n\n---\n\n## Project Structure\n```\nurl.shortener/\n│-- src/main/java/com/url/shortener\n│   ├── UrlShortenerApplication.java\n│   ├── config/\n│   │   ├── SecurityConfig.java\n│   ├── controller/\n│   │   ├── UrlShortenerController.java\n│   ├── service/\n│   │   ├── UrlShortenerService.java\n│   │   ├── impl/\n│   │   │   ├── UrlShortenerServiceImpl.java\n│   ├── repository/\n│   │   ├── UrlRepository.java\n│   ├── domain/\n│   │   ├── Url.java\n│   ├── dto/\n│   │   ├── UrlRequestDto.java\n│   │   ├── UrlResponseDto.java\n│   ├── exception/\n│   │   ├── UrlNotFoundException.java\n│   │   ├── GlobalExceptionHandler.java\n│   ├── util/\n│   │   ├── HashingUtil.java\n│-- src/main/resources\n│   ├── application.yml\n└── pom.xml\n```\n\n---\n\n## Installation and Setup\n\n### Prerequisites\n- Install **Java 21**\n- Install **Maven**\n\n### Steps to Run the Application\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/thanthtooaung-coding/url-shortener.git\n   cd url-shortener\n   ```\n2. Build the project:\n   ```bash\n   mvn clean install\n   ```\n3. Run the application:\n   ```bash\n   mvn spring-boot:run\n   ```\n4. Access the API via:\n    - H2 Console: `http://localhost:8080/h2-console` (JDBC URL: `jdbc:h2:mem:urlshortenerdb`)\n\n---\n\n## API Endpoints\n\n### 1. Shorten URL\n**Endpoint:**\n```\nPOST /api/urls/shorten\n```\n**Request Body:**\n```json\n{\n  \"originalUrl\": \"https://www.example.com\"\n}\n```\n**Response:**\n```json\n{\n  \"shortUrl\": \"abc123\"\n}\n```\n\n### 2. Retrieve Original URL\n**Endpoint:**\n```\nGET /api/urls/{shortUrl}\n```\n**Response:**\n```json\n\"https://www.example.com\"\n```\n\n### 3. Invalid URL Handling\n**Response:**\n```json\n{\n  \"message\": \"Shortened URL not found\"\n}\n```\n\n---\n\n## Configuration\n\n**`application.yml` Example:**\n```yaml\nserver:\n  port: 8080\n\nspring:\n  datasource:\n    url: jdbc:h2:mem:urlshortenerdb\n    driver-class-name: org.h2.Driver\n    username: sa\n    password:\n  jpa:\n    hibernate:\n      ddl-auto: update\n    show-sql: true\n  h2:\n    console:\n      enabled: true\n      path: /h2-console\n      \nlogging:\n  level:\n    root: INFO\n    org.springframework: DEBUG\n\nshortener:\n  base-url: http://localhost:8080/\n  hash-length: 8\n```\n\n---\n\n## Testing\nTo test the application, you can use:\n- **Postman**: Create API requests to shorten and retrieve URLs.\n- **cURL**: Example usage:\n  ```bash\n  curl -X POST http://localhost:8080/api/urls/shorten -H \"Content-Type: application/json\" -d '{\"originalUrl\":\"https://www.example.com\"}'\n  ```\n\n---\n\n## Future Improvements\n- Integrate with Swagger UI for API documentation.\n- Add Redis caching for better performance.\n- Implement custom expiration for shortened URLs.\n- Develop a frontend using Vue.js or React.\n- Add user authentication for personalized URL tracking.\n\n---\n\n## License\nThis project is licensed under the [MIT License](LICENSE).\n\n---\n\n## Contact\nFor any queries, please contact [thanthtoo1285@gmail.com](mailto:thanthtoo1285@gmail.com).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthanthtooaung-coding%2Furl-shortener","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthanthtooaung-coding%2Furl-shortener","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthanthtooaung-coding%2Furl-shortener/lists"}