# olgaarenas22/routines architecture

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

- Interactive diagram: https://gitdiagram.com/olgaarenas22/routines
- Repository: https://github.com/olgaarenas22/routines

## Overview

1. **Overall shape**
   - This is a .NET / ASP.NET Core service named **Users**.
   - It is organized with a clear layering split: **Controllers/API**, **Application**, **Domain**, and **Infrastructure**.
   - The codebase is centered on user profile/onboarding, faction selection, tutorial progression, and reacting to external fitness/routine events.

2. **API boundary**
   - `Users/Controllers/UsersController.cs` is the main HTTP entry point.
   - Request/response DTOs live under `Users/Models/Requests` and `Users/Models/Responses`.
   - `Program.cs` and `Extensions/DependencyInjectionExtensions.cs` wire up the service, middleware, and dependencies.

3. **Application layer as the orchestration boundary**
   - `Users/Application/CommandHandler` contains the main use-case handlers.
   - These handlers implement user-facing flows such as:
     - onboarding initialization
     - username/profile updates
     - gender, goal, height, weight, birth date, activity level, desired weight updates
     - faction selection
     - routine tutorial completion
   - This layer coordinates domain services, repositories, validation, and event publication rather than talking directly to infrastructure.

4. **Domain model**
   - `Users/Domain/Entities` holds the core persisted concepts:
     - `UserEntity`
     - `FactionEntity`, `FactionMainStatEntity`
     - `StatEntity`
     - `UserTutorialProgressEntity`
     - outbox and processed-integration-event tracking entities
   - `Users/Domain/Enums` defines user-related domain categories like `Gender`, `Goal`, `ActivityLevel`, `FactionType`, and `StatType`.
   - `Users/Domain/Repositories` and `Users/Domain/Services` define the abstraction boundary the application depends on.

5. **Business services**
   - `Users/Application/Services` contains the core domain logic services:
     - `UserService`
     - `FactionService`
     - `ProfileCalculationService`
     - `LevelProgressionService`
   - These services encapsulate calculations and business rules that are reused across handlers and event consumers.
   - `ProfileCalculationService` likely drives derived profile data, while `LevelProgressionService` handles progression logic from activity/session events.

6. **Validation and error handling**
   - Each command/request has a validator in `Users/Application/Validators`.
   - Validation is explicit and extensive, including both user-facing commands and internal event-driven commands.
   - Shared error handling lives in `Users/Common/Errors` and `Users/Common/Exceptions`, with `ExceptionHandlingMiddleware` providing the HTTP boundary for exceptions.

7. **Event-driven integration**
   - The service is not just request/response; it also consumes and emits domain/integration events.
   - Internal event types are under `Users/Models/Events`, including:
     - `UserRegisteredEvent`
     - `UserOnboardingCompletedEvent`
     - `UserSessionStartedEvent`
     - `WorkoutSessionExerciseCompletedEvent`
     - `RoutineWeekClosedEvent`
     - `UserRoutineSettingsUpdatedEvent`
   - Application event handlers react to these events and translate them into user state changes.

8. **Messaging and asynchronous processing**
   - `Users/Infraestructure/Events` contains event consumers, an event publisher, and a dispatcher.
   - `ServiceBusEventSender` plus `Configuration/ServiceBusSettings.cs` indicate integration with an external message bus, likely Azure Service Bus.
   - Workers (`OutboxWorker`, `ServiceBusWorker`) suggest background processing for dispatching queued events and consuming inbound messages.

9. **Outbox and idempotency pattern**
   - The presence of `OutboxEventEntity`, `ProcessedIntegrationEventEntity`, and corresponding repositories/persistence interfaces shows a classic reliability pattern:
     - write business changes and outgoing events together
     - asynchronously publish them later
     - record processed inbound integration events to avoid duplicate handling
   - This is a key architectural boundary: database state is the source of truth, while messaging is made reliable via outbox/inbox tracking.

10. **Persistence layer**
   - `Users/Infraestructure/Persistence` contains SQL-backed persistence implementations and a `SqlUnitOfWork`.
   - `Users/Infraestructure/Repositories` wrap those persistence classes and implement the domain repository interfaces.
   - This makes the application layer database-agnostic while still using concrete SQL persistence underneath.

11. **Security and request context**
   - `Users/Infraestructure/Security/UserContextService.cs` provides access to the current user context behind the `IUserContextService` abstraction.
   - That service is likely used by controllers or handlers to scope operations to the authenticated user.
   - `Configuration/JwtSettings.cs` indicates JWT-based authentication is part of the API boundary.

12. **Derived profile and appearance logic**
   - `Users/Infraestructure/Services/AppearanceMappingService.cs` and its domain interface indicate a separate concern for mapping user data to appearance-related results.
   - `Configuration/AssetsSettings.cs` suggests image/asset URL generation or asset lookup is part of the service’s outputs.
   - These are presentation-adjacent calculations, not core persistence concerns.

13. **Data flow at a glance**
   - HTTP request enters `UsersController`
   - controller forwards to an application command handler
   - handler validates input and uses domain services/repositories
   - persistence writes to SQL via repository/unit-of-work
   - domain events are stored in the outbox and later published
   - workers or consumers process incoming bus events and update user state or progression
   - responses are returned via DTOs in `Users/Models/Responses`

14. **Testing structure**
   - `Users.Tests` mirrors the production structure: application command handlers, event handlers, validators, services, controllers, security, infrastructure workers.
   - This indicates the repo is tested at multiple boundaries, especially business rules and message-processing flows.

15. **Key architectural takeaway**
   - This service is best drawn as a **domain-centric, event-driven ASP.NET Core microservice**:
     - synchronous API for user profile/onboarding operations
     - asynchronous integration for lifecycle/progression events
     - SQL persistence with outbox/inbox reliability
     - clear separation between controllers, application orchestration, domain abstractions, and infrastructure implementations

Main entry points: [`Users/Application/CommandHandler`](https://github.com/olgaarenas22/routines/tree/main/Users/Application/CommandHandler) (Command handlers), [`Users/Extensions/DependencyInjectionExtensions.cs`](https://github.com/olgaarenas22/routines/blob/main/Users/Extensions/DependencyInjectionExtensions.cs) (DI setup), [`Users/Application/EventHandler`](https://github.com/olgaarenas22/routines/tree/main/Users/Application/EventHandler) (Event handlers), [`Users/Controllers/UsersController.cs`](https://github.com/olgaarenas22/routines/blob/main/Users/Controllers/UsersController.cs) (Users API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API boundary"]
  node_program["Program<br/>host bootstrap<br/>[Program.cs]"]
  node_di["DI setup<br/>composition"]
  node_users_controller["Users API<br/>controller<br/>[UsersController.cs]"]
end

subgraph group_application["Application layer"]
  node_command_handlers["Command handlers<br/>use-case orchestration"]
  node_event_handlers["Event handlers<br/>integration orchestration"]
  node_validators["Validators<br/>input validation"]
  node_user_service["User service<br/>domain service<br/>[UserService.cs]"]
  node_faction_service["Faction service<br/>domain service<br/>[FactionService.cs]"]
  node_profile_calc["Profile calc<br/>calculation service"]
  node_progression_service["Progression<br/>domain service"]
end

subgraph group_domain["Domain model"]
  node_user_entity[("User<br/>entity<br/>[UserEntity.cs]")]
  node_faction_entity[("Faction<br/>entity<br/>[FactionEntity.cs]")]
  node_tutorial_entity[("Tutorial progress<br/>entity")]
  node_outbox_entity[("Outbox<br/>entity")]
  node_inbox_entity[("Processed events<br/>entity")]
  node_repos["Repositories<br/>repository interfaces"]
  node_domain_services["Domain services<br/>service interfaces"]
end

subgraph group_infra["Infrastructure"]
  node_exception_middleware["Error middleware"]
  node_persistence[("SQL persistence<br/>sql adapters")]
  node_repositories_impl["Repo adapters<br/>repository adapters"]
  node_event_bus["Events bus<br/>messaging"]
  node_bus_sender["Bus sender<br/>messaging client"]
  node_workers["Workers<br/>background processing"]
  node_user_context["User context<br/>security service"]
  node_appearance["Appearance map<br/>mapping service"]
end

subgraph group_models["Contracts"]
  node_commands_models["Commands<br/>message contracts"]
  node_events_models["Events<br/>event contracts"]
  node_requests_responses["HTTP DTOs<br/>api contracts"]
end

subgraph group_tests["Tests"]
  node_tests_app["App tests<br/>test suite<br/>[Application]"]
  node_tests_api["API tests<br/>test suite<br/>[Controllers]"]
  node_tests_infra["Infra tests<br/>test suite<br/>[Infrastructure]"]
end

node_program -->|"composes"| node_di
node_program -->|"hosts"| node_users_controller
node_program -->|"uses"| node_exception_middleware
node_di -->|"registers"| node_command_handlers
node_di -->|"registers"| node_event_handlers
node_di -->|"registers"| node_validators
node_di -->|"binds"| node_repositories_impl
node_di -->|"binds"| node_event_bus
node_di -->|"starts"| node_workers
node_users_controller -->|"uses"| node_requests_responses
node_users_controller -->|"calls"| node_command_handlers
node_users_controller -->|"validates"| node_validators
node_command_handlers -->|"accepts"| node_commands_models
node_command_handlers -->|"orchestrates"| node_user_service
node_command_handlers -->|"orchestrates"| node_faction_service
node_command_handlers -->|"derives"| node_profile_calc
node_command_handlers -->|"advances"| node_progression_service
node_command_handlers -->|"persists via"| node_repos
node_event_handlers -->|"handles"| node_events_models
node_event_handlers -->|"updates"| node_progression_service
node_event_handlers -->|"updates"| node_user_service
node_event_handlers -->|"reads/writes"| node_repos
node_validators -->|"checks"| node_commands_models
node_user_service -->|"governs"| node_user_entity
node_user_service -->|"updates"| node_tutorial_entity
node_faction_service -->|"uses"| node_faction_entity
node_profile_calc -->|"feeds"| node_appearance
node_progression_service -->|"derives"| node_user_entity
node_repos -->|"implemented by"| node_persistence
node_repositories_impl -->|"wraps"| node_persistence
node_persistence -->|"stores"| node_outbox_entity
node_persistence -->|"stores"| node_inbox_entity
node_event_bus -->|"publishes via"| node_bus_sender
node_event_bus -->|"consumes/emits"| node_events_models
node_workers -->|"drives"| node_event_bus
node_workers -->|"polls"| node_persistence
node_user_context -->|"implements"| node_domain_services
node_appearance -->|"implements"| node_domain_services
node_tests_app -.->|"covers"| node_command_handlers
node_tests_app -.->|"covers"| node_event_handlers
node_tests_app -.->|"covers"| node_validators
node_tests_app -.->|"covers"| node_user_service
node_tests_api -.->|"covers"| node_users_controller
node_tests_infra -.->|"covers"| node_workers
node_tests_infra -.->|"covers"| node_user_context
node_tests_infra -.->|"covers"| node_appearance

click node_program "https://github.com/olgaarenas22/routines/blob/main/Users/Program.cs"
click node_di "https://github.com/olgaarenas22/routines/blob/main/Users/Extensions/DependencyInjectionExtensions.cs"
click node_users_controller "https://github.com/olgaarenas22/routines/blob/main/Users/Controllers/UsersController.cs"
click node_exception_middleware "https://github.com/olgaarenas22/routines/blob/main/Users/Infraestructure/Middleware/ExceptionHandlingMiddleware.cs"
click node_command_handlers "https://github.com/olgaarenas22/routines/tree/main/Users/Application/CommandHandler"
click node_event_handlers "https://github.com/olgaarenas22/routines/tree/main/Users/Application/EventHandler"
click node_validators "https://github.com/olgaarenas22/routines/tree/main/Users/Application/Validators"
click node_user_service "https://github.com/olgaarenas22/routines/blob/main/Users/Application/Services/UserService.cs"
click node_faction_service "https://github.com/olgaarenas22/routines/blob/main/Users/Application/Services/FactionService.cs"
click node_profile_calc "https://github.com/olgaarenas22/routines/blob/main/Users/Application/Services/ProfileCalculationService.cs"
click node_progression_service "https://github.com/olgaarenas22/routines/blob/main/Users/Application/Services/LevelProgressionService.cs"
click node_user_entity "https://github.com/olgaarenas22/routines/blob/main/Users/Domain/Entities/UserEntity.cs"
click node_faction_entity "https://github.com/olgaarenas22/routines/blob/main/Users/Domain/Entities/FactionEntity.cs"
click node_tutorial_entity "https://github.com/olgaarenas22/routines/blob/main/Users/Domain/Entities/UserTutorialProgressEntity.cs"
click node_outbox_entity "https://github.com/olgaarenas22/routines/blob/main/Users/Domain/Entities/OutboxEventEntity.cs"
click node_inbox_entity "https://github.com/olgaarenas22/routines/blob/main/Users/Domain/Entities/ProcessedIntegrationEventEntity.cs"
click node_repos "https://github.com/olgaarenas22/routines/tree/main/Users/Domain/Repositories"
click node_domain_services "https://github.com/olgaarenas22/routines/tree/main/Users/Domain/Services"
click node_persistence "https://github.com/olgaarenas22/routines/tree/main/Users/Infraestructure/Persistence"
click node_repositories_impl "https://github.com/olgaarenas22/routines/tree/main/Users/Infraestructure/Repositories"
click node_event_bus "https://github.com/olgaarenas22/routines/tree/main/Users/Infraestructure/Events"
click node_bus_sender "https://github.com/olgaarenas22/routines/blob/main/Users/Infraestructure/Events/Sender/ServiceBusEventSender.cs"
click node_workers "https://github.com/olgaarenas22/routines/tree/main/Users/Infraestructure/Workers"
click node_user_context "https://github.com/olgaarenas22/routines/blob/main/Users/Infraestructure/Security/UserContextService.cs"
click node_appearance "https://github.com/olgaarenas22/routines/blob/main/Users/Infraestructure/Services/AppearanceMappingService.cs"
click node_commands_models "https://github.com/olgaarenas22/routines/tree/main/Users/Models/Commands"
click node_events_models "https://github.com/olgaarenas22/routines/tree/main/Users/Models/Events"
click node_requests_responses "https://github.com/olgaarenas22/routines/tree/main/Users/Models/Requests"
click node_tests_app "https://github.com/olgaarenas22/routines/blob/main/Users.Tests/Application"
click node_tests_api "https://github.com/olgaarenas22/routines/blob/main/Users.Tests/Controllers"
click node_tests_infra "https://github.com/olgaarenas22/routines/blob/main/Users.Tests/Infrastructure"

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_program,node_di,node_users_controller toneBlue
class node_command_handlers,node_event_handlers,node_validators,node_user_service,node_faction_service,node_profile_calc,node_progression_service toneAmber
class node_user_entity,node_faction_entity,node_tutorial_entity,node_outbox_entity,node_inbox_entity,node_repos,node_domain_services toneMint
class node_exception_middleware,node_persistence,node_repositories_impl,node_event_bus,node_bus_sender,node_workers,node_user_context,node_appearance toneRose
class node_commands_models,node_events_models,node_requests_responses toneIndigo
class node_tests_app,node_tests_api,node_tests_infra toneTeal
```

## Components

### API boundary

HTTP entrypoint, hosting, middleware, and request/response contracts.

- [Program](https://github.com/olgaarenas22/routines/blob/main/Users/Program.cs): host bootstrap · ASP.NET Core composition root and startup wiring. · `Users/Program.cs`
- [DI setup](https://github.com/olgaarenas22/routines/blob/main/Users/Extensions/DependencyInjectionExtensions.cs): composition · Registers services, middleware, and infrastructure implementations. · `Users/Extensions/DependencyInjectionExtensions.cs`
- [Users API](https://github.com/olgaarenas22/routines/blob/main/Users/Controllers/UsersController.cs): controller · Main HTTP entrypoint for user profile and onboarding operations. · `Users/Controllers/UsersController.cs`

### Application layer

Use-case orchestration, validation, and event-driven handlers.

- [Command handlers](https://github.com/olgaarenas22/routines/tree/main/Users/Application/CommandHandler): use-case orchestration · User-facing flows for onboarding, profile updates, faction selection, and routine/tutorial actions. · `Users/Application/CommandHandler`
- [Event handlers](https://github.com/olgaarenas22/routines/tree/main/Users/Application/EventHandler): integration orchestration · React to user lifecycle and workout/routine events to update state. · `Users/Application/EventHandler`
- [Validators](https://github.com/olgaarenas22/routines/tree/main/Users/Application/Validators): input validation · Rules for commands and requests at the application boundary. · `Users/Application/Validators`
- [User service](https://github.com/olgaarenas22/routines/blob/main/Users/Application/Services/UserService.cs): domain service · Central user-state business logic used by handlers and consumers. · `Users/Application/Services/UserService.cs`
- [Faction service](https://github.com/olgaarenas22/routines/blob/main/Users/Application/Services/FactionService.cs): domain service · Faction selection and faction-related business rules. · `Users/Application/Services/FactionService.cs`
- [Profile calc](https://github.com/olgaarenas22/routines/blob/main/Users/Application/Services/ProfileCalculationService.cs): calculation service · Derived profile, appearance, and onboarding-related calculations. · `Users/Application/Services/ProfileCalculationService.cs`
- [Progression](https://github.com/olgaarenas22/routines/blob/main/Users/Application/Services/LevelProgressionService.cs): domain service · Level and progression logic driven by activity and session events. · `Users/Application/Services/LevelProgressionService.cs`

### Domain model

Core entities, enums, and service/repository abstractions.

- [User](https://github.com/olgaarenas22/routines/blob/main/Users/Domain/Entities/UserEntity.cs): entity · Core persisted user profile and state aggregate. · `Users/Domain/Entities/UserEntity.cs`
- [Faction](https://github.com/olgaarenas22/routines/blob/main/Users/Domain/Entities/FactionEntity.cs): entity · Faction definitions and main stat metadata. · `Users/Domain/Entities/FactionEntity.cs`
- [Tutorial progress](https://github.com/olgaarenas22/routines/blob/main/Users/Domain/Entities/UserTutorialProgressEntity.cs): entity · Persisted tutorial/onboarding progression. · `Users/Domain/Entities/UserTutorialProgressEntity.cs`
- [Outbox](https://github.com/olgaarenas22/routines/blob/main/Users/Domain/Entities/OutboxEventEntity.cs): entity · Outgoing integration events queued for reliable publication. · `Users/Domain/Entities/OutboxEventEntity.cs`
- [Processed events](https://github.com/olgaarenas22/routines/blob/main/Users/Domain/Entities/ProcessedIntegrationEventEntity.cs): entity · Tracks consumed integration events to prevent duplicate handling. · `Users/Domain/Entities/ProcessedIntegrationEventEntity.cs`
- [Repositories](https://github.com/olgaarenas22/routines/tree/main/Users/Domain/Repositories): repository interfaces · Persistence abstractions for user, faction, stats, tutorial, outbox, and inbox state. · `Users/Domain/Repositories`
- [Domain services](https://github.com/olgaarenas22/routines/tree/main/Users/Domain/Services): service interfaces · Abstractions for calculation, progression, event publishing, context, and user logic. · `Users/Domain/Services`

### Infrastructure

SQL persistence, messaging, security, and background workers.

- [Error middleware](https://github.com/olgaarenas22/routines/blob/main/Users/Infraestructure/Middleware/ExceptionHandlingMiddleware.cs): middleware · Translates application exceptions into HTTP error responses. · `Users/Infraestructure/Middleware/ExceptionHandlingMiddleware.cs`
- [SQL persistence](https://github.com/olgaarenas22/routines/tree/main/Users/Infraestructure/Persistence): sql adapters · Concrete SQL-backed persistence and unit-of-work implementations. · `Users/Infraestructure/Persistence`
- [Repo adapters](https://github.com/olgaarenas22/routines/tree/main/Users/Infraestructure/Repositories): repository adapters · Repository implementations that wrap persistence classes. · `Users/Infraestructure/Repositories`
- [Events bus](https://github.com/olgaarenas22/routines/tree/main/Users/Infraestructure/Events): messaging · Integration event dispatcher, consumers, and publisher. · `Users/Infraestructure/Events`
- [Bus sender](https://github.com/olgaarenas22/routines/blob/main/Users/Infraestructure/Events/Sender/ServiceBusEventSender.cs): messaging client · Sends integration events to the external service bus. · `Users/Infraestructure/Events/Sender/ServiceBusEventSender.cs`
- [Workers](https://github.com/olgaarenas22/routines/tree/main/Users/Infraestructure/Workers): background processing · Outbox dispatch and service bus consumption loops. · `Users/Infraestructure/Workers`
- [User context](https://github.com/olgaarenas22/routines/blob/main/Users/Infraestructure/Security/UserContextService.cs): security service · Resolves the current authenticated user context. · `Users/Infraestructure/Security/UserContextService.cs`
- [Appearance map](https://github.com/olgaarenas22/routines/blob/main/Users/Infraestructure/Services/AppearanceMappingService.cs): mapping service · Maps user data to appearance-related outputs. · `Users/Infraestructure/Services/AppearanceMappingService.cs`

### Contracts

Commands, events, requests, and responses shared across layers.

- [Commands](https://github.com/olgaarenas22/routines/tree/main/Users/Models/Commands): message contracts · Application command contracts for user operations and inbound event handlers. · `Users/Models/Commands`
- [Events](https://github.com/olgaarenas22/routines/tree/main/Users/Models/Events): event contracts · Internal domain/integration event messages. · `Users/Models/Events`
- [HTTP DTOs](https://github.com/olgaarenas22/routines/tree/main/Users/Models/Requests): api contracts · Request and response models used by the controller surface. · `Users/Models/Requests`

### Tests

Behavioral coverage mirroring the production architecture.

- [App tests](https://github.com/olgaarenas22/routines/blob/main/Users.Tests/Application): test suite · Command handler, event handler, validator, and service tests. · `Users.Tests/Application`
- [API tests](https://github.com/olgaarenas22/routines/blob/main/Users.Tests/Controllers): test suite · Controller-level coverage. · `Users.Tests/Controllers`
- [Infra tests](https://github.com/olgaarenas22/routines/blob/main/Users.Tests/Infrastructure): test suite · Security, services, and worker processing tests. · `Users.Tests/Infrastructure`

## Connections

- Program → DI setup: composes · Startup wires dependency injection and app services.
- Program → Users API: hosts · Exposes the HTTP API endpoints.
- Program → Error middleware: uses · Registers centralized exception handling.
- DI setup → Command handlers: registers · Adds use-case handlers to the container.
- DI setup → Event handlers: registers · Adds event consumers and handlers.
- DI setup → Validators: registers · Adds request and command validators.
- DI setup → Repo adapters: binds · Maps repository interfaces to SQL-backed implementations.
- DI setup → Events bus: binds · Registers messaging pipeline components.
- DI setup → Workers: starts · Adds background workers for dispatch and consumption.
- Users API → HTTP DTOs: uses · Accepts requests and returns DTO responses.
- Users API → Command handlers: calls · Delegates HTTP actions to application use cases.
- Users API → Validators: validates · Enforces request rules before execution.
- Command handlers → Commands: accepts · Handlers are driven by command contracts.
- Command handlers → User service: orchestrates · Coordinates user business logic.
- Command handlers → Faction service: orchestrates · Uses faction rules for selection and assignment.
- Command handlers → Profile calc: derives · Computes profile-related outputs.
- Command handlers → Progression: advances · Applies progression logic where relevant.
- Command handlers → Repositories: persists via · Relies on repository abstractions, not concrete SQL.
- Event handlers → Events: handles · Consumes internal lifecycle and workout events.
- Event handlers → Progression: updates · Applies event-driven progression changes.
- Event handlers → User service: updates · Mutates user state from incoming events.
- Event handlers → Repositories: reads/writes · Uses repository abstractions for state changes.
- Validators → Commands: checks · Validates commands and requests.
- User service → User: governs · Encapsulates core user rules.
- User service → Tutorial progress: updates · Manages onboarding/tutorial progress.
- Faction service → Faction: uses · Operates on faction definitions.
- Profile calc → Appearance map: feeds · Supports appearance and profile presentation data.
- Progression → User: derives · Computes progression from user state and events.
- Repositories → SQL persistence: implemented by · Domain persistence contracts are realized in SQL adapters.
- Repo adapters → SQL persistence: wraps · Repository classes delegate to SQL persistence.
- SQL persistence → Outbox: stores · Persists outgoing integration events.
- SQL persistence → Processed events: stores · Persists processed-event tracking.
- Events bus → Bus sender: publishes via · Sends integration events externally.
- Events bus → Events: consumes/emits · Moves event contracts across boundaries.
- Workers → Events bus: drives · Background jobs dispatch and consume messages.
- Workers → SQL persistence: polls · Reads outbox and inbox state for reliable processing.
- User context → Domain services: implements · Provides the current-user abstraction.
- Appearance map → Domain services: implements · Provides appearance mapping abstraction.
- App tests → Command handlers: covers · Validates user flows and orchestration.
- App tests → Event handlers: covers · Validates event-driven state changes.
- App tests → Validators: covers · Validates input rules.
- App tests → User service: covers · Checks core user business rules.
- API tests → Users API: covers · Exercises the HTTP boundary.
- Infra tests → Workers: covers · Exercises background processing.
- Infra tests → User context: covers · Checks security context behavior.
- Infra tests → Appearance map: covers · Checks derived appearance mapping.
