{"id":25627629,"url":"https://github.com/rekha0suthar/url-shorten","last_synced_at":"2026-06-18T02:31:20.950Z","repository":{"id":277501214,"uuid":"932618042","full_name":"rekha0suthar/url-shorten","owner":"rekha0suthar","description":"Simple url shortening application where you can give logn url and get short url which can be used instead long url.","archived":false,"fork":false,"pushed_at":"2025-02-27T08:32:45.000Z","size":305,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-13T02:03:47.000Z","etag":null,"topics":["context-api","expressjs","javascript","jwt-token","material-ui","mongodb-atlas","mongoose","oauth2","react-hooks","react-router","reactjs","toastify"],"latest_commit_sha":null,"homepage":"https://shortify-nu.vercel.app/","language":"JavaScript","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/rekha0suthar.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-02-14T08:00:45.000Z","updated_at":"2025-02-27T08:32:48.000Z","dependencies_parsed_at":"2025-11-13T02:02:46.862Z","dependency_job_id":null,"html_url":"https://github.com/rekha0suthar/url-shorten","commit_stats":null,"previous_names":["rekha0suthar/url-shorten"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rekha0suthar/url-shorten","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rekha0suthar%2Furl-shorten","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rekha0suthar%2Furl-shorten/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rekha0suthar%2Furl-shorten/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rekha0suthar%2Furl-shorten/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rekha0suthar","download_url":"https://codeload.github.com/rekha0suthar/url-shorten/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rekha0suthar%2Furl-shorten/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34474063,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-18T02:00:06.871Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["context-api","expressjs","javascript","jwt-token","material-ui","mongodb-atlas","mongoose","oauth2","react-hooks","react-router","reactjs","toastify"],"created_at":"2025-02-22T17:53:35.439Z","updated_at":"2026-06-18T02:31:20.941Z","avatar_url":"https://github.com/rekha0suthar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Shortify - URL Shortener Application\n\n## Table of Contents\n\n- [Overview](#overview)\n- [Features](#features)\n- [Technologies Used](#technologies-used)\n- [Demo](#demo)\n- [Getting Started](#getting-started)\n  - [Prerequisites](#prerequisites)\n  - [Installation](#installation)\n  - [Environment Variables](#environment-variables)\n  - [Running the Application](#running-the-application)\n- [API Documentation](#api-documentation)\n- [Folder Structure](#folder-structure)\n- [Contributing](#contributing)\n- [License](#license)\n- [Contact](#contact)\n- [Acknowledgements](#acknowledgements)\n\n## Overview\n\n**Shortify** is a professional and user-friendly URL shortening application designed to help users create, manage, and analyze short links effortlessly. Whether you're looking to share links on social media, track URL performance, or organize links by topics, Shortify provides a comprehensive solution.\n\n## Features\n\n- **Google Authentication:**\n\n  - Secure user login via Google accounts.\n  - Protects user data and URL history.\n\n- **URL Shortening:**\n\n  - Generate short URLs for any long URL.\n  - Option to create custom aliases for personalized short links.\n  - Categorize URLs by topics for better organization.\n\n- **URL History:**\n\n  - View a paginated list of all shortened URLs.\n  - Filter URLs based on topics.\n  - Access detailed analytics for each URL.\n\n- **Analytics Dashboard:**\n\n  - Overall analytics to monitor URL performance.\n  - Detailed insights for individual URLs, including click counts, geographical data, and user-agent information.\n\n- **Topic Analytics:**\n\n  - View analytics for URLs grouped by topics.\n  - Track performance of URLs by topic.\n\n- **Responsive Design:**\n\n  - Optimized for various devices and screen sizes.\n  - Intuitive and clean UI built with Material-UI.\n\n- **Theme Customization:**\n  - Modern color themes to match your brand or preference.\n\n## Technologies Used\n\n### Frontend\n\n- **React**: User interface library.\n- **Redux Toolkit**: State management library for React.\n- **Material-UI (MUI)**: UI component library for React.\n- **React Router DOM**: Routing library for React applications.\n- **Axios**: Promise-based HTTP client for browser and Node.js.\n- **React Toastify**: Notification library for React.\n- **Vite**: Fast frontend build tool.\n\n### Backend\n\n- **Node.js**: JavaScript runtime.\n- **Express.js**: Web framework for Node.js.\n- **MongoDB**: NoSQL database.\n- **Mongoose**: ODM for MongoDB.\n- **Nanoid**: Unique string ID generator.\n- **express-rate-limit**: Basic rate-limiting middleware for Express.\n- **UAParser.js**: User-Agent parser.\n- **geoip-lite**: Geolocation lookup library.\n\n## Demo\n\n[Shortify Demo](https://shortify-nu.vercel.app/) \u003c!-- Replace with actual demo GIF or screenshot --\u003e\n\n## Challenges Faced\n\n1. Short URL Redirect\n\n   \u003e Challenge: Implementing a short URL redirect proved to be tricky.\n\n   \u003e Solution: I initially attempted to solve it on my own. When I encountered difficulties, I turned to a YouTube tutorial which provided the guidance I needed.\n\n2. URLs Analytics\n\n   \u003e Challenge: Tracking and analyzing URL data was another hurdle.\n\n   \u003e Solution: I conducted online research and discovered several informative blog posts that helped me understand the analytics process and proceed with the implementation.\n\n3. Login only while creating a url\n\n   \u003e Challenge: I wanted to ensure that users are logged in only while creating a url.\n\n   \u003e Solution: I used the `useLocation` hook to get the state from the redirect and then used the `useAuth` hook to check if the user is logged in. If not, I redirected the user to the login page.\n\n4. Docker setup\n\n   \u003e Challenge: I never used docker before.\n\n   \u003e Solution: I read the documentation and followed the steps to setup the docker compose file.\n\n## Getting Started\n\n### Prerequisites\n\n- **Node.js** (v14 or later)\n- **npm** or **Yarn**\n- **MongoDB** instance (local or cloud-based)\n\n### Installation\n\n1. **Clone the Repository:**\n\n   ```bash\n   git clone https://github.com/rekha0suthar/url-shorten.git\n   cd url-shorten\n   ```\n\n2. **Install Backend Dependencies:**\n\n   ```bash\n   cd backend\n   npm install\n   # or\n   yarn install\n   ```\n\n3. **Install Frontend Dependencies:**\n\n   ```bash\n   cd ../frontend\n   npm install\n   # or\n   yarn install\n   ```\n\n## Docker setup\n\n1. **Build the Docker Images:**\n\n   ```bash\n   docker-compose build\n   ```\n\n2. **Start the Docker Containers:**\n\n   ```bash\n   docker-compose up -d\n   ```\n\n3. **Access the Application:**\n\n   Open your browser and navigate to `http://localhost:3000` to access Shortify.\n\n   \u003e **Note:**\n   \u003e\n   \u003e - The application will be available at `http://localhost:3000`.\n   \u003e - The backend will be available at `http://localhost:5000`.\n   \u003e - The MongoDB will be available at `http://localhost:27017`.\n   \u003e - The Redis will be available at `http://localhost:6379`.\n\n4. **Stop the Docker Containers:**\n\n   ```bash\n   docker-compose down\n   ```\n\n5. **Remove the Docker Containers, Docker Network, Images, Volumes:**\n\n   ```bash\n   docker-compose down -v\n   ```\n\n6. **Execute Commands Inside Containers:**\n\n   ```bash\n     docker-compose exec backend bash\n     docker-compose exec frontend sh\n   ```\n\n## Environment Variables\n\nCreate a `.env` file in both the `backend` and `frontend` directories with the following configurations:\n\n#### Backend `.env`\n\n```env\nPORT=5000\nMONGO_URI=your_mongodb_connection_string\nJWT_SECRET=your_jwt_secret\nGOOGLE_CLIENT_ID=your_google_client_id\nGOOGLE_CLIENT_SECRET=your_google_client_secret\n```\n\n#### Frontend `.env`\n\n```env\nVITE_API_URL=http://localhost:5000/api\n```\n\n\u003e **Note:**\n\u003e\n\u003e - Replace `your_mongodb_connection_string` and `your_jwt_secret` with your actual MongoDB URI and a strong secret key for JWT.\n\u003e - Replace `your_google_client_id` and `your_google_client_secret` with your Google OAuth credentials. You can obtain these from the [Google Developers Console](https://console.developers.google.com/).\n\n### Running the Application\n\n1. **Start the Backend Server:**\n\n   ```bash\n   cd frontend\n   npm run dev\n   ```\n\n   The backend server should now be running on `http://localhost:5000`.\n\n2. **Start the Frontend Development Server:**\n\n   Open a new terminal window/tab and navigate to the `frontend` directory:\n\n   ```bash\n   cd frontend\n   npm run dev\n   ```\n\n   The frontend will be available at `http://localhost:3000`.\n\n3. **Accessing the Application:**\n\n   Open your browser and navigate to `http://localhost:3000` to access Shortify.\n\n## API Documentation\n\n### Base URL\n\n```\nhttp://localhost:5000/api\n```\n\n### Endpoints\n\n#### 1. **Login with Google**\n\n- **URL:** `/auth/google`\n- **Method:** `POST`\n- **Description:** Redirects the user to Google for authentication.\n- **Request Body:**\n\n  ```json\n  {\n    \"token\": \"djbvdsddbd\"\n  }\n  ```\n\n- **Response:**\n\n  ```json\n  {\n    \"token\": \"jwttoken\",\n    \"user\": {\n      \"email\": \"user@example.com\",\n      \"name\": \"John Doe\",\n      \"picture\": \"https://example.com/picture.jpg\"\n    }\n  }\n  ```\n\n#### 2. **Google Authentication Callback**\n\n- **URL:** `/auth/google/callback`\n- **Method:** `GET`\n- **Description:** Handles the OAuth callback from Google.\n- **Response:**\n\n  - On successful authentication, redirects the user to the frontend application with a JWT token.\n\n#### 3. **Shorten URL**\n\n- **URL:** `/shorten`\n- **Method:** `POST`\n- **Headers:** `Authorization: Bearer \u003cjwt_token\u003e`\n- **Description:** Create a shortened URL.\n- **Request Body:**\n\n  ```json\n  {\n    \"originalUrl\": \"https://www.example.com\",\n    \"customAlias\": \"exmpl\", // Optional\n    \"topic\": \"acquisition\" // Optional\n  }\n  ```\n\n- **Response:**\n\n  ```json\n  {\n    \"shortUrl\": \"http://localhost:5000/api/shorten/exmpl\",\n    \"createdAt\": \"2023-10-01T00:00:00.000Z\"\n  }\n  ```\n\n#### 4. **Redirect to Original URL**\n\n- **URL:** `/shorten/:alias`\n- **Method:** `GET`\n- **Description:** Redirect to the original URL using the shortened alias.\n\n#### 5. **Fetch All URLs**\n\n- **URL:** `/urls`\n- **Method:** `GET`\n- **Headers:** `Authorization: Bearer \u003cjwt_token\u003e`\n- **Description:** Retrieve all shortened URLs for the authenticated user with pagination.\n- **Query Parameters:**\n\n  - `page` (default: `1`)\n  - `limit` (default: `7`)\n  - `topic` (optional)\n\n- **Response:**\n\n  ```json\n  {\n    \"urls\": [\n      {\n        \"shortUrl\": \"exmpl\",\n        \"originalUrl\": \"https://www.example.com\",\n        \"topic\": \"acquisition\",\n        \"createdAt\": \"2023-10-01T00:00:00.000Z\",\n        \"clicks\": [\n          /* Array of click analytics */\n        ]\n      }\n      // More URL objects...\n    ],\n    \"total\": 100,\n    \"page\": 1,\n    \"pages\": 15\n  }\n  ```\n\n#### 6. **Fetch URL Analytics**\n\n- **URL:** `/analytics/:alias`\n- **Method:** `GET`\n- **Description:** Retrieve detailed analytics for a specific shortened URL.\n\n#### 7. **Fetch Topic Analytics**\n\n- **URL:** `/analytics/topic/:topic`\n- **Method:** `GET`\n- **Description:** Retrieve analytics for a specific topic.\n\n## Folder Structure\n\n```\nshortify/\n│\n├── backend/\n│   ├── models/\n│   │   └── UrlModel.js\n│   ├── middleware/\n│   │   └── auth.js\n│   ├── routes/\n│   │   └── UrlRoute.js\n│   ├── controllers/\n│   │   └── UrlController.js\n│   └── index.js\n│\n├── frontend/\n│   ├── public/\n│   │   └── index.html\n│   ├── src/\n│   │   ├── apis/\n│   │   │   └── index.js\n│   │   ├── components/\n│   │   │   ├── CreateUrlForm.jsx\n│   │   │   └── Layout.jsx\n│   │   │   └── Loading.jsx\n│   │   │   └── AnalyticsChart.jsx\n│   │   │   └── ProtectedRoute.jsx\n│   │   ├── context/\n│   │   │   └── AuthContext.jsx\n│   │   ├── pages/\n│   │   │   ├── Dashboard.jsx\n│   │   │   ├── Login.jsx\n│   │   │   ├── Analytics.jsx\n│   │   │   ├── UrlList.jsx\n│   │   │   └── TopicAnalytics.jsx\n│   │   ├── App.jsx\n│   │   └── main.jsx\n│   ├── README.md\n│   └── vite.config.js\n│\n├── README.md\n└── package.json\n```\n\n## Contributing\n\nContributions are welcome! If you have suggestions, bug reports, or feature requests, please open an issue or submit a pull request.\n\n### Steps to Contribute\n\n1. **Fork the Repository**\n\n   Click on the `Fork` button at the top-right corner of this repository's page.\n\n2. **Clone Your Fork**\n\n   ```bash\n   git clone https://github.com/rekha0suthar/url-shorten.git\n   cd url-shorten\n   ```\n\n3. **Create a New Branch**\n\n   ```bash\n   git checkout -b feature/YourFeatureName\n   ```\n\n4. **Make Your Changes**\n\n   Implement your feature or bug fix.\n\n5. **Commit Your Changes**\n\n   ```bash\n   git commit -m \"Add feature: YourFeatureName\"\n   ```\n\n6. **Push to Your Fork**\n\n   ```bash\n   git push origin feature/YourFeatureName\n   ```\n\n7. **Create a Pull Request**\n\n   Navigate to the original repository and create a pull request from your fork's branch.\n\n## License\n\nDistributed under the [MIT License](LICENSE).\n\n## Contact\n\n- **Rekha Suthar**\n- **Email:** rekha0suthar@gmail.com\n- **LinkedIn:** [linkedin.com/in/rekha0suthar](https://www.linkedin.com/in/rekha0suthar)\n- **GitHub:** [github.com/rekha0suthar](https://github.com/rekha0suthar)\n\n## Acknowledgements\n\n- [Material-UI](https://mui.com/) for powerful and flexible React components.\n- [React Toastify](https://fkhadra.github.io/react-toastify/introduction) for elegant notifications.\n- [Express.js](https://expressjs.com/) for the robust backend framework.\n- [MongoDB](https://www.mongodb.com/) for the reliable NoSQL database solution.\n- [Nanoid](https://github.com/ai/nanoid) for unique ID generation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frekha0suthar%2Furl-shorten","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frekha0suthar%2Furl-shorten","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frekha0suthar%2Furl-shorten/lists"}