{"id":23906973,"url":"https://github.com/letsmakecakes/urlshortener","last_synced_at":"2025-02-23T14:16:26.325Z","repository":{"id":270682904,"uuid":"910819811","full_name":"letsmakecakes/urlshortener","owner":"letsmakecakes","description":"A robust URL shortening service built with Go, featuring a RESTful API, MongoDB storage, and Docker support. This service allows you to create, manage, and track shortened URLs with comprehensive statistics.","archived":false,"fork":false,"pushed_at":"2025-01-02T10:49:40.000Z","size":1,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-02T11:30:33.723Z","etag":null,"topics":["go","golang","http","server","url","url-shortener"],"latest_commit_sha":null,"homepage":"","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/letsmakecakes.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":"2025-01-01T14:30:18.000Z","updated_at":"2025-01-02T11:10:46.000Z","dependencies_parsed_at":"2025-01-02T11:30:40.163Z","dependency_job_id":"56bef121-bc60-4aa7-8abf-f84076037f6b","html_url":"https://github.com/letsmakecakes/urlshortener","commit_stats":null,"previous_names":["letsmakecakes/urlshortener"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letsmakecakes%2Furlshortener","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letsmakecakes%2Furlshortener/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letsmakecakes%2Furlshortener/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letsmakecakes%2Furlshortener/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/letsmakecakes","download_url":"https://codeload.github.com/letsmakecakes/urlshortener/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240324066,"owners_count":19783455,"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":["go","golang","http","server","url","url-shortener"],"created_at":"2025-01-05T02:15:46.986Z","updated_at":"2025-02-23T14:16:26.028Z","avatar_url":"https://github.com/letsmakecakes.png","language":"Go","readme":"# URL Shortener Service\n\nA robust URL shortening service built with Go, featuring a RESTful API, MongoDB storage, and Docker support. This service allows you to create, manage, and track shortened URLs with comprehensive statistics.\n\n## Features\n\n- ✨ Create shortened URLs\n- 🔄 Update existing URLs\n- 📊 Track URL access statistics\n- 🚀 RESTful API\n- 🔒 Input validation\n- 📝 Structured logging\n- 🐳 Docker support\n- 🧪 Comprehensive tests\n\n## Tech Stack\n\n- Go 1.21+\n- MongoDB\n- Docker \u0026 Docker Compose\n- Zap Logger\n- Gorilla Mux\n- Testify (testing)\n\n## Prerequisites\n\n- Go 1.21 or higher\n- Docker and Docker Compose\n- MongoDB (if running locally)\n\n## Getting Started\n\n### Running with Docker\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/letsmakecakes/urlshortener.git\ncd urlshortener\n```\n\n2. Start the services:\n```bash\ndocker-compose up -d\n```\n\nThe following services will be available:\n- URL Shortener API: http://localhost:8080\n- MongoDB Express UI: http://localhost:8081 (admin/password)\n\n### Running Locally\n\n1. Set up environment variables:\n```bash\ncp .env.example .env\n# Edit .env with your configuration\n```\n\n2. Install dependencies:\n```bash\ngo mod download\n```\n\n3. Run the application:\n```bash\ngo run cmd/api/main.go\n```\n\n## API Documentation\n\n### Create Short URL\n\n```http\nPOST /shorten\nContent-Type: application/json\n\n{\n    \"url\": \"https://example.com/some/long/url\"\n}\n```\n\nResponse:\n```json\n{\n    \"id\": \"1\",\n    \"url\": \"https://example.com/some/long/url\",\n    \"shortCode\": \"abc123\",\n    \"createdAt\": \"2024-01-02T12:00:00Z\",\n    \"updatedAt\": \"2024-01-02T12:00:00Z\"\n}\n```\n\n### Get Original URL\n\n```http\nGET /shorten/{shortCode}\n```\n\nResponse:\n```json\n{\n    \"id\": \"1\",\n    \"url\": \"https://example.com/some/long/url\",\n    \"shortCode\": \"abc123\",\n    \"createdAt\": \"2024-01-02T12:00:00Z\",\n    \"updatedAt\": \"2024-01-02T12:00:00Z\"\n}\n```\n\n### Update URL\n\n```http\nPUT /shorten/{shortCode}\nContent-Type: application/json\n\n{\n    \"url\": \"https://example.com/updated/url\"\n}\n```\n\n### Delete URL\n\n```http\nDELETE /shorten/{shortCode}\n```\n\n### Get URL Statistics\n\n```http\nGET /shorten/{shortCode}/stats\n```\n\nResponse:\n```json\n{\n    \"id\": \"1\",\n    \"url\": \"https://example.com/some/long/url\",\n    \"shortCode\": \"abc123\",\n    \"accessCount\": 42,\n    \"createdAt\": \"2024-01-02T12:00:00Z\",\n    \"updatedAt\": \"2024-01-02T12:00:00Z\"\n}\n```\n\n## Running Tests\n\n### Unit Tests\n\n```bash\ngo test ./internal/... -v\n```\n\n### Integration Tests\n\n```bash\n# Ensure the service is running\nINTEGRATION_TEST=true go test ./tests/integration -v\n```\n\n## Project Structure\n\n```\nurlshortener/\n├── cmd/\n│   └── api/\n│       └── main.go               # Application entry point\n├── internal/\n│   ├── api/                      # HTTP handlers and routes\n│   ├── config/                   # Configuration management\n│   ├── domain/                   # Domain models and interfaces\n│   ├── pkg/                      # Internal packages\n│   └── service/                  # Business logic\n├── pkg/                          # Public packages\n├── tests/                        # Integration tests\n└── docker-compose.yml           # Docker composition\n```\n\n## Development\n\n### Adding New Endpoints\n\n1. Define the handler in `internal/api/handlers/url_handler.go`\n2. Add the route in `internal/api/routes/routes.go`\n3. Implement business logic in `internal/service/url_service.go`\n4. Add tests for the new functionality\n\n### Logging\n\nThe service uses Zap for structured logging. Logs are configured based on the environment:\n- Development: Console-friendly, colored output\n- Production: JSON format for better parsing\n\n### Monitoring\n\nMonitor the application using:\n```bash\n# View logs\ndocker-compose logs -f app\n\n# Access MongoDB Express\nopen http://localhost:8081\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fletsmakecakes%2Furlshortener","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fletsmakecakes%2Furlshortener","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fletsmakecakes%2Furlshortener/lists"}