{"id":29016451,"url":"https://github.com/webvishnu/url-shortner","last_synced_at":"2026-05-07T01:36:28.532Z","repository":{"id":300577910,"uuid":"1006349670","full_name":"WebVishnu/url-shortner","owner":"WebVishnu","description":"A modern URL shortener built with Next.js, MongoDB, and machine fingerprinting. No accounts needed - your links are automatically saved to your device.","archived":false,"fork":false,"pushed_at":"2025-06-22T13:42:35.000Z","size":44,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-22T14:36:45.830Z","etag":null,"topics":["docker","docker-compose","nextjs14"],"latest_commit_sha":null,"homepage":"https://url-shortner-dun-two.vercel.app","language":"TypeScript","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/WebVishnu.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}},"created_at":"2025-06-22T04:12:16.000Z","updated_at":"2025-06-22T13:42:38.000Z","dependencies_parsed_at":"2025-06-22T14:49:34.709Z","dependency_job_id":null,"html_url":"https://github.com/WebVishnu/url-shortner","commit_stats":null,"previous_names":["webvishnu/url-shortner"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/WebVishnu/url-shortner","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebVishnu%2Furl-shortner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebVishnu%2Furl-shortner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebVishnu%2Furl-shortner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebVishnu%2Furl-shortner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WebVishnu","download_url":"https://codeload.github.com/WebVishnu/url-shortner/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebVishnu%2Furl-shortner/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261960448,"owners_count":23236575,"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":["docker","docker-compose","nextjs14"],"created_at":"2025-06-25T22:08:28.321Z","updated_at":"2026-05-07T01:36:28.482Z","avatar_url":"https://github.com/WebVishnu.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# URL Shortener\n\nA simple and modern URL shortener built with Next.js, MongoDB, and Tailwind CSS, containerized with Docker for easy deployment and development.\n\n## 🚀 Quick Start with Docker\n\n### Prerequisites\n- [Docker](https://www.docker.com/products/docker-desktop/) installed on your system\n- [Docker Compose](https://docs.docker.com/compose/install/) (usually included with Docker Desktop)\n\n### Getting Started\n\n1. **Clone the repository**\n   ```bash\n   git clone \u003cyour-repo-url\u003e\n   cd url-shortner\n   ```\n\n2. **Choose your mode and run**\n\n   **For Development (with hot reload):**\n   ```bash\n   ./dev.sh\n   ```\n\n   **For Production:**\n   ```bash\n   ./prod.sh\n   ```\n\n3. **Access the application**\n   - 🌐 **URL Shortener**: http://localhost:3000\n   - 🗄️ **MongoDB**: localhost:27017\n\n## 🛠️ Development vs Production\n\n### Development Mode (`./dev.sh`)\n- ✅ Hot reloading enabled\n- ✅ Source code changes reflect immediately\n- ✅ Development environment with Turbopack\n- ✅ Volume mounts for live code updates\n\n### Production Mode (`./prod.sh`)\n- ✅ Optimized build\n- ✅ Standalone output\n- ✅ Production-ready environment\n- ✅ Smaller container size\n\n## 📁 Project Structure\n```\nurl-shortner/\n├── app/                    # Next.js app directory\n│   ├── page.tsx           # Homepage with URL shortener form\n│   ├── [shortId]/         # Short URL redirect handler\n│   └── api/urls/          # API routes\n├── lib/                   # Utility libraries\n│   ├── mongodb.ts         # MongoDB connection\n│   └── url.ts            # URL model\n├── docker-compose.yml     # Production Docker setup\n├── docker-compose.dev.yml # Development Docker setup\n├── Dockerfile            # Multi-stage Docker build\n├── dev.sh               # Development startup script\n└── prod.sh              # Production startup script\n```\n\n## 🐳 Docker Commands\n\n### Start Services\n```bash\n# Development\n./dev.sh\n\n# Production\n./prod.sh\n```\n\n### View Logs\n```bash\n# Development logs\ndocker-compose -f docker-compose.dev.yml logs -f\n\n# Production logs\ndocker-compose logs -f\n```\n\n### Stop Services\n```bash\n# Development\ndocker-compose -f docker-compose.dev.yml down\n\n# Production\ndocker-compose down\n```\n\n### Rebuild Containers\n```bash\n# Development\ndocker-compose -f docker-compose.dev.yml up --build -d\n\n# Production\ndocker-compose up --build -d\n```\n\n## 🔧 Manual Setup (Alternative)\n\nIf you prefer to run without Docker:\n\n### 1. Install dependencies\n```bash\nnpm install\n```\n\n### 2. Set up MongoDB\n- Install MongoDB locally or use MongoDB Atlas\n- Create a `.env.local` file:\n  ```\n  MONGODB_URI=mongodb://localhost:27017/url-shortener\n  ```\n\n### 3. Run the development server\n```bash\nnpm run dev\n```\n\n## 🌟 Features\n- ✂️ Shorten long URLs\n- 📊 Track visit counts and analytics\n- 🔄 Automatic redirects\n- 📱 Responsive design\n- 🚀 Fast development with hot reload\n- 🐳 Containerized for easy deployment\n\n## 📝 Environment Variables\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `MONGODB_URI` | MongoDB connection string | `mongodb://admin:password@mongodb:27017/url-shortener?authSource=admin` |\n| `NODE_ENV` | Environment mode | `production` (prod) / `development` (dev) |\n\n## 🤝 Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Test with Docker\n5. Submit a pull request\n\n## 📄 License\n\nMIT License - feel free to use this project for your own purposes.\n\n## 🆘 Troubleshooting\n\n### Port Already in Use\nIf port 3000 or 27017 is already in use:\n```bash\n# Stop existing containers\ndocker-compose down\ndocker-compose -f docker-compose.dev.yml down\n\n# Or change ports in docker-compose files\n```\n\n### MongoDB Connection Issues\n- Ensure MongoDB container is running: `docker-compose ps`\n- Check logs: `docker-compose logs mongodb`\n- Verify network connectivity between containers\n\n### Build Issues\n- Clear Docker cache: `docker system prune -a`\n- Rebuild without cache: `docker-compose build --no-cache`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebvishnu%2Furl-shortner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebvishnu%2Furl-shortner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebvishnu%2Furl-shortner/lists"}