{"id":18135399,"url":"https://github.com/avaterclasher/zexd-backend","last_synced_at":"2026-04-11T05:32:58.366Z","repository":{"id":259731831,"uuid":"879303620","full_name":"AvaterClasher/zexd-backend","owner":"AvaterClasher","description":"A backend of a url shortner written in Golang.","archived":false,"fork":false,"pushed_at":"2024-11-05T21:04:03.000Z","size":327,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T16:49:22.317Z","etag":null,"topics":["api","backend","docker","docker-compose","docker-container","docker-image","dockerfile","dragonflydb","go","golang","grafana","mux-router","postgresql","prometheus","rest","rest-api","url-shortener"],"latest_commit_sha":null,"homepage":"https://zexd.onrender.com/swagger/index.html","language":"Go","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/AvaterClasher.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-10-27T14:59:14.000Z","updated_at":"2024-11-06T17:48:09.000Z","dependencies_parsed_at":"2025-02-12T22:46:14.627Z","dependency_job_id":null,"html_url":"https://github.com/AvaterClasher/zexd-backend","commit_stats":null,"previous_names":["avaterclasher/zexd","avaterclasher/zexd-backend"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AvaterClasher/zexd-backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AvaterClasher%2Fzexd-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AvaterClasher%2Fzexd-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AvaterClasher%2Fzexd-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AvaterClasher%2Fzexd-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AvaterClasher","download_url":"https://codeload.github.com/AvaterClasher/zexd-backend/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AvaterClasher%2Fzexd-backend/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260673693,"owners_count":23044990,"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","backend","docker","docker-compose","docker-container","docker-image","dockerfile","dragonflydb","go","golang","grafana","mux-router","postgresql","prometheus","rest","rest-api","url-shortener"],"created_at":"2024-11-01T14:07:09.225Z","updated_at":"2025-12-30T21:07:25.146Z","avatar_url":"https://github.com/AvaterClasher.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ZEXD - URL Shortening Service\n\n**ZEXD** is a URL shortening service designed for speed along with reliability, scalability, and monitoring in mind. This project uses a Go-based backend, with PostgreSQL as the database, DragonflyDB for caching, and integrated monitoring via Prometheus and Grafana.\n\n## Features\n\n- URL shortening and redirection having a average response time of 2ms for creation and 1ms for redirection.\n- Click tracking and analytics for shortened URLs\n- URL expiration management (default: 24 hours)\n- Health monitoring with Prometheus and Grafana dashboards\n- API documentation via Swagger UI\n\n## Benchmarks\n\nThe performance of ZEXD was tested using the [k6](https://k6.io/) load testing tool. The tests were run on a Lenovo Ideapad Flex 5 with an 11th Gen Intel Core i7 processor and 16GB of RAM.\n\n- Tests for Url Creation\n  - Test 1\n    - 1 VU for 30 seconds\n    - 16519 requests\n    - Avg. response time: 1.71ms\n  - Test 2\n    - 100 VU for 2 minutes\n    - 253477 requests\n    - Avg. response time: 47.19ms\n  - Test 3\n    - 200 VU for 2 minutes\n    - 330481 requests\n    - Avg. response time: 72.48ms\n  - Test 4\n    - 1000 VU for 2 minutes\n    - 324233 requests\n    - Avg. response time: 369.2ms\n\n- Tests for Url Redirection\n  - Test 1\n    - 1 VU for 30 seconds\n    - 25053 requests\n    - Avg. response time: 1.09ms\n  - Test 2\n    - 100 VU for 2 minutes\n    - 170563 requests\n    - Avg. response time: 12.39ms\n  - Test 3\n    - The server was not able to handle the load of 200 VUs for 2 mins.\n\nSee the [benchmark results](loadtesting/benchmark.md) for the performance of ZexD.\n\n## Prerequisites\n\nMake sure you have the following installed:\n\n- **Docker** and **Docker Compose**\n- **Go 1.23** or later (optional, if you wish to run or develop outside Docker)\n\n## Getting Started\n\n### Cloning the Repository\n\n```bash\ngit clone https://github.com/AvaterClasher/zexd-backend.git\ncd zexd-backend\n```\n\n### Environment Variables\n\nCreate an `.env` file in the root directory based on the `.env.example` provided:\nChange with whatever DB or redis service you are using if not using docker compose.\n\n```bash\nDB_HOST=postgres\nDB_PORT=5432\nDB_USER=zexd\nDB_PASSWORD=zexd\nDB_NAME=zexd_db\nDB_SSL=disable\nTABLE_NAME=shortened_url # dont change this\nEXPIRY_TIME=1440  # Expiration time in minutes\nREDIS_DOMAIN=redis://user@dragonflydb:6379/\nSERVER_DOMAIN=http://localhost:8080/\n```\n\n### Docker Compose Setups\n\n#### Local Development\n\nThis setup is for local development and testing. Any changes made to the code will be reflected here.\nThe environment variables are already set in the docker compose file.\nTo start the service in a local development environment, use:\n\n```bash\ndocker-compose -f compose.local.yml up --build\n```\n\n#### Production Setup\n\nThis uses a pre-built image from Docker Hub. This setup is for production use.\nThe environment variables are already set in the docker compose file.\nFor a production-ready setup:\n\n```bash\ndocker-compose -f compose.prod.yml up -d --build\n```\n\nThis setup configures all services (backend, PostgreSQL, DragonflyDB, Prometheus, and Grafana) with production-level configurations.\n\n### Running the Containers Individually\n\nIf you want to run the services independently, here are some examples:\n\n#### Backend (ZEXD)\n\n```bash\ndocker run -p 8080:8080 --env-file .env avaterclasher/zexd-backend:v1\n```\n\n### Swagger API Documentation\n\n- **Production**: Hosted Swagger documentation is available at [https://zexd.onrender.com/swagger/index.html](https://zexd.onrender.com/swagger/index.html)\n- **Local**: Once the service is running locally, access Swagger documentation at [http://localhost:8080/swagger/index.html](http://localhost:8080/swagger/index.html).\n\n## Monitoring with Prometheus and Grafana\n\nThis project uses Prometheus and Grafana for monitoring. When started, these services will be available at:\n\n- **Prometheus**: [http://localhost:9090](http://localhost:9090)\n- **Grafana**: [http://localhost:3000](http://localhost:3000)\n\nTo log into Grafana, use:\n\n- **Username**: `admin`\n- **Password**: `admin`\n\nYou can find the Grafana dashboard JSON file in `grafana_dashboard.json` for pre-configured metrics related to this project.\n\n## Dockerfile Information\n\nThe Dockerfile is a multi-stage build with two stages:\n\n1. **Builder**: Builds the Go application.\n2. **Alpine**: Copies the compiled application and runs it on a minimal Alpine image for lightweight production usage.\n\n### Build and Run Manually\n\nTo build and run the image manually:\n\n```bash\ndocker build -t zexd-backend .\ndocker run -p 8080:8080 --env-file .env zexd-backend\n```\n\n## API Endpoints\n\nThe API endpoints are as follows:\n\n| Method | Endpoint | Body | Description |\n| --- | --- | --- | --- |\n| POST | /api/create | {\"url\": \"https://www.youtube.com\", \"user_id\": \"user1\"} | Generates a shortened URL |\n| POST | /api/delete | {\"url\": \"https://www.youtube.com\"} | Deletes the shortened URL |\n| GET | /api/list/{user_id} || Returns the urls of the user |\n| GET | /{shortened_url} || Redirects to the original URL |\n| GET | /health || Returns the health status of the server |\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request if you have any suggestions or improvements.\n\n## Maintainer\n\n- Github: [Avater Clasher](https://github.com/AvaterClasher)\n- Linkedin: [Soumyadip Moni](https://www.linkedin.com/in/soumyadip-moni/)\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favaterclasher%2Fzexd-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favaterclasher%2Fzexd-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favaterclasher%2Fzexd-backend/lists"}