How brillery/mediahub works
This repository is a media upload and short-link system: users browse a Vue interface and upload files through Mediahub, which stores media and requests short links from a separate gRPC service. Short-link resolution is also exposed through an HTTP proxy; a scheduled job flushes Redis access counts to MySQL. The short-link server excerpt supports the cache, lock, persistence, and warmup relationships shown below. Several controller, proxy, data, and cron implementations were not sampled, so their internal call wiring is intentionally limited.
Main entry points: server.go Short-link service · redis.go Redis cache and counts · routers.go API routes · file.go File controller
Components 25
Web client
- Vue app
mediahub-web/src/main.ts - Home view
mediahub-web/src/views/home.vue - Upload UI
mediahub-web/src/views/components/upload.vue - Web API client
mediahub-web/src/api/api.ts
MediaHub API
- MediaHub HTTP API
mediahub/main.go - API routes
mediahub/routers/routers.go - File controller
mediahub/controller/file.go - Home controller
mediahub/controller/home.go - Short-link client
mediahub/services/shorturl/client.go - gRPC connection pool
mediahub/pkg/grpc_client_pool/client_pool.go
Short-link services
- Short-link gRPC server
shorturl/shorturl-server/main.go - Short-link service
shorturl/shorturl-server/server/server.go - URL mapping data
shorturl/shorturl-server/data/url_map.go - Two-level cache
shorturl/shorturl-server/cache/cache.go - Distributed locks
shorturl/shorturl-server/cache/lock.go - Access counter
shorturl/shorturl-server/cache/access_counter.go - Redirect proxy
shorturl-proxy/proxy/proxy.go - Proxy gRPC client
shorturl-proxy/services/shorturl/client.go - Count flush job
shorturl-crontab/cron/access_count.go - Cron MySQL access
shorturl-crontab/pkg/db/mysql/mysql.go
Persistence and storage
- COS media storage
mediahub/pkg/storage/cos/cos.go - MySQL mappings
shorturl/pkg/db/mysql/mysql.go - Redis cache and counts
shorturl/pkg/db/redis/redis.go
Other components
- Visitor
- COS service
Connections 27
- Visitor → Vue app: uses
- Vue app → Home view: renders
- Home view → Upload UI: offers upload
- Upload UI → Web API client: requests API
- Visitor → MediaHub HTTP API: uploads file
- MediaHub HTTP API → API routes: dispatches
- API routes → File controller: routes upload
- API routes → Home controller: routes home
- File controller → COS media storage: stores media
- COS media storage → COS service: stores objects
- File controller → Short-link client: requests short link
- Short-link client → gRPC connection pool: gets connection
- Short-link gRPC server → Short-link service: registers service
- Short-link service → URL mapping data: reads/writes mappings
- Short-link service → Two-level cache: reads/fills cache
- Short-link service → Distributed locks: coordinates misses
- Short-link service → Access counter: increments visits
- URL mapping data → MySQL mappings: persists mappings
- Two-level cache → Redis cache and counts: reads/writes cache
- Distributed locks → Redis cache and counts: coordinates access
- Access counter → Redis cache and counts: increments counts
- Visitor → Redirect proxy: opens short link
- Redirect proxy → Proxy gRPC client: resolves link
- Proxy gRPC client → Short-link gRPC server: calls gRPC
- Count flush job → Redis cache and counts: reads counts
- Count flush job → Cron MySQL access: flushes counts
- Cron MySQL access → MySQL mappings: updates totals