{"id":48242721,"url":"https://github.com/botsarefuture/shorturl","last_synced_at":"2026-04-04T20:20:15.542Z","repository":{"id":257264927,"uuid":"857767927","full_name":"botsarefuture/shorturl","owner":"botsarefuture","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-19T09:13:17.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-19T09:36:41.172Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/botsarefuture.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-09-15T15:05:21.000Z","updated_at":"2025-03-19T09:13:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"70d3c572-7c86-4b7a-9c0a-cd816da1db60","html_url":"https://github.com/botsarefuture/shorturl","commit_stats":null,"previous_names":["botsarefuture/shorturl"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/botsarefuture/shorturl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botsarefuture%2Fshorturl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botsarefuture%2Fshorturl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botsarefuture%2Fshorturl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botsarefuture%2Fshorturl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/botsarefuture","download_url":"https://codeload.github.com/botsarefuture/shorturl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/botsarefuture%2Fshorturl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31412480,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T20:09:54.854Z","status":"ssl_error","status_checked_at":"2026-04-04T20:09:44.350Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2026-04-04T20:20:15.419Z","updated_at":"2026-04-04T20:20:15.510Z","avatar_url":"https://github.com/botsarefuture.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# URL Shortener\n\nWelcome to the URL Shortener application—a professional web solution for transforming long URLs into concise, shareable links while tracking user engagement. This application is built with Flask for web routing and MongoDB for robust data management.\n\n## Overview\n\nThe URL Shortener integrates several key components to ensure efficiency, security, and analytical insight:\n\n- **Main Application**: Operates from `app.py` and manages URL shortening, Flask route configuration, user authentication, and event tracking.\n- **Database Management**: Utilizes MongoDB with a custom `DatabaseManager` that implements a singleton pattern to maintain a single client instance.\n- **User Authentication \u0026 Security**: \n    - Implements security features using `flask_autosec` to sanitize inputs.\n    - Manages user sessions and role validations via `flask_lac`.\n- **Analytics and Tracking**: Integrates Matomo API (found in `matomo.py`) to monitor events such as URL creation and redirection.\n\n## File Structure\n\nThe project is organized as follows:\n\n- **`app.py`**  \n    Main flask application with API endpoints and dashboard functionalities.\n\n- **`utils.py`**  \n    Contains utility functions for processing data (e.g., process_object_ids).\n\n- **`config.py`** \u0026 **`example.config.py`**  \n    Configuration files for setting up MongoDB connection parameters.\n\n- **`README.md`**  \n    This documentation file.\n\n- **`requirements.txt`**  \n    Lists the necessary Python packages for installation.\n\n- **`templates/`**  \n    Directory holding HTML templates such as `base.html`, `index.html`, `dashboard.html`, and `home.html`.\n\n- **`matomo.py`**  \n    Client integration for the Matomo analytics platform.\n\n## Installation\n\nFollow these simple steps to set up your environment:\n\n1. **Clone the Repository**  \n     Navigate to the workspace directory via terminal.\n     \n2. **Set Up a Virtual Environment (Recommended)**\n     ```\n     python3 -m venv venv\n     source venv/bin/activate\n     ```\n\n3. **Install Dependencies**\n     ```\n     pip install -r requirements.txt\n     ```\n\n## Configuration\n\nEstablish your environment by updating the configuration parameters:\n\n- **`config.py`**: Modify the file to reflect your MongoDB connection settings.\n- **Environment Variables**: Ensure the following variables are properly set:\n    - `SECRET_KEY`\n    - `MONGO_URI`\n    - `MATOMO_URL`\n    - `MATOMO_SITE_ID`\n\n## Running the Application\n\nLaunch the application with the following command:\n\n```\npython app.py\n```\n\nAccess the application via `http://0.0.0.0:5000/`.\n\n## API Endpoints\n\nDetailed API endpoints include:\n\n- **Create Short URL** (`/api/create`):  \n    Accepts a field: `_long_url`. This endpoint requires user authentication.\n    \n- **Dashboard** (`/dashboard`):  \n    Displays a summary of user-specific URLs along with click counts.\n    \n- **Redirect URL** (`/\u003cshort_hash\u003e`):  \n    Redirects to the corresponding long URL and logs the click event.\n    \n- **User URLs** (`/api/my-urls`):  \n    Retrieves URLs created by the authenticated user.\n    \n- **Admin URLs** (`/admin/urls`):  \n    Accessible only by users with elevated privileges.\n\n## Authentication \u0026 Security\n\nThis application uses a token-based authentication system with a signed serializer. Routes are protected using:\n- `@login_required` for basic authentication.\n- `@role_required` for role-based access control.\n\n## Additional Information\n\n- **Singleton Database Manager**:  \n    Uses a singleton pattern to maintain a single MongoDB client instance.\n    \n- **Comprehensive Event Tracking**:  \n    Leveraging Matomo for detailed analytics on URL creation, redirection, and other administrative events.\n\nFor further details or assistance, please refer to the documentation within each module.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbotsarefuture%2Fshorturl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbotsarefuture%2Fshorturl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbotsarefuture%2Fshorturl/lists"}