How datpham2001/user-service-ms works
Project type and purpose
• This is a Go‑based User Service Microservice focused on authentication, registration, and OAuth2 integration (Google).
• Exposes a RESTful HTTP API (Gin) and has a basic gRPC server scaffold.
• Integrates with external systems: relational database, cache store, OAuth2 provider (Google), and message broker (RabbitMQ).
File structure
• Top‑level binaries under cmd/:
– http_server.go (starts Gin HTTP server)
– grpc_server.go (starts gRPC interface)
– main.go (wire up config, logging, servers)
• API definitions in api/v1/: route registration for /api/v1/auth endpoints.
• Configuration under config/: YAML loader (Viper) and sample config.
• internal/: implements a layered (clean/hexagonal) architecture:
– delivery/http/auth: HTTP handlers and route wiring
– service/auth, service/token: business logic, JWT & OAuth2 flows
– repository/auth & repository/common: database CRUD & common DB operations
– infra/database, infra/cache, infra/rabbitmq: external resource clients
– middleware: logging, request ID injection
– dto: request/response models
– errors: custom error types
– client/oauth: OAuth2 client wrapper
• pkg/: reusable libraries (HTTP client, logger, response formatting).
README for additional insights
• Technology stack: Go, Gin, Viper, Logrus, PostgreSQL/Redis (configurable), Google OAuth, gRPC.
• Core features: signup/login, password validation, email format checks, OAuth2 flow, structured logging, error handling.
Detailed capture of essential elements
• Dependency injection: e.g., “main.go → NewAuthHandler(deps) → Handler”.
– Lane 1: Transport (HTTP/gRPC)
– Lane 2: Orchestration (Handlers)
– Lane 3: Business (Services)
– Lane 4: Data (Repos, Infra)
– Lane 5: External (DB, Cache, Google OAuth, RabbitMQ)