{"id":21068447,"url":"https://github.com/prajjwalyd/linkloom","last_synced_at":"2026-04-09T18:03:49.418Z","repository":{"id":248242366,"uuid":"820534226","full_name":"prajjwalyd/LinkLoom","owner":"prajjwalyd","description":"LinkLoom🔗 is a microservice application designed to manage URLs, providing URL shortening, QR code generation, analytics logging, and an integrated API service.","archived":false,"fork":false,"pushed_at":"2024-07-14T20:22:31.000Z","size":76,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-20T21:37:38.653Z","etag":null,"topics":["devops","flask","golang","kubernetes","microservice","microservices","minikube","monitoring"],"latest_commit_sha":null,"homepage":"","language":"Python","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/prajjwalyd.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-06-26T16:56:41.000Z","updated_at":"2024-07-14T20:22:34.000Z","dependencies_parsed_at":"2024-07-13T11:31:02.427Z","dependency_job_id":"9042b4da-a616-44b0-a485-72ca2fc0a1f9","html_url":"https://github.com/prajjwalyd/LinkLoom","commit_stats":null,"previous_names":["prajjwalyd/linkloom"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prajjwalyd%2FLinkLoom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prajjwalyd%2FLinkLoom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prajjwalyd%2FLinkLoom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prajjwalyd%2FLinkLoom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prajjwalyd","download_url":"https://codeload.github.com/prajjwalyd/LinkLoom/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243510056,"owners_count":20302296,"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":["devops","flask","golang","kubernetes","microservice","microservices","minikube","monitoring"],"created_at":"2024-11-19T18:21:15.681Z","updated_at":"2025-12-27T22:23:36.835Z","avatar_url":"https://github.com/prajjwalyd.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LinkLoom🔗\n\nLinkLoom is a microservice application designed to manage URLs, providing URL shortening, QR code generation, analytics logging, and an integrated API service. The 4 microservices (1. URL Shortener, 2. QR Code Generator, 3. Analytics, and 4. API) are loosely coupled, and the application is deployed on a local Kubernetes cluster using Minikube (for now). Helm is utilized to manage deployments of MongoDB and PostgreSQL, alongside Prometheus and Grafana for monitoring purposes. CI/CD pipeline is implemented using GitHub Actions to automate build, test, and deployment processes.\n\n🎥 Watch the full project setup here: https://youtu.be/UUu3EVSBkLc\n\n[![Tech Stack](https://skillicons.dev/icons?i=flask,python,go,postgres,mongodb,githubactions,docker,k8s,prometheus,grafana)](https://skillicons.dev)\n\n## Architecture Overview:\n```mermaid\ngraph LR\n        A1[User]\n    \n    subgraph \"LinkLoom Application\"\n        A[API Service]\n        B[URL Shortener Service]\n        C[QR Code Generator Service]\n        D[Analytics Service]\n    end\n    \n    subgraph Databases\n        E[(PostgreSQL Analytics)]\n        F[(MongoDB URLs \u0026 QR Codes)]\n    end\n    \n    subgraph Monitoring\n        G[Prometheus]\n    end\n\n    A1 --\u003e |HTTP Requests| A\n\n    A --\u003e |POST /create| B\n    A --\u003e |GET /qr/:short_url| C\n    A --\u003e |Log access on each redirection| D\n    A --\u003e |GET /:short_url/analytics| D\n    B --\u003e |Returns short_url| A\n    C --\u003e |Returns QR Code| A\n    D \u003c--\u003e |Stores/Fetches Logs for each short_url| E\n\n    D --\u003e |Returns analytics| A\n    \n\n    A \u003c--\u003e |Stores/Fetches Long URL, Short URL, QR Code| F\n\n    B --\u003e |/metrics| G\n    C --\u003e |/metrics| G\n    D --\u003e |/metrics| G\n    A --\u003e |/metrics| G\n\n    G --\u003e Grafana\n\n    style A fill:#f9f,stroke:#333,stroke-width:2px\n    style B fill:#f9f,stroke:#333,stroke-width:2px\n    style C fill:#f9f,stroke:#333,stroke-width:2px\n    style D fill:#f9f,stroke:#333,stroke-width:2px\n    style E fill:#bbf,stroke:#333,stroke-width:2px\n    style F fill:#bbf,stroke:#333,stroke-width:2px\n    style G fill:#bbf,stroke:#333,stroke-width:2px\n    style A1 fill:#afa,stroke:#333,stroke-width:2px\n\n```\n\n## Components:\n\n1. **URL Shortener Service** (Flask)\n   - **Description:** Provides functionality to shorten URLs, supporting custom short URLs.\n   - **Endpoint:** `/shorten`\n   - **Docker Image:** `docker.io/prajjwalyd/url-shortener`\n\n2. **QR Code Generator Service** (Golang)\n   - **Description:** Generates QR codes for given URLs.\n   - **Endpoint:** `/generate_qr`\n   - **Docker Image:** `docker.io/prajjwalyd/qr-code-generator`\n\n3. **Analytics Service** (Flask)\n   - **Description:** Logs analytics data (access time, IP, user agent, referrer) into a PostgreSQL database.\n   - **Endpoints:** \n     - `/log` (for logging access)\n     - `/\u003cshort_url\u003e/analytics` (to retrieve analytics for a given short URL)\n   - **Docker Image:** `docker.io/prajjwalyd/analytics`\n\n4. **API Service** (Flask)\n   - **Description:** Integrates all services, manages URL mappings and QR codes, stores data in MongoDB, and provides unified endpoints.\n   - **Endpoints:** \n     - `/create` (to create a shortened URL and optionally generate QR code)\n     - `/\u003cshort_url\u003e` (to redirect to the original long URL)\n        - It logs data whenever a short url is accessed by sending a POST request to the Analytics service. \n     - `/qr/\u003cshort_url\u003e` (to retrieve QR code)\n     - `/\u003cshort_url\u003e/analytics` (to fetch analytics data)\n   - **Docker Image:** `docker.io/prajjwalyd/api`\n\n**Prometheus Metrics Endpoint:** Each service exposes `/metrics`.\n\n5. **Databases**\n   - **MongoDB:** Stores URL mappings and QR codes.\n     - Helm Deployment: `my-mongo`\n   - **PostgreSQL:** Stores analytics data.\n     - Helm Deployment: `my-postgresql`\n\n6. **Monitoring**\n   - **Prometheus:** Collects metrics from each service.\n     - Helm Deployment: `prometheus`\n   - **Grafana:** Visualizes metrics and provides dashboards.\n     - Helm Deployment: `grafana`\n    \n\n\n## Setup and Deployment:\n\nFor the quickest and easiest way to get the app running, I recommend setting it up in a GitHub Codespace. \n\n\u003e **How to set up on Codespaces?**\n\u003e Watch this video: https://youtu.be/UUu3EVSBkLc\n\n\n#### Local Kubernetes Cluster Setup (Minikube):\n[Minikube installation guide](https://minikube.sigs.k8s.io/docs/start/)\n   ```\n   minikube start\n   ```\n\n#### Helm:\n[Helm installation guide](https://helm.sh/docs/intro/install/)\n```\nhelm repo add bitnami https://charts.bitnami.com/bitnami\nhelm repo add prometheus-community https://prometheus-community.github.io/helm-charts\nhelm repo add grafana https://grafana.github.io/helm-charts\nhelm repo update\n```\n\n#### Deploy Databases:\n```\nhelm install my-mongo bitnami/mongodb --set auth.rootPassword=example,auth.username=root,auth.password=example,auth.database=url_db\nhelm install my-postgresql bitnami/postgresql -f values.yaml\n```\n\n#### Deploy Services:\nApply Kubernetes manifests (`k8s/` directory)\n```\nkubectl apply -f k8s\n```\n\n#### Deploy Prometheus and Grafana:\n```\nhelm install prometheus prometheus-community/prometheus -f prometheus.yml\nhelm install grafana grafana/grafana\n```\n\n#### Verify Deployment:\n```\nkubectl get pods\nkubectl get svc\n```\n\n#### Access Prometheus and Grafana:\n- Forward ports:\n    ```\n    kubectl port-forward deploy/prometheus-server 9090\n    kubectl port-forward deploy/grafana 3000\n    ```\n- Prometheus: `http://localhost:9090`\n- Grafana: `http://localhost:3000`\n    Login with username `admin` and retrieve your password using:\n    ```\n    kubectl get secret --namespace default grafana -o jsonpath=\"{.data.admin-password}\" | base64 --decode ; echo\n    ```\n\n#### Set Up Grafana Data Source:\nAdd Prometheus data source in Grafana with URL `http://prometheus-server.default.svc.cluster.local:80`\n\n#### Import Dashboard:\nImport the provided [JSON dashboard](https://github.com/prajjwalyd/LinkLoom/blob/main/LinkLoom-grafana.json) file for metrics visualization.\n\n\n## Testing Endpoints:\n- Find your Minikube IP:\n```\nminikube ip\n```\n- Expose the API service:\n```\nkubectl port-forward service/api 30000:5000\n```\n- curl commands:\n```\n# Replace `http://192.168.49.2` with your minikube IP\n\n# Creating a short url:\ncurl http://192.168.49.2:30000/create -X POST -H \"Content-Type: application/json\" -d '{\"long_url\": \"http://example.com\"}'\n\n# Crating a custom short url:\ncurl -X POST http://192.168.49.2:30000/create -H \"Content-Type: application/json\" -d '{\"long_url\": \"https://example.com\", \"custom_url\": \"mycustomurl\"}'\n\n# Creating a short url with QR Code:\ncurl -X POST http://192.168.49.2:30000/create -H \"Content-Type: application/json\" -d '{\"long_url\": \"https://example.com\", \"custom_url\": \"custom123\", \"generate_qr\": true}'\n\n# Retreive the QR Code and save it as PNG:\ncurl -X GET http://192.168.49.2:30000/qr/custom123 --output qr_code.png\n\n# Test the redirection\ncurl -L http://192.168.49.2:30000/custom123\n\n# Access the analytics\ncurl -X GET http://192.168.49.2:30000/custom123/analytics\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprajjwalyd%2Flinkloom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprajjwalyd%2Flinkloom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprajjwalyd%2Flinkloom/lists"}