How furialfonso/sso-service works
Project Type and Purpose
• This is a 3-tier service designed for Single Sign-On (SSO) functionality. Its architecture emphasizes dependency injection and the separation of concerns between the API, business logic, and external integrations.
• The README and file structure confirm that it’s a backend service written in Go (using Gin for HTTP routing) and integrated with external systems like Keycloak, Team API, and Prometheus for monitoring.
File Structure
• Top-level directories such as "api", "middleware", "pkg", and "mocks" indicate a clear separation of concerns.
• The "api" directory contains the service’s entry point and routing logic, with subdirectories for different HTTP handlers (e.g., for authentication, user actions, and ping checks) which aligns with the “Handler Container” in the architecture.
• Business logic is in the "pkg/service" directory (split between AuthService and UserService), which represents the "Service Container".
• The "pkg/integration" folder holds client logic for interacting with external systems (Keycloak, Rest calls, Team integration), corresponding to the "Client Container".
• Configuration and properties in "pkg/config", along with Docker and dependency injection tools (using Dig) indicate an emphasis on modularity and predictable deployments.
Insights from the README
• It also lists technologies: Golang, Gin, Mokery, Dig, and Docker—each of which frames how components interact and are integrated.
• The README reinforces the three-tier model and dependency injection, which should be prominently represented.
a. Components to Include:
• External User: The client interacting over HTTP.
• API Gateway Container: Comprising the Gin-based API Server, Router, and Metrics Middleware.
• Handler Container: Contains Auth Handler, User Handler, and Ping Handler.
• Service Container: Consists of Auth Service and User Service.
• Client Container: Incorporates Keycloak Client, Rest Client, and Team Client.
• External Systems: Keycloak server for auth, Team API for team data, and Prometheus for monitoring.
b. Relationships and Interactions:
• External User sending HTTP requests to the API Server.
• API Server forwarding requests to the Router, which applies Metrics Middleware.
• Router to the appropriate Handlers (e.g., /auth goes to Auth Handler, /users to User Handler, /ping to Ping Handler).
• That each handler calls the corresponding service (Auth Handler → Auth Service, User Handler → User Service).
• Demonstrate that services, via dependency injection, communicate with clients (e.g., Auth Service uses Keycloak Client; User Service uses Keycloak and Team Clients).
• Connections from the clients to their respective external systems (Keycloak, Team API) and the inclusion of Prometheus in the Metrics path.
c. Important Architectural Patterns and Design Principles:
• The 3-tier architecture (API Gateway → Handlers → Services) and dependency injection facilitate modularity and testability.
• Clear separation of external integrations, as seen in the Client Container.
• Use of middleware (e.g., Metrics Middleware) to handle cross-cutting concerns like logging and monitoring.
d. Relevant Technologies:
• Gin for the API and Router.
• Dig for dependency injection.
• Mokery for mocks in unit tests.
• Docker and docker-compose for containerization and deployment.
• Go’s built-in testing suite for test coverage.
Final Details
• Components are clearly labeled with their technology or role (for instance, “API Server (Gin)” or “Metrics Middleware (Prometheus)”).
• Brief notes on dependency injection and how the components are assembled using Dig.