How koioio/short_link works
This repository contains a short-link product with a Vue frontend and a Go-Zero API/RPC architecture; the tree also includes a separate Gin-based service implementation. The principal workflow is authenticated URL submission, generation and persistence of a short code, then lookup and HTTP redirect. The graph follows the documented Go-Zero workflow and sampled handlers/service contexts; generation variants and infrastructure relationships are included where documented, though their full implementations were not sampled.
Main entry points: generateshorturllogic.go Generation logic · shorturlserver.go Short-link RPC server · routes.go Route registration · handleshortlogic.go Redirect logic
Components 26
Web client
- Vue application
web/shorturl-frontend/src/App.vue - Auth state
web/shorturl-frontend/src/api/auth.js - Generate page
web/shorturl-frontend/src/pages/Generate.vue - Login/register pages
web/shorturl-frontend/src/pages/Login.vue
HTTP API
- HTTP gateway
zero_remake/shorturl_api/shorturl.go - Route registration
zero_remake/shorturl_api/internal/handler/routes.go - Generate handlers
zero_remake/shorturl_api/internal/handler/generatehandler.go - Redirect handler
zero_remake/shorturl_api/internal/handler/redirecthandler.go - Auth handlers
zero_remake/shorturl_api/internal/handler/loginhandler.go - API service context
zero_remake/shorturl_api/internal/svc/servicecontext.go - Short-link RPC client
zero_remake/shorturl_rpc/shorturlclient/shorturl.go - User RPC client
zero_remake/user-rpc/userservice/userservice.go
RPC services
- Short-link RPC server
zero_remake/shorturl_rpc/internal/server/shorturlserver.go - Generation logic
zero_remake/shorturl_rpc/internal/logic/generateshorturllogic.go - Redirect logic
zero_remake/shorturl_rpc/internal/logic/handleshortlogic.go - Generation variants
zero_remake/shorturl_rpc/internal/logic - User RPC server
zero_remake/user-rpc/internal/server/userserviceserver.go - Login/register logic
zero_remake/user-rpc/internal/logic - Short-link service context
zero_remake/shorturl_rpc/internal/svc/servicecontext.go
Storage and generation
- MySQL
- Redis cache
- Bloom filter
zero_remake/shorturl_rpc/internal/logic/repository/RedisBloomFliter.go - Snowflake IDs
zero_remake/shorturl_rpc/internal/logic/repository/mysnowflake.go - Base encoding
zero_remake/shorturl_rpc/internal/logic/repository/Base64.go
Other components
- Browser user
- Etcd discovery
Connections 36
- Browser user → Vue application: uses
- Vue application → Generate page: shows
- Vue application → Login/register pages: shows
- Login/register pages → Auth state: sets token
- Generate page → Auth state: reads token
- Generate page → HTTP gateway: submits URL
- Login/register pages → HTTP gateway: sends credentials
- HTTP gateway → Route registration: registers routes
- Route registration → Generate handlers: dispatches
- Route registration → Redirect handler: dispatches
- Route registration → Auth handlers: dispatches
- Generate handlers → Short-link RPC client: calls RPC
- Redirect handler → Short-link RPC client: calls RPC
- Auth handlers → User RPC client: calls RPC
- API service context → Short-link RPC client: constructs
- API service context → User RPC client: constructs
- Short-link RPC client → Short-link RPC server: gRPC calls
- User RPC client → User RPC server: gRPC calls
- Short-link RPC server → Generation logic: dispatches
- Short-link RPC server → Redirect logic: dispatches
- Short-link RPC server → Generation variants: dispatches variants
- User RPC server → Login/register logic: dispatches
- Generation logic → Snowflake IDs: generates ID
- Generation logic → Base encoding: encodes ID
- Generation logic → Bloom filter: checks and adds
- Generation logic → MySQL: reads and writes
- Generation logic → Redis cache: caches mapping
- Redirect logic → Redis cache: checks cache
- Redirect logic → MySQL: queries mapping
- Redirect logic → Redis cache: refreshes cache
- Login/register logic → MySQL: reads and writes
- Short-link service context → MySQL: initializes
- Short-link service context → Redis cache: initializes
- Short-link service context → Bloom filter: constructs
- HTTP gateway → Etcd discovery: service discovery
- Short-link RPC server → Etcd discovery: service discovery