# marcosobiang/servidor_hotty_webflux architecture

> Architecture diagram of the GitHub repository marcosobiang/servidor_hotty_webflux, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/marcosobiang/servidor_hotty_webflux
- Repository: https://github.com/marcosobiang/servidor_hotty_webflux

## Overview

1. **Overall shape**
This is a **modular monolith / service suite** in one Java 21 + Spring Boot 3 codebase, organized by bounded context under `com.hotty.*`. The code is heavily **reactive (WebFlux / Reactor)** and relies on **MongoDB**, **Redis**, and **MinIO** as the main backing services.

2. **`common` is the orchestration core**
`common` is not just utilities: it contains shared **use cases**, **transaction support**, **event publishers**, **push-notification strategies**, localization, and global exception handling. This is the main cross-module boundary where coordinated workflows live, especially flows that must update multiple domains consistently.

3. **Edge and security layer**
`gateway_server` is the ingress boundary. It owns **JWT creation/validation**, security filters, and an **OAuth2 login controller**. It also contains a Feign client into auth-related endpoints, so external traffic is authenticated and normalized before reaching domain services.

4. **Identity and session management**
`auth_service` handles authentication state: user auth records, auth tokens, Google auth strategy support, JWT encode/decode, refresh/logout/revocation use cases, and token expiration scheduling. It also includes a cache repository, indicating token/session state is split between persistent storage and fast access.

5. **User domain as the main business hub**
`user_service` is the largest domain module and stores user profile state: characteristics, location, settings, rewards, notifications, subscription state, and device notification tokens. It also handles **geospatial querying**, profile discovery settings, credit/purchase logic, image updates, and RevenueCat purchase processing. This is the central persistent profile model around which other services synchronize.

6. **Interactions and matching**
`likes_service` owns the “like” relationship and its lifecycle: create, update, delete, fetch, bulk delete by user, and user-picture propagation. This module is likely one of the main consumers of cross-service orchestration because a like/match affects discovery, notifications, and downstream chat creation.

7. **Chat and message persistence**
`chat_service` contains both **chat thread management** and **message management**. Its repository and use-case split shows a clean flow from controller → use case → repo/model. It also includes `UpdateUserPictureInChatsUseCase`, which implies chat records denormalize profile metadata and need bulk synchronization when user avatars change.

8. **Realtime delivery plane**
`realtime_service` is the WebSocket fan-out boundary. It manages active WebSocket sessions, a realtime handler, and a subscriber that listens for user events. In the architecture, this service is the last hop after event publication: it turns internal events into live client delivery.

9. **Event-driven backbone**
The README’s Redis Pub/Sub design is reflected in `common` and `realtime_service`. `common` contains publishers for chat, likes, user, and token revocation events, while `realtime_service` consumes them. This separates **durable state changes** from **live notification delivery**.

10. **Media storage boundary**
`media_service` is a thin boundary over **object storage**, backed locally by MinIO data in the repo. This service is responsible for file/object access rather than database persistence, which keeps binary assets out of Mongo and makes image/profile media a separate subsystem.

11. **Subscriptions and webhook ingestion**
`subscriptions_service` handles subscription lifecycle and external billing integration, including **RevenueCat webhook payloads**, webhook processing, subscription stream controllers, and notification service. This module bridges an external SaaS billing provider into internal user subscription state.

12. **Cross-service integration style**
Inter-service communication is a mix of **HTTP clients** (`Feign`, `WebClient`), **event publication/subscription** (`Redis`), and shared domain contracts in `common`. The boundaries are intentionally asymmetric: domain services own persistence and local rules, while `common` coordinates multi-step workflows and side effects.

13. **Persistence model**
MongoDB is the primary database across domains, with transaction support centralized in `common/common_transactions`. Redis is used both as cache/session support and as the event transport. The presence of Mongo transaction helpers suggests some workflows span multiple Mongo writes and need retry handling.

14. **Operational/runtime concerns**
`docker-compose.yml` and the included MinIO data directory indicate the repo is set up for local or self-hosted infrastructure. The codebase also includes extensive test and refactoring docs around webhooks, subscriptions, token revocation, and message flows, which reinforces that those are important architectural hot spots.

15. **What to draw in a diagram**
A good diagram should show: **Gateway at the edge**, **auth/user/likes/chat/media/subscriptions as domain services**, **common as the orchestration/event hub**, **realtime as the WebSocket delivery layer**, and **Mongo/Redis/MinIO as shared infrastructure**. The primary data flow is: client request → gateway → domain service → persistence → event publication in `common` → realtime/subscription/notification consumers → client push or downstream sync.

Main entry points: [`src/main/java/com/hotty/common/services/EventPublishers`](https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/common/services/EventPublishers) (Event publishers), [`src/main/java/com/hotty/common/common_usecases`](https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/common/common_usecases) (Shared use cases), [`src/main/java/com/hotty/gateway_server`](https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/gateway_server) (Gateway), [`src/main/java/com/hotty/common`](https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/common) (Common)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["Edge"]
  node_gateway_server["Gateway<br/>edge ingress"]
  node_gateway_jwt["JWT<br/>token security"]
  node_gateway_filters["Filters"]
  node_gateway_oauth2["OAuth2 login<br/>login controller"]
end

subgraph group_core["Core"]
  node_common["Common<br/>orchestration core"]
  node_common_usecases["Shared use cases<br/>workflow coordination"]
  node_common_events["Event publishers<br/>redis pubsub"]
  node_common_tx["Mongo tx<br/>transaction support"]
  node_common_push["Push notifications<br/>notification strategies"]
end

subgraph group_domains["Domain services"]
  node_auth_service["Auth<br/>identity/session service"]
  node_user_service["Users<br/>profile hub"]
  node_likes_service["Likes<br/>relationship service"]
  node_chat_service["Chat<br/>conversation service"]
  node_subscriptions_service["Subscriptions<br/>billing service"]
  node_media_service["Media<br/>object storage service"]
end

subgraph group_delivery["Delivery"]
  node_realtime_service["Realtime<br/>websocket fan-out"]
  node_realtime_subscriber["Event subscriber<br/>event consumer"]
end

subgraph group_infra["Infrastructure"]
  node_mongo[("MongoDB<br/>primary datastore")]
  node_redis[("Redis<br/>cache and bus")]
  node_minio[("MinIO<br/>object storage")]
end

node_gateway_server -->|"uses"| node_gateway_jwt
node_gateway_server -->|"protects"| node_gateway_filters
node_gateway_server -->|"exposes"| node_gateway_oauth2
node_gateway_server -->|"routes auth"| node_auth_service
node_common -->|"contains"| node_common_usecases
node_common -->|"contains"| node_common_events
node_common -->|"contains"| node_common_tx
node_common -->|"contains"| node_common_push
node_common_usecases -->|"coordinates"| node_user_service
node_common_usecases -->|"coordinates"| node_likes_service
node_common_usecases -->|"coordinates"| node_chat_service
node_common_usecases -->|"coordinates"| node_media_service
node_common_events -->|"publishes"| node_redis
node_auth_service -->|"persists"| node_mongo
node_auth_service -->|"caches"| node_redis
node_user_service -->|"persists"| node_mongo
node_user_service -->|"publishes"| node_common_events
node_likes_service -->|"persists"| node_mongo
node_likes_service -->|"publishes"| node_common_events
node_chat_service -->|"persists"| node_mongo
node_chat_service -->|"publishes"| node_common_events
node_subscriptions_service -->|"persists"| node_mongo
node_subscriptions_service -->|"publishes"| node_common_events
node_media_service -->|"stores in"| node_minio
node_realtime_service -->|"subscribes"| node_redis
node_realtime_service -->|"contains"| node_realtime_subscriber
node_realtime_subscriber -->|"consumes"| node_common_events
node_common_push -.->|"supports"| node_realtime_service

click node_gateway_server "https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/gateway_server"
click node_gateway_jwt "https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/gateway_server/componentes/JWT"
click node_gateway_filters "https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/gateway_server/componentes/securityFilters"
click node_gateway_oauth2 "https://github.com/marcosobiang/servidor_hotty_webflux/blob/main/src/main/java/com/hotty/gateway_server/controllers/OAuth2LoginController.java"
click node_common "https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/common"
click node_common_usecases "https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/common/common_usecases"
click node_common_events "https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/common/services/EventPublishers"
click node_common_tx "https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/common/common_transactions"
click node_common_push "https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/common/services/PushNotifications"
click node_auth_service "https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/auth_service"
click node_user_service "https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/user_service"
click node_likes_service "https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/likes_service"
click node_chat_service "https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/chat_service"
click node_subscriptions_service "https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/subscriptions_service"
click node_media_service "https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/media_service"
click node_realtime_service "https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/realtime_service"
click node_realtime_subscriber "https://github.com/marcosobiang/servidor_hotty_webflux/blob/main/src/main/java/com/hotty/realtime_service/subscriber/UserEventSubscriber.java"
click node_minio "https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/minio/data"

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_server,node_gateway_jwt,node_gateway_filters,node_gateway_oauth2 toneBlue
class node_common,node_common_usecases,node_common_events,node_common_tx,node_common_push toneAmber
class node_auth_service,node_user_service,node_likes_service,node_chat_service,node_subscriptions_service,node_media_service toneMint
class node_realtime_service,node_realtime_subscriber toneRose
class node_mongo,node_redis,node_minio toneIndigo
```

## Components

### Edge

Ingress, auth normalization, and request security.

- [Gateway](https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/gateway_server): edge ingress · JWT security boundary and OAuth2 login entrypoint. · `src/main/java/com/hotty/gateway_server`
- [JWT](https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/gateway_server/componentes/JWT): token security · Creates, validates, and decodes gateway-issued tokens. · `src/main/java/com/hotty/gateway_server/componentes/JWT`
- [Filters](https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/gateway_server/componentes/securityFilters): security filters · Enriches requests with user identity and rejects invalid tokens. · `src/main/java/com/hotty/gateway_server/componentes/securityFilters`
- [OAuth2 login](https://github.com/marcosobiang/servidor_hotty_webflux/blob/main/src/main/java/com/hotty/gateway_server/controllers/OAuth2LoginController.java): login controller · Handles external login flow before routing into domain services. · `src/main/java/com/hotty/gateway_server/controllers/OAuth2LoginController.java`

### Core

Cross-domain orchestration, shared contracts, and eventing.

- [Common](https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/common): orchestration core · Shared workflows, transaction helpers, event publishers, push strategies, and global errors. · `src/main/java/com/hotty/common`
- [Shared use cases](https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/common/common_usecases): workflow coordination · Coordinates cross-domain actions such as create user, likes, picture updates, and accept/reveal flows. · `src/main/java/com/hotty/common/common_usecases`
- [Event publishers](https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/common/services/EventPublishers): redis pubsub · Publishes chat, like, user, and token-revocation events. · `src/main/java/com/hotty/common/services/EventPublishers`
- [Mongo tx](https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/common/common_transactions): transaction support · Centralized Mongo transaction configuration and retry helper. · `src/main/java/com/hotty/common/common_transactions`
- [Push notifications](https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/common/services/PushNotifications): notification strategies · Push delivery strategies, localization, and notification text selection. · `src/main/java/com/hotty/common/services/PushNotifications`

### Domain services

Primary bounded contexts and persistence owners.

- [Auth](https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/auth_service): identity/session service · Authentication records, JWT lifecycle, refresh/logout/revocation, and token expiration scheduling. · `src/main/java/com/hotty/auth_service`
- [Users](https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/user_service): profile hub · Primary user profile store with settings, rewards, location, discovery, notifications, and purchases. · `src/main/java/com/hotty/user_service`
- [Likes](https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/likes_service): relationship service · Manages like lifecycle and user-picture propagation. · `src/main/java/com/hotty/likes_service`
- [Chat](https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/chat_service): conversation service · Owns chat threads, messages, and chat-avatar synchronization. · `src/main/java/com/hotty/chat_service`
- [Subscriptions](https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/subscriptions_service): billing service · Processes RevenueCat webhooks and subscription state updates. · `src/main/java/com/hotty/subscriptions_service`
- [Media](https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/media_service): object storage service · Thin boundary over MinIO-backed file and image access. · `src/main/java/com/hotty/media_service`

### Delivery

Realtime fan-out and client push paths.

- [Realtime](https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/src/main/java/com/hotty/realtime_service): websocket fan-out · Maintains live sessions and consumes internal events for client push. · `src/main/java/com/hotty/realtime_service`
- [Event subscriber](https://github.com/marcosobiang/servidor_hotty_webflux/blob/main/src/main/java/com/hotty/realtime_service/subscriber/UserEventSubscriber.java): event consumer · Listens for user events and forwards them to active websocket sessions. · `src/main/java/com/hotty/realtime_service/subscriber/UserEventSubscriber.java`

### Infrastructure

Backing services used by multiple modules.

- **MongoDB**: primary datastore · Shared document persistence across domain modules.
- **Redis**: cache and bus · Used for cache/session state and pub-sub event transport.
- [MinIO](https://github.com/marcosobiang/servidor_hotty_webflux/tree/main/minio/data): object storage · Backs media and image storage. · `minio/data`

## Connections

- Gateway → JWT: uses · Gateway delegates token creation and validation.
- Gateway → Filters: protects · Security filters normalize identity on inbound requests.
- Gateway → OAuth2 login: exposes · OAuth2 login is part of the ingress boundary.
- Gateway → Auth: routes auth · Ingress forwards authenticated flows to the auth module.
- Common → Shared use cases: contains · Shared orchestration lives here.
- Common → Event publishers: contains · Event publication is centralized in common.
- Common → Mongo tx: contains · Transaction support is centralized in common.
- Common → Push notifications: contains · Push notification logic and localization live here.
- Shared use cases → Users: coordinates · Creates and updates user state across workflows.
- Shared use cases → Likes: coordinates · Accept/reveal like flows bridge into likes state.
- Shared use cases → Chat: coordinates · Like acceptance and user updates can create or sync chats.
- Shared use cases → Media: coordinates · Picture update workflows involve media references.
- Event publishers → Redis: publishes · Internal events are emitted through Redis pub/sub.
- Auth → MongoDB: persists · Auth records and tokens are stored in MongoDB.
- Auth → Redis: caches · Fast token/session state is split into Redis.
- Users → MongoDB: persists · User profile, settings, rewards, and subscription state are stored in MongoDB.
- Users → Event publishers: publishes · User changes can drive downstream realtime updates.
- Likes → MongoDB: persists · Like relationships are stored in MongoDB.
- Likes → Event publishers: publishes · Like lifecycle emits downstream events.
- Chat → MongoDB: persists · Chats and messages are persisted in MongoDB.
- Chat → Event publishers: publishes · Chat activity is propagated through shared events.
- Subscriptions → MongoDB: persists · Subscription records are stored in MongoDB.
- Subscriptions → Event publishers: publishes · Subscription changes can notify other modules.
- Media → MinIO: stores in · Media module fronts object storage.
- Realtime → Redis: subscribes · Realtime consumes pub/sub streams from Redis.
- Realtime → Event subscriber: contains · Subscriber bridges events into websocket delivery.
- Event subscriber → Event publishers: consumes · Consumes user and related domain events.
- Push notifications → Realtime: supports · Push strategies complement live client delivery.
