# geovanesv/order-user-microservices architecture

> Architecture diagram of the GitHub repository geovanesv/order-user-microservices, 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/order-user-microservices
- Repository: https://github.com/geovanesv/order-user-microservices

## Overview

This is a NestJS user-and-order microservice demo. The main workflow creates a user over HTTP, persists it in PostgreSQL, publishes a `user.created` event through RabbitMQ, and has the order service consume and process it. The user service also exposes login, JWT-protected user lookup, and token-related endpoints. The README documents these capabilities; sampled source confirms the user creation, persistence, publishing, and consumer behavior. Some infrastructure wiring is documented but not all deployment configuration was sampled.

Main entry points: [`user-service/src/user/user.controller.ts`](https://github.com/geovanesv/order-user-microservices/blob/main/user-service/src/user/user.controller.ts) (User API), [`user-service/src/user/user.service.ts`](https://github.com/geovanesv/order-user-microservices/blob/main/user-service/src/user/user.service.ts) (User management), [`user-service/src/auth/auth.controller.ts`](https://github.com/geovanesv/order-user-microservices/blob/main/user-service/src/auth/auth.controller.ts) (Auth API), [`user-service/src/auth/auth.service.ts`](https://github.com/geovanesv/order-user-microservices/blob/main/user-service/src/auth/auth.service.ts) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_user["User service"]
  node_user_api["User API<br/>[user.controller.ts]"]
  node_user_logic["User management<br/>[user.service.ts]"]
  node_user_db[("PostgreSQL")]
end

subgraph group_auth["Authentication"]
  node_auth_api["Auth API<br/>[auth.controller.ts]"]
  node_auth_logic["Authentication<br/>[auth.service.ts]"]
  node_auth_dto["Auth DTOs<br/>[auth.dto.ts]"]
  node_jwt_guard["JWT guard<br/>[jwt-auth.guard.ts]"]
  node_jwt_strategy["JWT strategy<br/>[jwt.strategy.ts]"]
end

subgraph group_events["Event transport"]
  node_rabbit["RabbitMQ"]
  node_publisher["Event publisher"]
end

subgraph group_orders["Order service"]
  node_consumer["Event consumer"]
  node_order_http["Health endpoint<br/>[app.controller.ts]"]
  node_order_health["Health response<br/>[app.service.ts]"]
end

node_client(("HTTP client"))

node_client -->|"creates user"| node_user_api
node_user_api -->|"calls"| node_user_logic
node_user_logic -->|"persists user"| node_user_db
node_user_logic -->|"publishes event"| node_publisher
node_publisher -->|"publishes message"| node_rabbit
node_rabbit -->|"delivers event"| node_consumer
node_consumer -->|"processes user"| node_consumer
node_client -->|"requests login"| node_auth_api
node_auth_api -->|"calls"| node_auth_logic
node_auth_logic -->|"looks up user"| node_user_logic
node_auth_logic -->|"returns token data"| node_auth_dto
node_client -->|"requests protected lookup"| node_user_api
node_user_api -->|"guards lookup"| node_jwt_guard
node_auth_api -->|"guards routes"| node_jwt_guard
node_client -->|"checks health"| node_order_http
node_order_http -->|"calls"| node_order_health

click node_user_api "https://github.com/geovanesv/order-user-microservices/blob/main/user-service/src/user/user.controller.ts"
click node_user_logic "https://github.com/geovanesv/order-user-microservices/blob/main/user-service/src/user/user.service.ts"
click node_auth_api "https://github.com/geovanesv/order-user-microservices/blob/main/user-service/src/auth/auth.controller.ts"
click node_auth_logic "https://github.com/geovanesv/order-user-microservices/blob/main/user-service/src/auth/auth.service.ts"
click node_auth_dto "https://github.com/geovanesv/order-user-microservices/blob/main/user-service/src/auth/dto/auth.dto.ts"
click node_jwt_guard "https://github.com/geovanesv/order-user-microservices/blob/main/user-service/src/auth/jwt-auth.guard.ts"
click node_jwt_strategy "https://github.com/geovanesv/order-user-microservices/blob/main/user-service/src/auth/jwt.strategy.ts"
click node_publisher "https://github.com/geovanesv/order-user-microservices/blob/main/user-service/src/messaging/messaging.service.ts"
click node_consumer "https://github.com/geovanesv/order-user-microservices/blob/main/order-service/src/messaging/messaging.service.ts"
click node_order_http "https://github.com/geovanesv/order-user-microservices/blob/main/order-service/src/app.controller.ts"
click node_order_health "https://github.com/geovanesv/order-user-microservices/blob/main/order-service/src/app.service.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_api,node_user_logic,node_user_db,node_client toneBlue
class node_auth_api,node_auth_logic,node_auth_dto,node_jwt_guard,node_jwt_strategy toneAmber
class node_rabbit,node_publisher toneMint
class node_consumer,node_order_http,node_order_health toneRose
```

## Components

### User service

- [User API](https://github.com/geovanesv/order-user-microservices/blob/main/user-service/src/user/user.controller.ts): `user-service/src/user/user.controller.ts`
- [User management](https://github.com/geovanesv/order-user-microservices/blob/main/user-service/src/user/user.service.ts): `user-service/src/user/user.service.ts`
- **PostgreSQL**

### Authentication

- [Auth API](https://github.com/geovanesv/order-user-microservices/blob/main/user-service/src/auth/auth.controller.ts): `user-service/src/auth/auth.controller.ts`
- [Authentication](https://github.com/geovanesv/order-user-microservices/blob/main/user-service/src/auth/auth.service.ts): `user-service/src/auth/auth.service.ts`
- [Auth DTOs](https://github.com/geovanesv/order-user-microservices/blob/main/user-service/src/auth/dto/auth.dto.ts): `user-service/src/auth/dto/auth.dto.ts`
- [JWT guard](https://github.com/geovanesv/order-user-microservices/blob/main/user-service/src/auth/jwt-auth.guard.ts): `user-service/src/auth/jwt-auth.guard.ts`
- [JWT strategy](https://github.com/geovanesv/order-user-microservices/blob/main/user-service/src/auth/jwt.strategy.ts): `user-service/src/auth/jwt.strategy.ts`

### Event transport

- **RabbitMQ**
- [Event publisher](https://github.com/geovanesv/order-user-microservices/blob/main/user-service/src/messaging/messaging.service.ts): `user-service/src/messaging/messaging.service.ts`

### Order service

- [Event consumer](https://github.com/geovanesv/order-user-microservices/blob/main/order-service/src/messaging/messaging.service.ts): `order-service/src/messaging/messaging.service.ts`
- [Health endpoint](https://github.com/geovanesv/order-user-microservices/blob/main/order-service/src/app.controller.ts): `order-service/src/app.controller.ts`
- [Health response](https://github.com/geovanesv/order-user-microservices/blob/main/order-service/src/app.service.ts): `order-service/src/app.service.ts`

### Other components

- **HTTP client**

## Connections

- HTTP client → User API: creates user (evidence: `README.md`)
- User API → User management: calls (evidence: `user-service/src/user/user.controller.ts`)
- User management → PostgreSQL: persists user (evidence: `user-service/src/user/user.service.ts`)
- User management → Event publisher: publishes event (evidence: `user-service/src/user/user.service.ts`)
- Event publisher → RabbitMQ: publishes message (evidence: `user-service/src/messaging/messaging.service.ts`)
- RabbitMQ → Event consumer: delivers event (evidence: `README.md`)
- Event consumer → Event consumer: processes user (evidence: `order-service/src/messaging/messaging.service.ts`)
- HTTP client → Auth API: requests login (evidence: `README.md`)
- Auth API → Authentication: calls (evidence: `user-service/src/auth/auth.controller.ts`)
- Authentication → User management: looks up user (evidence: `user-service/src/auth/auth.service.ts`)
- Authentication → Auth DTOs: returns token data (evidence: `user-service/src/auth/auth.service.ts`)
- HTTP client → User API: requests protected lookup (evidence: `README.md`)
- User API → JWT guard: guards lookup (evidence: `user-service/src/user/user.controller.ts`)
- Auth API → JWT guard: guards routes (evidence: `user-service/src/auth/auth.controller.ts`)
- HTTP client → Health endpoint: checks health (evidence: `README.md`)
- Health endpoint → Health response: calls (evidence: `order-service/src/app.controller.ts`)
