# geovanesv/user-service-rabbitmq architecture

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

- Interactive diagram: https://gitdiagram.com/geovanesv/user-service-rabbitmq
- Repository: https://github.com/geovanesv/user-service-rabbitmq

## Overview

This NestJS user microservice supports user registration and JWT-protected lookup, plus email/password and Passport login, token validation and refresh, profile, and logout routes. Registration checks for duplicates, hashes and stores the password, then publishes a `user.created` event for downstream consumers. Authentication verifies users through the user service and issues JWTs. The graph shows PostgreSQL and RabbitMQ as external systems; implementation details for some documented authentication routes and strategies are not fully sampled, so their internal flows are not expanded.

Main entry points: [`src/user/user.service.ts`](https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/user/user.service.ts) (User Service), [`src/auth/auth.controller.ts`](https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/auth/auth.controller.ts) (Auth Routes), [`src/app.module.ts`](https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/app.module.ts) (App Module), [`src/auth/auth.module.ts`](https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/auth/auth.module.ts) (Auth Module)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_user_domain["User Management"]
  node_user_controller["User Routes<br/>[user.controller.ts]"]
  node_user_service["User Service<br/>[user.service.ts]"]
  node_user_entity["User Entity<br/>[user.entity.ts]"]
end

subgraph group_auth_domain["Authentication"]
  node_auth_controller["Auth Routes<br/>[auth.controller.ts]"]
  node_auth_service["Auth Service<br/>[auth.service.ts]"]
  node_login_dto["Login DTO<br/>[auth.dto.ts]"]
  node_jwt_guard["JWT Guard<br/>[jwt-auth.guard.ts]"]
  node_local_guard["Local Guard"]
  node_jwt_strategy["JWT Strategy<br/>[jwt.strategy.ts]"]
end

subgraph group_messaging_domain["Event Messaging"]
  node_messaging_service["Messaging Service"]
end

subgraph group_platform["Application Platform"]
  node_bootstrap["Nest Bootstrap<br/>[main.ts]"]
  node_app_module["App Module<br/>[app.module.ts]"]
  node_user_module["User Module<br/>[user.module.ts]"]
  node_auth_module["Auth Module<br/>[auth.module.ts]"]
  node_messaging_module["Messaging Module"]
end

node_client(("API Client"))
node_postgres[("PostgreSQL")]
node_jwt_engine["JWT Service"]
node_rabbitmq["RabbitMQ"]

node_client -->|"calls user routes"| node_user_controller
node_client -->|"calls auth routes"| node_auth_controller
node_user_controller -->|"delegates to"| node_user_service
node_user_controller -->|"guards lookup"| node_jwt_guard
node_user_service -->|"persists users"| node_user_entity
node_user_service -->|"reads and writes"| node_postgres
node_user_service -->|"publishes event"| node_messaging_service
node_messaging_service -->|"publishes message"| node_rabbitmq
node_auth_controller -->|"delegates to"| node_auth_service
node_auth_controller -->|"guards routes"| node_jwt_guard
node_auth_controller -->|"guards Passport login"| node_local_guard
node_auth_service -->|"looks up users"| node_user_service
node_auth_service -->|"signs and verifies"| node_jwt_engine
node_bootstrap -->|"starts application"| node_app_module
node_app_module -->|"registers module"| node_user_module
node_app_module -->|"registers module"| node_auth_module
node_app_module -->|"registers module"| node_messaging_module
node_auth_module -->|"registers controller"| node_auth_controller
node_auth_module -->|"provides service"| node_auth_service
node_auth_module -->|"registers strategy"| node_jwt_strategy
node_user_module -->|"registers controller"| node_user_controller
node_user_module -->|"provides service"| node_user_service
node_messaging_module -->|"provides service"| node_messaging_service

click node_user_controller "https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/user/user.controller.ts"
click node_user_service "https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/user/user.service.ts"
click node_user_entity "https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/user/entities/user.entity.ts"
click node_auth_controller "https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/auth/auth.controller.ts"
click node_auth_service "https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/auth/auth.service.ts"
click node_login_dto "https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/auth/dto/auth.dto.ts"
click node_jwt_guard "https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/auth/jwt-auth.guard.ts"
click node_local_guard "https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/auth/local-auth.guard.ts"
click node_jwt_strategy "https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/auth/jwt.strategy.ts"
click node_messaging_service "https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/messaging/messaging.service.ts"
click node_bootstrap "https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/main.ts"
click node_app_module "https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/app.module.ts"
click node_user_module "https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/user/user.module.ts"
click node_auth_module "https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/auth/auth.module.ts"
click node_messaging_module "https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/messaging/messaging.module.ts"

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_user_controller,node_user_service,node_user_entity,node_client toneBlue
class node_auth_controller,node_auth_service,node_login_dto,node_jwt_guard,node_local_guard,node_jwt_strategy,node_postgres toneAmber
class node_messaging_service toneMint
class node_bootstrap,node_app_module,node_user_module,node_auth_module,node_messaging_module toneRose
class node_jwt_engine,node_rabbitmq toneIndigo
```

## Components

### User Management

- [User Routes](https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/user/user.controller.ts): `src/user/user.controller.ts`
- [User Service](https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/user/user.service.ts): `src/user/user.service.ts`
- [User Entity](https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/user/entities/user.entity.ts): `src/user/entities/user.entity.ts`

### Authentication

- [Auth Routes](https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/auth/auth.controller.ts): `src/auth/auth.controller.ts`
- [Auth Service](https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/auth/auth.service.ts): `src/auth/auth.service.ts`
- [Login DTO](https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/auth/dto/auth.dto.ts): `src/auth/dto/auth.dto.ts`
- [JWT Guard](https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/auth/jwt-auth.guard.ts): `src/auth/jwt-auth.guard.ts`
- [Local Guard](https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/auth/local-auth.guard.ts): `src/auth/local-auth.guard.ts`
- [JWT Strategy](https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/auth/jwt.strategy.ts): `src/auth/jwt.strategy.ts`

### Event Messaging

- [Messaging Service](https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/messaging/messaging.service.ts): `src/messaging/messaging.service.ts`

### Application Platform

- [Nest Bootstrap](https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/main.ts): `src/main.ts`
- [App Module](https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/app.module.ts): `src/app.module.ts`
- [User Module](https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/user/user.module.ts): `src/user/user.module.ts`
- [Auth Module](https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/auth/auth.module.ts): `src/auth/auth.module.ts`
- [Messaging Module](https://github.com/geovanesv/user-service-rabbitmq/blob/main/src/messaging/messaging.module.ts): `src/messaging/messaging.module.ts`

### Other components

- **API Client**
- **PostgreSQL**
- **JWT Service**
- **RabbitMQ**

## Connections

- API Client → User Routes: calls user routes (evidence: `README.md`)
- API Client → Auth Routes: calls auth routes (evidence: `README.md`)
- User Routes → User Service: delegates to (evidence: `src/user/user.controller.ts`)
- User Routes → JWT Guard: guards lookup (evidence: `src/user/user.controller.ts`)
- User Service → User Entity: persists users (evidence: `src/user/user.service.ts`)
- User Service → PostgreSQL: reads and writes (evidence: `src/user/user.service.ts`)
- User Service → Messaging Service: publishes event (evidence: `src/user/user.service.ts`)
- Messaging Service → RabbitMQ: publishes message (evidence: `src/messaging/messaging.service.ts`)
- Auth Routes → Auth Service: delegates to (evidence: `src/auth/auth.controller.ts`)
- Auth Routes → JWT Guard: guards routes (evidence: `src/auth/auth.controller.ts`)
- Auth Routes → Local Guard: guards Passport login (evidence: `src/auth/auth.controller.ts`)
- Auth Service → User Service: looks up users (evidence: `src/auth/auth.service.ts`)
- Auth Service → JWT Service: signs and verifies (evidence: `src/auth/auth.service.ts`)
- Nest Bootstrap → App Module: starts application (evidence: `src/main.ts`)
- App Module → User Module: registers module (evidence: `src/app.module.ts`)
- App Module → Auth Module: registers module (evidence: `src/app.module.ts`)
- App Module → Messaging Module: registers module (evidence: `src/app.module.ts`)
- Auth Module → Auth Routes: registers controller (evidence: `src/auth/auth.module.ts`)
- Auth Module → Auth Service: provides service (evidence: `src/auth/auth.module.ts`)
- Auth Module → JWT Strategy: registers strategy (evidence: `src/auth/auth.module.ts`)
- User Module → User Routes: registers controller (evidence: `src/user/user.module.ts`)
- User Module → User Service: provides service (evidence: `src/user/user.module.ts`)
- Messaging Module → Messaging Service: provides service (evidence: `src/messaging/messaging.module.ts`)
