How marcosobiang/servidor_hotty_webflux works
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: EventPublishers Event publishers · common_usecases Shared use cases · gateway_server Gateway · common Common
Components 20
Edge
Ingress, auth normalization, and request security.
- Gateway · JWT security boundary and OAuth2 login entrypoint.
src/main/java/com/hotty/gateway_server - JWT · Creates, validates, and decodes gateway-issued tokens.
src/main/java/com/hotty/gateway_server/componentes/JWT - Filters · Enriches requests with user identity and rejects invalid tokens.
src/main/java/com/hotty/gateway_server/componentes/securityFilters - OAuth2 login · 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 · Shared workflows, transaction helpers, event publishers, push strategies, and global errors.
src/main/java/com/hotty/common - Shared use cases · 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 · Publishes chat, like, user, and token-revocation events.
src/main/java/com/hotty/common/services/EventPublishers - Mongo tx · Centralized Mongo transaction configuration and retry helper.
src/main/java/com/hotty/common/common_transactions - Push notifications · 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 · Authentication records, JWT lifecycle, refresh/logout/revocation, and token expiration scheduling.
src/main/java/com/hotty/auth_service - Users · Primary user profile store with settings, rewards, location, discovery, notifications, and purchases.
src/main/java/com/hotty/user_service - Likes · Manages like lifecycle and user-picture propagation.
src/main/java/com/hotty/likes_service - Chat · Owns chat threads, messages, and chat-avatar synchronization.
src/main/java/com/hotty/chat_service - Subscriptions · Processes RevenueCat webhooks and subscription state updates.
src/main/java/com/hotty/subscriptions_service - Media · 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 · Maintains live sessions and consumes internal events for client push.
src/main/java/com/hotty/realtime_service - Event subscriber · 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 · Shared document persistence across domain modules.
- Redis · Used for cache/session state and pub-sub event transport.
- MinIO · Backs media and image storage.
minio/data
Connections 28
- 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.