How gopinathmaharaja/shorturl works
This is a Go Fiber URL-shortening API. Its principal workflow is user registration and login, followed by authenticated short-link creation and public redirection; the API also exposes click analytics. The graph captures route registrations and calls visible in excerpts, plus the documented MongoDB persistence capability. Several service, repository, startup, and optional cache details are indexed but unsampled, so their internal connections are omitted or marked unverified rather than inferred.
Main entry points: router.go Route setup · handler.go Short-link handlers · user/repository.go User repository · shortUrl/repository.go Short-link repository
Components 18
HTTP API
- Route setup
routes/router.go - Health endpoints
internal/handlers/health_handler.go - Rate limiting
internal/middleware/ratelimit.go - Application startup
cmd/main.go
Identity
- User handlers
internal/user/handler.go - JWT and API-key auth
internal/middleware/jwt.go - User service
internal/user/service.go - User model
internal/user/model.go - User repository
internal/user/repository.go
Short Links
- Short-link handlers
internal/shortUrl/handler.go - Short-link service
internal/shortUrl/service.go - Short-link repository
internal/shortUrl/repository.go - Link and analytics models
internal/shortUrl/model.go - Scheduled cleanup
internal/utils/cron.go
Persistence and Support
- MongoDB
pkg/db/mongo.go - Redis cache
pkg/cache/redis.go - Logger
pkg/logger/logger.go
Other components
- API client
Connections 16
- API client → Route setup: sends requests
README.md - Route setup → Health endpoints: registers health
routes/router.go - Route setup → User handlers: registers auth routes
routes/router.go - Route setup → Short-link handlers: registers link routes
routes/router.go - Route setup → JWT and API-key auth: protects URL routes
routes/router.go - Route setup → Rate limiting: applies limits
routes/router.go - User handlers → User service: calls
- JWT and API-key auth → User repository: looks up users
internal/middleware/jwt.go - Short-link handlers → Short-link service: creates and resolves links
internal/shortUrl/handler.go - Short-link handlers → Short-link repository: requests click analytics
internal/shortUrl/handler.go - User service → User repository: persists users
- Short-link service → Short-link repository: persists links
- User repository → MongoDB: stores user records
- Short-link repository → MongoDB: stores links and analytics
- Application startup → Route setup: starts API
- Application startup → MongoDB: initializes database