# foll-project/foll_microservicio-iam architecture

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

- Interactive diagram: https://gitdiagram.com/foll-project/foll_microservicio-iam
- Repository: https://github.com/foll-project/foll_microservicio-iam

## Overview

This is an IAM microservice for user registration, login, profile/context lookup, and account-deletion requests. The main workflow enters through REST controllers, uses application services to validate credentials and perform domain operations, and persists users and deletion state. Deletion requests also enter an outbox-driven integration flow; the service publishes events through RabbitMQ and registers a consumer for completion events. The graph reflects relationships shown in sampled source and the source index; several registered adapters and the consumer implementation were not excerpted, so their internal behavior is not detailed.

Main entry points: [`IAM/Application/Internal/CommandServices/UserCommandService.cs`](https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Application/Internal/CommandServices/UserCommandService.cs) (User commands), [`IAM/Application/Internal/QueryServices/UserQueryService.cs`](https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Application/Internal/QueryServices/UserQueryService.cs) (User queries), [`IAM/Interfaces/REST/AuthenticationController.cs`](https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Interfaces/REST/AuthenticationController.cs) (Authentication API), [`Shared/Infrastructure/Persistence/EFC/Configuration/AppDbContext.cs`](https://github.com/foll-project/foll_microservicio-iam/blob/main/Shared/Infrastructure/Persistence/EFC/Configuration/AppDbContext.cs) (IAM database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["REST interface"]
  node_auth_api["Authentication API"]
  node_internal_api["Internal user APIs"]
end

subgraph group_app["Application services"]
  node_command["User commands"]
  node_query["User queries"]
  node_hashing["Password hashing"]
  node_tokens["JWT tokens<br/>[JwtTokenService.cs]"]
end

subgraph group_domain["IAM domain"]
  node_user["User account<br/>[User.cs]"]
  node_deletion["Deletion request"]
  node_deletion_event["Deletion event"]
end

subgraph group_infra["Persistence and messaging"]
  node_user_repo["User repository<br/>[UserRepository.cs]"]
  node_database[("IAM database<br/>[AppDbContext.cs]")]
  node_outbox_service["Outbox event staging"]
  node_outbox_publisher["Outbox dispatcher"]
  node_event_publisher["Integration publisher"]
  node_rabbit_connection["RabbitMQ connection"]
  node_completion_consumer["Deletion completion consumer"]
end

node_client(("API client"))
node_broker["RabbitMQ broker"]

node_client -->|"sends requests"| node_auth_api
node_auth_api -->|"handles commands"| node_command
node_auth_api -->|"handles queries"| node_query
node_internal_api -->|"queries users"| node_query
node_command -->|"reads and writes"| node_user_repo
node_query -->|"reads users"| node_user_repo
node_command -->|"verifies and hashes"| node_hashing
node_query -->|"verifies password"| node_hashing
node_query -->|"generates token"| node_tokens
node_command -->|"creates request"| node_deletion
node_command -->|"stages event"| node_outbox_service
node_outbox_service -->|"stores outbox message"| node_database
node_outbox_publisher -->|"loads and updates"| node_database
node_outbox_publisher -->|"publishes events"| node_event_publisher
node_event_publisher -.->|"sends events"| node_broker
node_rabbit_connection -.->|"connects to"| node_broker
node_completion_consumer -.->|"updates completion state"| node_database

click node_auth_api "https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Interfaces/REST/AuthenticationController.cs"
click node_internal_api "https://github.com/foll-project/foll_microservicio-iam/tree/main/IAM/Interfaces/Internal"
click node_command "https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Application/Internal/CommandServices/UserCommandService.cs"
click node_query "https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Application/Internal/QueryServices/UserQueryService.cs"
click node_hashing "https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Infrastructure/Hashing/BcryptHashingService.cs"
click node_tokens "https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Infrastructure/Tokens/JwtTokenService.cs"
click node_user "https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Domain/Model/Entities/User.cs"
click node_deletion "https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Domain/Model/Entities/AccountDeletionRequest.cs"
click node_deletion_event "https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Application/IntegrationEvents/AccountDeletionRequestedIntegrationEvent.cs"
click node_user_repo "https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Infrastructure/Persistence/EFC/Repositories/UserRepository.cs"
click node_database "https://github.com/foll-project/foll_microservicio-iam/blob/main/Shared/Infrastructure/Persistence/EFC/Configuration/AppDbContext.cs"
click node_outbox_service "https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Infrastructure/Messaging/Outbox/OutboxUserEventService.cs"
click node_outbox_publisher "https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Infrastructure/Messaging/Outbox/OutboxPublisherBackgroundService.cs"
click node_event_publisher "https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Infrastructure/Messaging/RabbitMq/RabbitMqIntegrationEventPublisher.cs"
click node_rabbit_connection "https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Infrastructure/Messaging/RabbitMq/RabbitMqConnection.cs"
click node_completion_consumer "https://github.com/foll-project/foll_microservicio-iam/tree/main/Shared/Infrastructure/Messaging"

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_auth_api,node_internal_api,node_client toneBlue
class node_command,node_query,node_hashing,node_tokens toneAmber
class node_user,node_deletion,node_deletion_event toneMint
class node_user_repo,node_database,node_outbox_service,node_outbox_publisher,node_event_publisher,node_rabbit_connection,node_completion_consumer toneRose
class node_broker toneIndigo
```

## Components

### REST interface

- [Authentication API](https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Interfaces/REST/AuthenticationController.cs): `IAM/Interfaces/REST/AuthenticationController.cs`
- [Internal user APIs](https://github.com/foll-project/foll_microservicio-iam/tree/main/IAM/Interfaces/Internal): `IAM/Interfaces/Internal`

### Application services

- [User commands](https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Application/Internal/CommandServices/UserCommandService.cs): `IAM/Application/Internal/CommandServices/UserCommandService.cs`
- [User queries](https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Application/Internal/QueryServices/UserQueryService.cs): `IAM/Application/Internal/QueryServices/UserQueryService.cs`
- [Password hashing](https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Infrastructure/Hashing/BcryptHashingService.cs): `IAM/Infrastructure/Hashing/BcryptHashingService.cs`
- [JWT tokens](https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Infrastructure/Tokens/JwtTokenService.cs): `IAM/Infrastructure/Tokens/JwtTokenService.cs`

### IAM domain

- [User account](https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Domain/Model/Entities/User.cs): `IAM/Domain/Model/Entities/User.cs`
- [Deletion request](https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Domain/Model/Entities/AccountDeletionRequest.cs): `IAM/Domain/Model/Entities/AccountDeletionRequest.cs`
- [Deletion event](https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Application/IntegrationEvents/AccountDeletionRequestedIntegrationEvent.cs): `IAM/Application/IntegrationEvents/AccountDeletionRequestedIntegrationEvent.cs`

### Persistence and messaging

- [User repository](https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Infrastructure/Persistence/EFC/Repositories/UserRepository.cs): `IAM/Infrastructure/Persistence/EFC/Repositories/UserRepository.cs`
- [IAM database](https://github.com/foll-project/foll_microservicio-iam/blob/main/Shared/Infrastructure/Persistence/EFC/Configuration/AppDbContext.cs): `Shared/Infrastructure/Persistence/EFC/Configuration/AppDbContext.cs`
- [Outbox event staging](https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Infrastructure/Messaging/Outbox/OutboxUserEventService.cs): `IAM/Infrastructure/Messaging/Outbox/OutboxUserEventService.cs`
- [Outbox dispatcher](https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Infrastructure/Messaging/Outbox/OutboxPublisherBackgroundService.cs): `IAM/Infrastructure/Messaging/Outbox/OutboxPublisherBackgroundService.cs`
- [Integration publisher](https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Infrastructure/Messaging/RabbitMq/RabbitMqIntegrationEventPublisher.cs): `IAM/Infrastructure/Messaging/RabbitMq/RabbitMqIntegrationEventPublisher.cs`
- [RabbitMQ connection](https://github.com/foll-project/foll_microservicio-iam/blob/main/IAM/Infrastructure/Messaging/RabbitMq/RabbitMqConnection.cs): `IAM/Infrastructure/Messaging/RabbitMq/RabbitMqConnection.cs`
- [Deletion completion consumer](https://github.com/foll-project/foll_microservicio-iam/tree/main/Shared/Infrastructure/Messaging): `Shared/Infrastructure/Messaging`

### Other components

- **API client**
- **RabbitMQ broker**

## Connections

- API client → Authentication API: sends requests (evidence: `IAM/Interfaces/REST/AuthenticationController.cs`)
- Authentication API → User commands: handles commands (evidence: `IAM/Interfaces/REST/AuthenticationController.cs`)
- Authentication API → User queries: handles queries (evidence: `IAM/Interfaces/REST/AuthenticationController.cs`)
- Internal user APIs → User queries: queries users (evidence: `IAM/Interfaces/Internal/NotificationRecipientController.cs`)
- User commands → User repository: reads and writes (evidence: `IAM/Application/Internal/CommandServices/UserCommandService.cs`)
- User queries → User repository: reads users (evidence: `IAM/Application/Internal/QueryServices/UserQueryService.cs`)
- User commands → Password hashing: verifies and hashes (evidence: `IAM/Application/Internal/CommandServices/UserCommandService.cs`)
- User queries → Password hashing: verifies password (evidence: `IAM/Application/Internal/QueryServices/UserQueryService.cs`)
- User queries → JWT tokens: generates token (evidence: `IAM/Application/Internal/QueryServices/UserQueryService.cs`)
- User commands → Deletion request: creates request (evidence: `IAM/Application/Internal/CommandServices/UserCommandService.cs`)
- User commands → Outbox event staging: stages event (evidence: `IAM/Application/Internal/CommandServices/UserCommandService.cs`)
- Outbox event staging → IAM database: stores outbox message (evidence: `IAM/Infrastructure/Messaging/Outbox/OutboxUserEventService.cs`)
- Outbox dispatcher → IAM database: loads and updates (evidence: `IAM/Infrastructure/Messaging/Outbox/OutboxPublisherBackgroundService.cs`)
- Outbox dispatcher → Integration publisher: publishes events (evidence: `IAM/Infrastructure/Messaging/Outbox/OutboxPublisherBackgroundService.cs`)
- Integration publisher → RabbitMQ broker: sends events
- RabbitMQ connection → RabbitMQ broker: connects to
- Deletion completion consumer → IAM database: updates completion state (evidence: `Shared/Infrastructure/Messaging/IntegrationEventHandler.cs`)
