# marcosobiang/hotty2 architecture

> Architecture diagram of the GitHub repository marcosobiang/hotty2, 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/hotty2
- Repository: https://github.com/marcosobiang/hotty2

## Overview

1. **Overall shape**
   - This is a Flutter/Dart client for a social app called **Hotty**, targeting mobile plus desktop/web via the standard Flutter platform folders.
   - The codebase is organized as a **modular monolith**: each business area owns its own models, repositories, use cases, state, and views.

2. **App entry and bootstrapping**
   - `lib/main.dart` and `lib/main_starter.dart` are the entry points into the app lifecycle.
   - Startup is not “everything at once”; instead, the app uses **starter classes** under `lib/starters/` to control which modules are initialized before sign-in and after a user session is established.

3. **Lifecycle orchestration**
   - Starters are the main boundary for resource management: they initialize and dispose modules, especially those that hold subscriptions, WebSocket connections, or listeners.
   - This is important for the architecture diagram because modules are **conditionally active** rather than always resident.

4. **Dependency and infrastructure layer**
   - `lib/dependencies/main_injector.dart` acts as the central service locator.
   - The app uses this for shared infrastructure services like API access, WebSockets, notifications, storage, purchases, ads, navigation, and platform utilities.
   - Readme indicates GetX is used as the locator, while Provider is used for UI state propagation.

5. **Shared contracts and abstractions**
   - `lib/interfaces/` contains the cross-module contracts: starters, use cases, data handlers, state interfaces, async info exposure, and module sync executors.
   - These abstractions are the main decoupling boundary between infrastructure and feature modules.

6. **Feature-module architecture**
   - Most domains follow the same internal structure:
     - `model/` for domain data
     - `repo/` for backend/data access
     - `usecases/` for business actions
     - `state/` for reactive view state
     - `view/` or `screen/` for UI
     - `dependencies/` for module wiring
   - This pattern is visible in Chat, Messages, Discover, Like, Purchases, Rewards, Settings, Auth, CreateUser, and UserData modules.

7. **Authentication and onboarding**
   - `lib/mdoules/auth_module/` handles login flow, token refresh, and auth strategy selection.
   - It includes a dedicated flow layer (`flow/`) with steps, which suggests a multi-stage sign-in process rather than a single login call.
   - `CreateUserModule` is a separate onboarding boundary for account creation, profile setup, and post-signup completion screens.

8. **Core social product domains**
   - **DiscoverModule** handles profile discovery, filtering, sending likes, and location updates.
   - **LikeModule** manages like lifecycle, reveal/accept/delete actions, and countdown/timer-driven UI.
   - **ChatModule** owns chat list handling, chat deletion, real-time sorting, and message read coordination.
   - **MessagesModule** is the message-thread domain, with send, load, sync, listen, and mark-as-read operations.
   - **SettingsModule** manages profile editing, picture uploads, bio/characteristics/settings changes, and user deletion/logout.
   - **UserDataModule** centralizes current-user data loading and reactive observation.

9. **Real-time and event-driven flow**
   - The repo has a strong real-time layer built around **WebSockets** and internal event buses.
   - `lib/services/events/ChatEventBus.dart`, `ChatEventService.dart`, and `PurchaseEventBus.dart` suggest in-app event propagation across modules.
   - Chat and message modules include handler factories and synchronizers, meaning inbound socket events are translated into module-specific state updates rather than handled directly in the UI.

10. **Data access and external services**
   - Repositories are the main gateway to backend services; they typically depend on `ApiService`, WebSocket services, auth/session services, and platform storage.
   - `firebase_options.dart`, `google-services.json`, and the push notification services indicate Firebase integration for notifications.
   - There are also services for **purchases**, **ads**, **location/permissions**, and likely a backend auth provider via `keycloak_service.dart` and session storage.

11. **State and UI boundaries**
   - Feature state objects such as `AuthState`, `ChatState`, `MessagesState`, `DiscoveryPageState`, `LikeState`, `PurchasesState`, `RewardState`, and `SettingsState` are the main reactive bridge to the UI.
   - Views listen to these states and invoke use cases; they should be diagrammed as consumers of module state, not direct callers of repositories.

12. **Error handling and dialogs**
   - There is a dedicated exceptions layer in the root `lib/Exceptions/` and module-specific exception mappers.
   - `lib/Dialogs/` contains reusable dialog components for generic, network, and presentation feedback, indicating the UI surfaces errors through shared dialog infrastructure rather than ad hoc widgets.

13. **Platform and build integration**
   - Native wrappers exist for Android, iOS, macOS, Linux, Windows, and Web.
   - The Android project includes Firebase config, and the repo also contains shell utilities for developer workflows, suggesting this app is built and tested across multiple targets.

14. **Testing posture**
   - The `test/` tree is broad and module-specific, covering auth flow, repositories, use cases, models, and widget tests.
   - This reinforces the architecture: business logic is designed to be testable at the use-case/repository boundary, with UI tests isolated from infrastructure.

Main entry points: [`lib/starters`](https://github.com/marcosobiang/hotty2/tree/master/lib/starters) (Starters), [`lib/mdoules/auth_module`](https://github.com/marcosobiang/hotty2/tree/master/lib/mdoules/auth_module) (Auth), [`lib/services`](https://github.com/marcosobiang/hotty2/tree/master/lib/services) (Core services), [`lib/mdoules/ChatModule`](https://github.com/marcosobiang/hotty2/tree/master/lib/mdoules/ChatModule) (Chat)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bootstrap["Bootstrap"]
  node_main["main.dart<br/>entrypoint<br/>[main.dart]"]
  node_starter_main["Main starter<br/>boot orchestrator<br/>[main_starter.dart]"]
  node_starters["Starters<br/>lifecycle modules"]
end

subgraph group_infra["Infrastructure"]
  node_injector["Injector<br/>service locator<br/>[main_injector.dart]"]
  node_services["Core services<br/>platform infra"]
  node_websocket["WebSocket<br/>realtime transport"]
  node_api["API<br/>http client<br/>[ApiService.dart]"]
  node_push["Push notif.<br/>notifications"]
  node_storage["Storage<br/>[SecureStorage.dart]"]
end

subgraph group_contracts["Contracts"]
  node_contracts_root["Interfaces<br/>abstractions"]
end

subgraph group_features["Feature modules"]
  node_auth["Auth<br/>feature module"]
  node_create_user["Create user<br/>onboarding module"]
  node_discover["Discover<br/>social module"]
  node_likes["Likes<br/>social module"]
  node_chat["Chat<br/>conversation module"]
  node_messages["Messages<br/>thread module"]
  node_settings["Settings<br/>profile module"]
  node_purchases["Purchases<br/>monetization module"]
  node_rewards["Rewards<br/>engagement module"]
  node_user_data["User data<br/>session module"]
end

subgraph group_realtime["Real-time"]
  node_events["Event bus<br/>in-app events"]
end

node_main -->|"launches"| node_starter_main
node_starter_main -->|"wires"| node_injector
node_starter_main -->|"runs"| node_starters
node_injector -->|"registers"| node_services
node_injector -->|"implements"| node_contracts_root
node_starters -->|"starts"| node_auth
node_starters -->|"starts"| node_user_data
node_starters -->|"starts"| node_websocket
node_starters -->|"starts"| node_push
node_starters -->|"starts"| node_chat
node_starters -->|"starts"| node_messages
node_starters -->|"starts"| node_discover
node_starters -->|"starts"| node_likes
node_starters -->|"starts"| node_purchases
node_starters -->|"starts"| node_rewards
node_starters -->|"starts"| node_settings
node_auth -->|"reads/writes"| node_storage
node_auth -->|"calls"| node_api
node_auth -->|"uses"| node_services
node_discover -->|"calls"| node_api
node_discover -->|"uses"| node_services
node_likes -->|"publishes"| node_events
node_chat -->|"listens"| node_websocket
node_chat -->|"subscribes"| node_events
node_messages -->|"syncs"| node_websocket
node_messages -->|"publishes"| node_events
node_settings -->|"calls"| node_api
node_purchases -->|"uses"| node_services
node_rewards -->|"uses"| node_services
node_user_data -->|"loads"| node_api
node_chat -->|"coordinates"| node_messages
node_create_user -->|"follows"| node_auth

click node_main "https://github.com/marcosobiang/hotty2/blob/master/lib/main.dart"
click node_starter_main "https://github.com/marcosobiang/hotty2/blob/master/lib/main_starter.dart"
click node_starters "https://github.com/marcosobiang/hotty2/tree/master/lib/starters"
click node_injector "https://github.com/marcosobiang/hotty2/blob/master/lib/dependencies/main_injector.dart"
click node_services "https://github.com/marcosobiang/hotty2/tree/master/lib/services"
click node_websocket "https://github.com/marcosobiang/hotty2/blob/master/lib/services/WebSocket/WebSocketService.dart"
click node_api "https://github.com/marcosobiang/hotty2/blob/master/lib/services/ApiService.dart"
click node_push "https://github.com/marcosobiang/hotty2/blob/master/lib/services/PushNotifications/push_notifications_service.dart"
click node_storage "https://github.com/marcosobiang/hotty2/blob/master/lib/services/platform/storage/SecureStorage.dart"
click node_events "https://github.com/marcosobiang/hotty2/tree/master/lib/services/events"
click node_contracts_root "https://github.com/marcosobiang/hotty2/tree/master/lib/interfaces"
click node_auth "https://github.com/marcosobiang/hotty2/tree/master/lib/mdoules/auth_module"
click node_create_user "https://github.com/marcosobiang/hotty2/tree/master/lib/mdoules/CreateUserModule"
click node_discover "https://github.com/marcosobiang/hotty2/tree/master/lib/mdoules/DiscoverModule"
click node_likes "https://github.com/marcosobiang/hotty2/tree/master/lib/mdoules/LikeModule"
click node_chat "https://github.com/marcosobiang/hotty2/tree/master/lib/mdoules/ChatModule"
click node_messages "https://github.com/marcosobiang/hotty2/tree/master/lib/mdoules/MessagesModule"
click node_settings "https://github.com/marcosobiang/hotty2/tree/master/lib/mdoules/SettingsModule"
click node_purchases "https://github.com/marcosobiang/hotty2/tree/master/lib/mdoules/PurchasesModule"
click node_rewards "https://github.com/marcosobiang/hotty2/tree/master/lib/mdoules/RewardsModule"
click node_user_data "https://github.com/marcosobiang/hotty2/tree/master/lib/mdoules/user_data_module"

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_main,node_starter_main,node_starters toneBlue
class node_injector,node_services,node_websocket,node_api,node_push,node_storage toneAmber
class node_contracts_root toneMint
class node_auth,node_create_user,node_discover,node_likes,node_chat,node_messages,node_settings,node_purchases,node_rewards,node_user_data toneRose
class node_events toneIndigo
```

## Components

### Bootstrap

App entrypoints and lifecycle starters

- [main.dart](https://github.com/marcosobiang/hotty2/blob/master/lib/main.dart): entrypoint · Flutter app entrypoint · `lib/main.dart`
- [Main starter](https://github.com/marcosobiang/hotty2/blob/master/lib/main_starter.dart): boot orchestrator · Chooses and sequences module startup · `lib/main_starter.dart`
- [Starters](https://github.com/marcosobiang/hotty2/tree/master/lib/starters): lifecycle modules · Conditional module initialization and disposal · `lib/starters`

### Infrastructure

Shared services and platform integrations

- [Injector](https://github.com/marcosobiang/hotty2/blob/master/lib/dependencies/main_injector.dart): service locator · Central dependency wiring and shared singleton registration · `lib/dependencies/main_injector.dart`
- [Core services](https://github.com/marcosobiang/hotty2/tree/master/lib/services): platform infra · API, websocket, notifications, storage, ads, purchases, navigation, auth · `lib/services`
- [WebSocket](https://github.com/marcosobiang/hotty2/blob/master/lib/services/WebSocket/WebSocketService.dart): realtime transport · Socket connectivity and payload container · `lib/services/WebSocket/WebSocketService.dart`
- [API](https://github.com/marcosobiang/hotty2/blob/master/lib/services/ApiService.dart): http client · Backend request gateway · `lib/services/ApiService.dart`
- [Push notif.](https://github.com/marcosobiang/hotty2/blob/master/lib/services/PushNotifications/push_notifications_service.dart): notifications · Firebase push notification integration · `lib/services/PushNotifications/push_notifications_service.dart`
- [Storage](https://github.com/marcosobiang/hotty2/blob/master/lib/services/platform/storage/SecureStorage.dart): platform storage · Secure storage, permissions, and location utilities · `lib/services/platform/storage/SecureStorage.dart`

### Contracts

Cross-module abstractions and state interfaces

- [Interfaces](https://github.com/marcosobiang/hotty2/tree/master/lib/interfaces): abstractions · Shared module contracts and lifecycle interfaces · `lib/interfaces`

### Feature modules

Business modules for auth, social, messaging, and monetization

- [Auth](https://github.com/marcosobiang/hotty2/tree/master/lib/mdoules/auth_module): feature module · Login flow, token refresh, and auth strategy selection · `lib/mdoules/auth_module`
- [Create user](https://github.com/marcosobiang/hotty2/tree/master/lib/mdoules/CreateUserModule): onboarding module · Account creation and profile completion · `lib/mdoules/CreateUserModule`
- [Discover](https://github.com/marcosobiang/hotty2/tree/master/lib/mdoules/DiscoverModule): social module · Profile discovery, filters, likes, and location updates · `lib/mdoules/DiscoverModule`
- [Likes](https://github.com/marcosobiang/hotty2/tree/master/lib/mdoules/LikeModule): social module · Like lifecycle, reveal, accept, and timers · `lib/mdoules/LikeModule`
- [Chat](https://github.com/marcosobiang/hotty2/tree/master/lib/mdoules/ChatModule): conversation module · Chat list, deletion, sorting, and read coordination · `lib/mdoules/ChatModule`
- [Messages](https://github.com/marcosobiang/hotty2/tree/master/lib/mdoules/MessagesModule): thread module · Thread load, send, sync, listen, and mark-read · `lib/mdoules/MessagesModule`
- [Settings](https://github.com/marcosobiang/hotty2/tree/master/lib/mdoules/SettingsModule): profile module · Profile editing, uploads, logout, and deletion · `lib/mdoules/SettingsModule`
- [Purchases](https://github.com/marcosobiang/hotty2/tree/master/lib/mdoules/PurchasesModule): monetization module · Products, paywall, restore, and recharge flows · `lib/mdoules/PurchasesModule`
- [Rewards](https://github.com/marcosobiang/hotty2/tree/master/lib/mdoules/RewardsModule): engagement module · Daily and welcome reward claiming · `lib/mdoules/RewardsModule`
- [User data](https://github.com/marcosobiang/hotty2/tree/master/lib/mdoules/user_data_module): session module · Current-user data loading and observation · `lib/mdoules/user_data_module`

### Real-time

Event buses and websocket-driven coordination

- [Event bus](https://github.com/marcosobiang/hotty2/tree/master/lib/services/events): in-app events · Chat and purchase event propagation · `lib/services/events`

## Connections

- main.dart → Main starter: launches · App entry delegates lifecycle setup
- Main starter → Injector: wires · Bootstraps shared dependencies
- Main starter → Starters: runs · Coordinates module startup order
- Injector → Core services: registers · Provides shared infrastructure services
- Injector → Interfaces: implements · Binds shared abstractions to concrete services
- Starters → Auth: starts · Initial auth session is prepared first
- Starters → User data: starts · Session-scoped user data is initialized
- Starters → WebSocket: starts · Socket connections are activated when needed
- Starters → Push notif.: starts · Notification listeners are conditionally enabled
- Starters → Chat: starts · Chat runtime is activated for signed-in users
- Starters → Messages: starts · Thread sync/listen flow is activated
- Starters → Discover: starts · Discovery experience is enabled post-auth
- Starters → Likes: starts · Like lifecycle services are activated
- Starters → Purchases: starts · Monetization services are activated
- Starters → Rewards: starts · Reward timers and claims are activated
- Starters → Settings: starts · Profile/settings flows are made available
- Auth → Storage: reads/writes · Uses secure session storage
- Auth → API: calls · Authenticates against backend services
- Auth → Core services: uses · Depends on shared auth/session utilities
- Discover → API: calls · Loads profiles and saves discovery settings
- Discover → Core services: uses · Uses location and permission utilities
- Likes → Event bus: publishes · Shares like-related state changes
- Chat → WebSocket: listens · Consumes realtime chat events
- Chat → Event bus: subscribes · Coordinates chat UI updates via event bus
- Messages → WebSocket: syncs · Consumes and emits realtime message updates
- Messages → Event bus: publishes · Broadcasts message state changes
- Settings → API: calls · Uploads profile changes and account actions
- Purchases → Core services: uses · Depends on purchase platform services
- Rewards → Core services: uses · Depends on shared infrastructure and timing
- User data → API: loads · Fetches the current user profile/session data
- Chat → Messages: coordinates · Chat list and message threads are connected
- Create user → Auth: follows · Onboarding continues from authenticated/session state
