# bladerunner322/orange-team-microservices architecture

> Architecture diagram of the GitHub repository bladerunner322/orange-team-microservices, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bladerunner322/orange-team-microservices
- Repository: https://github.com/bladerunner322/orange-team-microservices

## Overview

This repository implements an API Gateway plus Auth and Profiles microservices. The main user workflow is HTTP registration/login through the Gateway to Auth, followed by token validation and refresh/logout; authenticated profile operations are forwarded to Profiles. Auth also manages JWTs and refresh-token state, while Profiles reads and mutates user profiles in PostgreSQL. The README documents these capabilities; some wiring is shown only by the SOURCE INDEX, so unverified links are marked dashed.

Main entry points: [`services/gateway/internal/bootstrap/bootstrap.go`](https://github.com/bladerunner322/orange-team-microservices/blob/main/services/gateway/internal/bootstrap/bootstrap.go) (Gateway wiring), [`services/auth/internal/application/usecases`](https://github.com/bladerunner322/orange-team-microservices/tree/main/services/auth/internal/application/usecases) (Auth workflows), [`services/gateway/internal/interfaces/http/handlers`](https://github.com/bladerunner322/orange-team-microservices/tree/main/services/gateway/internal/interfaces/http/handlers) (HTTP handlers), [`services/gateway/internal/infrastructure/clients/auth_grpc.go`](https://github.com/bladerunner322/orange-team-microservices/blob/main/services/gateway/internal/infrastructure/clients/auth_grpc.go) (Auth gRPC client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateway["HTTP Gateway"]
  node_gateway_http["HTTP handlers"]
  node_gateway_middleware["HTTP middleware"]
  node_gateway_bootstrap["Gateway wiring<br/>[bootstrap.go]"]
  node_auth_client["Auth gRPC client<br/>[auth_grpc.go]"]
  node_profiles_client["Profiles gRPC client<br/>[profiles_grpc.go]"]
end

subgraph group_auth["Authentication"]
  node_auth_api["Auth gRPC API<br/>[server.go]"]
  node_auth_usecases["Auth workflows"]
  node_auth_domain["User and token rules"]
  node_jwt["JWT manager<br/>[manager.go]"]
  node_auth_repository["User repository<br/>[repository.go]"]
  node_refresh_repository["Refresh-token repository<br/>[repository.go]"]
  node_auth_postgres[("Auth PostgreSQL")]
  node_auth_redis[("Refresh-token Redis")]
end

subgraph group_profiles["User Profiles"]
  node_profiles_api["Profiles gRPC API<br/>[server.go]"]
  node_profile_usecases["Profile workflows"]
  node_profile_domain["Profile rules<br/>[profile.go]"]
  node_profile_repository["Profile repository<br/>[repository.go]"]
  node_profiles_postgres[("Profiles PostgreSQL")]
end

subgraph group_shared["Shared Infrastructure"]
  node_grpc_support["gRPC client support<br/>[client.go]"]
  node_auth_context["Identity context<br/>[context.go]"]
  node_rate_limiter["Rate limiter<br/>[limiter.go]"]
  node_gateway_redis[("Gateway Redis<br/>[client.go]")]
end

node_client(("API caller"))

node_client -->|"sends HTTP"| node_gateway_http
node_gateway_http -.->|"uses middleware"| node_gateway_middleware
node_gateway_bootstrap -->|"wires handlers"| node_gateway_http
node_gateway_bootstrap -->|"wires middleware"| node_gateway_middleware
node_gateway_bootstrap -->|"wires client"| node_auth_client
node_gateway_bootstrap -->|"wires client"| node_profiles_client
node_gateway_http -.->|"calls auth"| node_auth_client
node_gateway_http -.->|"calls profiles"| node_profiles_client
node_auth_client -->|"calls gRPC"| node_auth_api
node_profiles_client -.->|"calls gRPC"| node_profiles_api
node_auth_api -->|"executes workflows"| node_auth_usecases
node_auth_usecases -.->|"applies rules"| node_auth_domain
node_auth_usecases -.->|"uses token manager"| node_jwt
node_auth_usecases -.->|"uses repository"| node_auth_repository
node_auth_usecases -.->|"uses token store"| node_refresh_repository
node_auth_repository -.->|"reads and writes"| node_auth_postgres
node_refresh_repository -->|"reads and writes"| node_auth_redis
node_profiles_api -->|"executes workflows"| node_profile_usecases
node_profile_usecases -.->|"uses domain"| node_profile_domain
node_profile_usecases -.->|"uses repository"| node_profile_repository
node_profile_repository -->|"reads and writes"| node_profiles_postgres
node_gateway_bootstrap -->|"configures Redis"| node_gateway_redis
node_gateway_bootstrap -->|"configures limiter"| node_rate_limiter
node_auth_client -->|"creates connection"| node_grpc_support
node_grpc_support -->|"propagates identity"| node_auth_context

click node_gateway_http "https://github.com/bladerunner322/orange-team-microservices/tree/main/services/gateway/internal/interfaces/http/handlers"
click node_gateway_middleware "https://github.com/bladerunner322/orange-team-microservices/tree/main/services/gateway/internal/interfaces/http/middleware"
click node_gateway_bootstrap "https://github.com/bladerunner322/orange-team-microservices/blob/main/services/gateway/internal/bootstrap/bootstrap.go"
click node_auth_client "https://github.com/bladerunner322/orange-team-microservices/blob/main/services/gateway/internal/infrastructure/clients/auth_grpc.go"
click node_profiles_client "https://github.com/bladerunner322/orange-team-microservices/blob/main/services/gateway/internal/infrastructure/clients/profiles_grpc.go"
click node_auth_api "https://github.com/bladerunner322/orange-team-microservices/blob/main/services/auth/internal/interfaces/authgrpc/server.go"
click node_auth_usecases "https://github.com/bladerunner322/orange-team-microservices/tree/main/services/auth/internal/application/usecases"
click node_auth_domain "https://github.com/bladerunner322/orange-team-microservices/tree/main/services/auth/internal/domain"
click node_jwt "https://github.com/bladerunner322/orange-team-microservices/blob/main/services/auth/internal/infrastructure/jwt/manager.go"
click node_auth_repository "https://github.com/bladerunner322/orange-team-microservices/blob/main/services/auth/internal/infrastructure/postgres_repo/repository.go"
click node_refresh_repository "https://github.com/bladerunner322/orange-team-microservices/blob/main/services/auth/internal/infrastructure/redis_repo/repository.go"
click node_profiles_api "https://github.com/bladerunner322/orange-team-microservices/blob/main/services/profiles/internal/interfaces/profilesgrpc/server.go"
click node_profile_usecases "https://github.com/bladerunner322/orange-team-microservices/tree/main/services/profiles/internal/application/usecases"
click node_profile_domain "https://github.com/bladerunner322/orange-team-microservices/blob/main/services/profiles/internal/domain/profile.go"
click node_profile_repository "https://github.com/bladerunner322/orange-team-microservices/blob/main/services/profiles/internal/infrastructure/postgres_repo/repository.go"
click node_grpc_support "https://github.com/bladerunner322/orange-team-microservices/blob/main/pkg/grpc/client/client.go"
click node_auth_context "https://github.com/bladerunner322/orange-team-microservices/blob/main/pkg/grpc/authctx/context.go"
click node_rate_limiter "https://github.com/bladerunner322/orange-team-microservices/blob/main/pkg/ratelimit/limiter.go"
click node_gateway_redis "https://github.com/bladerunner322/orange-team-microservices/blob/main/pkg/redis/client.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_gateway_http,node_gateway_middleware,node_gateway_bootstrap,node_auth_client,node_profiles_client toneBlue
class node_auth_api,node_auth_usecases,node_auth_domain,node_jwt,node_auth_repository,node_refresh_repository,node_auth_postgres,node_auth_redis toneAmber
class node_profiles_api,node_profile_usecases,node_profile_domain,node_profile_repository,node_profiles_postgres,node_client toneMint
class node_grpc_support,node_auth_context,node_rate_limiter,node_gateway_redis toneRose
```

## Components

### HTTP Gateway

- [HTTP handlers](https://github.com/bladerunner322/orange-team-microservices/tree/main/services/gateway/internal/interfaces/http/handlers): `services/gateway/internal/interfaces/http/handlers`
- [HTTP middleware](https://github.com/bladerunner322/orange-team-microservices/tree/main/services/gateway/internal/interfaces/http/middleware): `services/gateway/internal/interfaces/http/middleware`
- [Gateway wiring](https://github.com/bladerunner322/orange-team-microservices/blob/main/services/gateway/internal/bootstrap/bootstrap.go): `services/gateway/internal/bootstrap/bootstrap.go`
- [Auth gRPC client](https://github.com/bladerunner322/orange-team-microservices/blob/main/services/gateway/internal/infrastructure/clients/auth_grpc.go): `services/gateway/internal/infrastructure/clients/auth_grpc.go`
- [Profiles gRPC client](https://github.com/bladerunner322/orange-team-microservices/blob/main/services/gateway/internal/infrastructure/clients/profiles_grpc.go): `services/gateway/internal/infrastructure/clients/profiles_grpc.go`

### Authentication

- [Auth gRPC API](https://github.com/bladerunner322/orange-team-microservices/blob/main/services/auth/internal/interfaces/authgrpc/server.go): `services/auth/internal/interfaces/authgrpc/server.go`
- [Auth workflows](https://github.com/bladerunner322/orange-team-microservices/tree/main/services/auth/internal/application/usecases): `services/auth/internal/application/usecases`
- [User and token rules](https://github.com/bladerunner322/orange-team-microservices/tree/main/services/auth/internal/domain): `services/auth/internal/domain`
- [JWT manager](https://github.com/bladerunner322/orange-team-microservices/blob/main/services/auth/internal/infrastructure/jwt/manager.go): `services/auth/internal/infrastructure/jwt/manager.go`
- [User repository](https://github.com/bladerunner322/orange-team-microservices/blob/main/services/auth/internal/infrastructure/postgres_repo/repository.go): `services/auth/internal/infrastructure/postgres_repo/repository.go`
- [Refresh-token repository](https://github.com/bladerunner322/orange-team-microservices/blob/main/services/auth/internal/infrastructure/redis_repo/repository.go): `services/auth/internal/infrastructure/redis_repo/repository.go`
- **Auth PostgreSQL**
- **Refresh-token Redis**

### User Profiles

- [Profiles gRPC API](https://github.com/bladerunner322/orange-team-microservices/blob/main/services/profiles/internal/interfaces/profilesgrpc/server.go): `services/profiles/internal/interfaces/profilesgrpc/server.go`
- [Profile workflows](https://github.com/bladerunner322/orange-team-microservices/tree/main/services/profiles/internal/application/usecases): `services/profiles/internal/application/usecases`
- [Profile rules](https://github.com/bladerunner322/orange-team-microservices/blob/main/services/profiles/internal/domain/profile.go): `services/profiles/internal/domain/profile.go`
- [Profile repository](https://github.com/bladerunner322/orange-team-microservices/blob/main/services/profiles/internal/infrastructure/postgres_repo/repository.go): `services/profiles/internal/infrastructure/postgres_repo/repository.go`
- **Profiles PostgreSQL**

### Shared Infrastructure

- [gRPC client support](https://github.com/bladerunner322/orange-team-microservices/blob/main/pkg/grpc/client/client.go): `pkg/grpc/client/client.go`
- [Identity context](https://github.com/bladerunner322/orange-team-microservices/blob/main/pkg/grpc/authctx/context.go): `pkg/grpc/authctx/context.go`
- [Rate limiter](https://github.com/bladerunner322/orange-team-microservices/blob/main/pkg/ratelimit/limiter.go): `pkg/ratelimit/limiter.go`
- [Gateway Redis](https://github.com/bladerunner322/orange-team-microservices/blob/main/pkg/redis/client.go): `pkg/redis/client.go`

### Other components

- **API caller**

## Connections

- API caller → HTTP handlers: sends HTTP
- HTTP handlers → HTTP middleware: uses middleware
- Gateway wiring → HTTP handlers: wires handlers (evidence: `services/gateway/internal/bootstrap/bootstrap.go`)
- Gateway wiring → HTTP middleware: wires middleware (evidence: `services/gateway/internal/bootstrap/bootstrap.go`)
- Gateway wiring → Auth gRPC client: wires client (evidence: `services/gateway/internal/bootstrap/bootstrap.go`)
- Gateway wiring → Profiles gRPC client: wires client (evidence: `services/gateway/internal/bootstrap/bootstrap.go`)
- HTTP handlers → Auth gRPC client: calls auth
- HTTP handlers → Profiles gRPC client: calls profiles
- Auth gRPC client → Auth gRPC API: calls gRPC
- Profiles gRPC client → Profiles gRPC API: calls gRPC
- Auth gRPC API → Auth workflows: executes workflows (evidence: `services/auth/internal/interfaces/authgrpc/server.go`)
- Auth workflows → User and token rules: applies rules
- Auth workflows → JWT manager: uses token manager
- Auth workflows → User repository: uses repository
- Auth workflows → Refresh-token repository: uses token store
- User repository → Auth PostgreSQL: reads and writes
- Refresh-token repository → Refresh-token Redis: reads and writes (evidence: `services/auth/internal/infrastructure/redis_repo/repository.go`)
- Profiles gRPC API → Profile workflows: executes workflows (evidence: `services/profiles/internal/interfaces/profilesgrpc/server.go`)
- Profile workflows → Profile rules: uses domain
- Profile workflows → Profile repository: uses repository
- Profile repository → Profiles PostgreSQL: reads and writes (evidence: `services/profiles/internal/infrastructure/postgres_repo/repository.go`)
- Gateway wiring → Gateway Redis: configures Redis (evidence: `services/gateway/internal/bootstrap/bootstrap.go`)
- Gateway wiring → Rate limiter: configures limiter (evidence: `services/gateway/internal/bootstrap/bootstrap.go`)
- Auth gRPC client → gRPC client support: creates connection (evidence: `services/gateway/internal/infrastructure/clients/auth_grpc.go`)
- gRPC client support → Identity context: propagates identity
