# dotnetprog/dofus-alliance-manager-solution architecture

> Architecture diagram of the GitHub repository dotnetprog/dofus-alliance-manager-solution, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dotnetprog/dofus-alliance-manager-solution
- Repository: https://github.com/dotnetprog/dofus-alliance-manager-solution

## Overview

##### Project type and purpose
- This is a full-stack, .NET-centric application “dofus-alliance-manager” that combines:
- A browser-based ASP.NET Core MVC+OData WebApp with Identity and Swagger for alliance management.
- A Discord Bot service to interact with users via Discord.
- A commandline DataMigration tool for backfilling or migrating Discord messages into your system.
- A shared Core/Domain/Infrastructure library trio following a layered (hexagonal/CQRS) architecture.
- EntityFramework-backed Data and Database projects for persistence.
- A minimal AnkamaWebClient wrapper for an external Ankama REST API.

##### File structure
- Top-level “src/” contains multiple .NET projects:
- AnkamaWebClient (third-party API client)
- DAM.Core, DAM.Domain (application + domain logic / MediatR behaviors)
- DAM.Data.EntityFramework, DAM.Data, DAM.Database (infrastructure for persistence)
- DAM.Bot (Discord gateway service with Commands & Event Subscribers)
- DAM.WebApp (ASP.NET Core MVC + OData + Identity WebUI)
- DAM.Tool.DataMigrations (CLI for data migration)
- Common patterns:
- Core and Domain: abstraction → commands/queries under MediatR → behaviors, validators, subscribers.
- Infrastructure: EF Core services, DbContext factories, SQL scripts & migrations.
- Application: Controllers invoke MediatR requests to Core; Bot event handlers and command modules also send MediatR commands.

##### README for additional insights
- README only names the tool.
- But project structure clearly splits into Client → WebApp / Bot / Tool → Core → Data → Database → External services.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients Layer
    subgraph "Clients" 
        direction TB
        Browser["Web Browser"]:::client
        DiscordUser["Discord User"]:::client
        CLI["Dev/Operator CLI"]:::client
    end

    %% Presentation/API Layer
    subgraph "Presentation/API Layer" 
        direction TB
        WebApp["DAM.WebApp (ASP.NET Core MVC + OData + Identity + Swagger)"]:::presentation
        Bot["DAM.Bot (Discord Gateway Service)"]:::presentation
        DataMigration["DAM.Tool.DataMigrations (Console App)"]:::presentation
    end

    %% Application/Core Layer
    subgraph "Application/Core Layer" 
        direction TB
        Core["DAM.Core (MediatR Commands/Queries, Behaviors, Events, Subscribers)"]:::core
        Domain["DAM.Domain (Entities & Value Objects)"]:::core
        AnkamaClient["AnkamaWebClient (External API Adapter)"]:::core
    end

    %% Infrastructure Layer
    subgraph "Infrastructure/ Persistence Layer"
        direction TB
        EFInfra["DAM.Data.EntityFramework (IAllianceManagementService Implementations)"]:::infra
        Caching["DAM.Data (Caching Decorators)"]:::infra
        DatabaseProj["DAM.Database (DbContext, Migrations, Scripts)"]:::infra
    end

    %% External Systems
    subgraph "External Systems"
        direction TB
        DB["Relational Database"]:::external
        DiscordAPI["Discord Gateway/API"]:::external
        AnkamaAPI["Ankama REST API"]:::external
    end

    %% Data Flows
    Browser -->|"HTTP/REST/OData"| WebApp
    WebApp -->|"Controllers invoke MediatR"| Core
    Bot -->|"Discord Events"| DiscordAPI
    DiscordAPI -->|"OnMessage/Reaction"| Bot
    Bot -->|"MediatR Commands"| Core
    CLI -->|"CLI commands"| DataMigration
    DataMigration -->|"Uses AnkamaClient & Discord API"| AnkamaClient
    DataMigration -->|"MediatR Commands"| Core

    Core -->|"Domain Entities & VO"| Domain
    Core -->|"Calls Infrastructure Services"| EFInfra
    Core -->|"Publishes/Subscribes Domain Events"| Core

    EFInfra -->|"DbContext via DAM.Database"| DatabaseProj
    Caching -->|"Decorates EF Services"| EFInfra
    DatabaseProj -->|"SQL Queries"| DB
    AnkamaClient -->|"HTTP Requests"| AnkamaAPI

    %% Click Events
    click WebApp "https://github.com/dotnetprog/dofus-alliance-manager-solution/blob/main/src/DAM.WebApp"
    click Bot "https://github.com/dotnetprog/dofus-alliance-manager-solution/blob/main/src/DAM.Bot"
    click DataMigration "https://github.com/dotnetprog/dofus-alliance-manager-solution/blob/main/src/DAM.Tool.DataMigrations"
    click Core "https://github.com/dotnetprog/dofus-alliance-manager-solution/blob/main/src/DAM.Core"
    click Domain "https://github.com/dotnetprog/dofus-alliance-manager-solution/blob/main/src/DAM.Domain"
    click AnkamaClient "https://github.com/dotnetprog/dofus-alliance-manager-solution/tree/main/src/AnkamaWebClient"
    click EFInfra "https://github.com/dotnetprog/dofus-alliance-manager-solution/blob/main/src/DAM.Data.EntityFramework"
    click Caching "https://github.com/dotnetprog/dofus-alliance-manager-solution/blob/main/src/DAM.Data"
    click DatabaseProj "https://github.com/dotnetprog/dofus-alliance-manager-solution/blob/main/src/DAM.Database"

    %% Styles
    classDef client fill:#B3E5FC,stroke:#0288D1,color:#000
    classDef presentation fill:#BBDEFB,stroke:#1976D2,color:#000
    classDef core fill:#C8E6C9,stroke:#388E3C,color:#000
    classDef infra fill:#FFE0B2,stroke:#F57C00,color:#000
    classDef external fill:#E0E0E0,stroke:#616161,color:#000
```
