{"id":24142080,"url":"https://github.com/sekuldev/url-shortener","last_synced_at":"2026-04-09T18:36:58.754Z","repository":{"id":269752506,"uuid":"840543433","full_name":"SekulDev/url-shortener","owner":"SekulDev","description":"Simple URL Shortener with advanced architecture","archived":false,"fork":false,"pushed_at":"2024-12-25T21:23:07.000Z","size":93,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-12T04:55:23.559Z","etag":null,"topics":["clean-architecture","clean-code","docker","docker-compose","go","golang","htmx","htmx-go","integration-testing","load-balancer","mongodb","mongodb-cluster","nginx","redis","redis-cache","scalability","unit-testing","url-shortener"],"latest_commit_sha":null,"homepage":"","language":"Go","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/SekulDev.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-08-10T00:57:18.000Z","updated_at":"2024-12-25T21:23:10.000Z","dependencies_parsed_at":"2024-12-27T17:16:10.688Z","dependency_job_id":null,"html_url":"https://github.com/SekulDev/url-shortener","commit_stats":null,"previous_names":["sekuldev/url-shortener"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SekulDev%2Furl-shortener","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SekulDev%2Furl-shortener/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SekulDev%2Furl-shortener/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SekulDev%2Furl-shortener/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SekulDev","download_url":"https://codeload.github.com/SekulDev/url-shortener/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241368925,"owners_count":19951666,"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":["clean-architecture","clean-code","docker","docker-compose","go","golang","htmx","htmx-go","integration-testing","load-balancer","mongodb","mongodb-cluster","nginx","redis","redis-cache","scalability","unit-testing","url-shortener"],"created_at":"2025-01-12T04:55:28.114Z","updated_at":"2026-04-09T18:36:53.709Z","avatar_url":"https://github.com/SekulDev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# URL-SHORTENER\n\n## ABOUT\n\nA sophisticated URL shortener service built with modern technologies and scalability in mind. While URL shorteners might seem simple, this project serves as a playground for implementing advanced infrastructure, clean architecture, and exploring new technologies.\n\n## Tech Stack \u0026 Why I Chose It\n\n-   **Golang:** After hearing praise about Go's simplicity and performance, I had to try it myself. Its concurrency model and standard library are fantastic for building web services.\n-   **HTMX \u0026 GoTemplates:** After years of building JavaScript-heavy frontends, the simplicity of HTMX is refreshing. It's amazing how much you can achieve with so little code.\n-   **MongoDB:** I chose Mongo for its scaling capabilities. Running it in a cluster configuration with replica sets gives us:\n    -   A leader instance handling writes (which are less frequent in our case)\n    -   Multiple read replicas to handle the more common read operations\n    -   Easy horizontal scaling when needed\n-   **Redis:** Using for:\n    -   Caching shortened URLs to reduce database load\n    -   Managing rate limiting (more on that below)\n    -   Ensuring our application servers remain stateless for better scaling\n\n## Architecture Overview\n\nThis project follows Clean Architecture principles and is designed with scalability and business requirements in mind. I may not have achieved a perfect implementation, but i will make some improvements in free time\n\n### Infrastructure\n\nThe application itself can be scaled horizontally, with handling load balancing (for example nginx). This setup allows us to:\n\n-   Add more application instances during high load\n-   Perform zero-downtime deployments\n-   Handle failover scenarios gracefully\n\nMongoDB Cluster with replica-set ensures we can handle high read loads (which is the primary operation in a URL shortener) while maintaining data consistency.\n\n### URL Shortening Process\n\n1. **User Authentication \u0026 Security**\n\n    - Google ReCaptcha v2 integration to prevent automated access\n    - IP-based rate limiting (1 URL per 10 minutes)\n\n2. **URL Generation Strategy**\n\n    - Uses SnowflakeID converted to Base62 for generating short URLs\n    - Chosen for:\n\n        - Optimal length of generated URLs\n        - High performance compared to cryptographic functions\n        - Better scalability than auto-increment\n        - More efficient than recursive random ID generation\n\n3. **Data Flow**\n\n    - New URLs are permanently stored in MongoDB\n    - Generated short URLs are cached in Redis\n\n### Redirection Flow\n\n1. Check Redis cache first\n2. On cache miss, query MongoDB\n3. Cache the result in Redis\n4. Perform a 301 redirect (enables browser-side caching)\n\n## Running locally\n\n1. **Clone the repo**\n\n```bash\ngit clone https://github.com/SekulDev/url-shortener.git\n```\n\n2. **Set up your environment variables**\n\n    - Copy `./config/.env.dev.example` to `./config/.env.dev`\n    - Fill in your configuration values\n\n3. **Run**\n\n```bash\ndocker compose -f ./docker-compose.dev.yaml --env-file ./config/.env.dev up\n```\n\n## Project status\n\n**⚠️ Note:** As the only one developer, I opted to commit directly to main, as implementing a more complex branching strategy wouldn't provide significant benefits for a project of this size.\n\nIn the project there are some areas for improvement:\n\n-   Missing integrational / E2E tests, some unit tests are need improvement\n-   Code refactoring in specific areas\n-   Documentation improvements\n\nFeedback is welcome through GitHub Issues!\n\n## Learning Outcomes\n\nThis project served as an excellent learning experience for:\n\n-   Working with Clean Architecture\n-   Implementing scalable infrastructure\n-   Building business-oriented solutions\n-   Web services in Go\n\nThese technologies and methodologies have proven valuable and will definitely be utilized in future projects.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsekuldev%2Furl-shortener","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsekuldev%2Furl-shortener","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsekuldev%2Furl-shortener/lists"}