How yeegeek/uyou-go-api-starter works
UYou Go API Starter is a REST API starter with a React client for account and friend workflows. The main path is browser auth state → HTTP routes → handlers → services and repositories → configured data stores. The repository also documents gRPC, RabbitMQ/event messaging, health checks, Prometheus metrics, and scheduled jobs; those capabilities are represented where the tree or excerpts identify them, but their runtime wiring is not fully shown. Dashed edges mark documented or unverified integration; unsampled source was not inspected.
Main entry points: router.go HTTP routing · main.go API server · service.go User service · db.go PostgreSQL
Components 28
Web client
- Web app routes
frontend/src/App.tsx - Auth state
frontend/src/hooks/useAuth.ts - API client
frontend/src/services/api.ts
HTTP API
- API server
cmd/server/main.go - HTTP routing
internal/server/router.go - HTTP middleware
internal/middleware
Identity and social
- User handlers
internal/user/handler.go - User service
internal/user/service.go - User repository
internal/user/repository.go - Auth service
internal/auth/service.go - Refresh tokens
internal/auth/refresh_token.go - Friend handlers
internal/friend/handler.go - Friend service
internal/friend/service.go - Friend repository
internal/friend/repository.go
Persistence and operations
- PostgreSQL
internal/db/db.go - MongoDB
internal/mongodb/mongodb.go - Redis cache
internal/redis/redis.go - Health checks
internal/health - Prometheus metrics
internal/metrics/metrics.go - Schema migrations
internal/migrate/migrate.go
Service integrations
- gRPC server
internal/grpc/server/server.go - gRPC client
internal/grpc/client/user_client.go - User protobuf
api/proto/user/user.proto - RabbitMQ messaging
internal/messaging/rabbitmq.go - Event bus
internal/messaging/events.go - Task manager
internal/scheduler/manager.go - Scheduled tasks
internal/scheduler/tasks
Other components
- API user
Connections 27
- API user → Web app routes: uses
frontend/src/App.tsx - Web app routes → Auth state: reads auth
frontend/src/App.tsx - Web app routes → API client: requests
- API client → API server: HTTP calls
- API server → HTTP routing: configures
cmd/server/main.go - HTTP routing → User handlers: routes
internal/server/router.go - HTTP routing → Friend handlers: routes
internal/server/router.go - HTTP routing → HTTP middleware: installs
internal/server/router.go - HTTP routing → Health checks: routes
internal/server/router.go - User handlers → User service: calls
internal/user/handler.go - User handlers → Auth service: auth operations
internal/user/handler.go - User service → User repository: uses
- Auth service → Refresh tokens: rotates tokens
- Friend handlers → Friend service: calls
internal/friend/handler.go - Friend service → Friend repository: uses
- User repository → PostgreSQL: persists users
- Friend repository → PostgreSQL: persists friendships
- User service → Redis cache: cache integration
- API server → PostgreSQL: opens connection
cmd/server/main.go - API server → Schema migrations: checks schema
cmd/server/main.go - API server → gRPC server: starts service
- gRPC server → User service: serves user operations
- gRPC client → User protobuf: uses definitions
internal/grpc/client/user_client.go - RabbitMQ messaging → Event bus: publishes events
- Task manager → Scheduled tasks: registers tasks
- Health checks → PostgreSQL: checks database
- HTTP routing → Prometheus metrics: exposes metrics