# dlidstrom/minaglosor architecture

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

- Interactive diagram: https://gitdiagram.com/dlidstrom/minaglosor
- Repository: https://github.com/dlidstrom/minaglosor

## Overview

Below are detailed guidelines to capture the architecture:

##### Main Components
a. Frontend Web Client:
- AngularJS application under the MinaGlosor.Web/wwwroot folder.
- Elements here include Angular modules, controllers, directives, and views (HTML templates in wwwroot/app).
- Client assets such as CSS (Bootstrap), LESS files, and external JavaScript bundles.

b. Backend Web Application (API Layer & MVC Controllers):
- Views portion (Razor views, cshtml files) for server-rendered pages like account management and emails.
- Configuration files (Global.asax, Web.config) and startup components (App_Start classes, routing configured in RouteConfig.cs and WebApiConfig.cs).

c. Domain/Business Logic & Infrastructure:
- Models directory where domain models (User, Word, WordList, PracticeSession, etc.), Domain Events, and Commands reside.
- Connections to Command Handlers, Query Handlers, and background task processing. This points to a CQRS and Domain Event approach.
- Infrastructure folder, which contains IoC setup (Castle Windsor installers), logging (NLog), and other application services (like Email services, Background Tasks).

d. Data Access & Persistence:
- RavenDB-related assets with indexing files (e.g., in Models/Indexes) and Raven.Studio artifacts.

e. Migration/Tooling Component:
- The MinaGlosor.Tool project can be represented as a separate auxiliary component.
- This part deals with commands for migrating users, word lists and words, and uses migration scripts (e.g., migrate-queries.sql).
- Interaction with the database and possibly the API to perform data transformations.

f. Testing:
- While not part of production architecture, illustrate the MinaGlosor.Test project to show how API endpoints and domain logic are validated through unit tests and integration tests.
- How tests cover migrations, API endpoints, and also include web client testing (e.g., with Jasmine for Angular).

##### Relationships & Interactions
– Show how the Controllers broker calls between the Presentation layer and the Domain/Business Logic.
– Represent the communication between Domain Events, Command Handlers, and Query Handlers, reinforcing the CQRS pattern.
– Illustrate the IoC container (and dependency injection infrastructure) as a foundational service managing component interactions.
– Indicate the data flow from the backend to the Document Database (RavenDB) through indexing components.
– Represent the Tool component (MinaGlosor.Tool) as driving migrations which update or modify persisted data.
– Optionally, show the test suite as verifying the interactions between these layers.

##### Architectural Patterns & Design Principles
– Emphasize the use of the MVC pattern and separation of concerns: Presentation (Views & AngularJS), Application/API, Domain (business logic, commands, events), and Infrastructure (IoC, Logging, Persistence).
– Highlight the CQRS implementation where Queries (read operations) are separated from Commands (write operations) and Domain Events.
– Note that dependency injection (via Castle Windsor in the IoC folder) and modular design are key in this setup.
– Mention use of background tasks and scheduled operations for updating word scores, processing practice sessions, etc.

##### Relevant Technologies & Frameworks
– .NET Framework (ASP.NET MVC/Web API) for the server-side.
– AngularJS for the client-side.
– RavenDB for persistence (inferred from Raven Studio and Index files).
– NLog for logging.
– Castle Windsor for dependency injection.
– Testing frameworks such as NUnit and Jasmine for unit/integration testing.
– Build tools (MSBuild, appveyor.yml for CI).

##### Essential Elements
– Clear labels and boundaries for each major component and layer.
– Optionally, add annotations indicating the use of specific patterns (such as “CQRS”, “DI via Castle Windsor”, “Background Task Processing”) within each layer.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        A1["AngularJS Client"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        B1["MVC Controllers"]:::backend
        B2["Configuration & Routing"]:::backend
    end

    %% Business Logic & Infrastructure
    subgraph "Business Logic & Infrastructure"
        D1["Domain Models/Commands/Events"]:::domain
        D2["IoC Container (Castle Windsor)"]:::infra
        D3["Background Tasks"]:::infra
        D4["Logging (NLog)"]:::infra
    end

    %% Data Access & Persistence
    subgraph "Data Access & Persistence"
        P1["RavenDB Indexes"]:::persistence
        P2["RavenStudio Assets"]:::persistence
    end

    %% Migration/Tooling Component
    subgraph "Migration/Tooling"
        T1["Migration Tool"]:::tooling
    end

    %% Testing Layer
    subgraph "Testing"
        TS1["Test Suite"]:::testing
    end

    %% Connections
    A1 -->|"HTTP_call"| B1
    B1 -->|"Invokes"| D1
    B1 -->|"Resolved_by"| D2
    D1 -->|"Persistence"| P1
    D1 -->|"Persistence"| P2
    D1 -->|"Triggers"| D3
    D1 -->|"Logs_to"| D4
    T1 -->|"Migrates_data"| D1
    T1 -->|"Updates"| P1
    TS1 -->|"Tests"| A1
    TS1 -->|"Tests"| B1
    TS1 -->|"Tests"| D1

    %% Click Events
    click A1 "https://github.com/dlidstrom/minaglosor/tree/master/MinaGlosor.Web/wwwroot/app"
    click B1 "https://github.com/dlidstrom/minaglosor/tree/master/MinaGlosor.Web/Controllers"
    click B2 "https://github.com/dlidstrom/minaglosor/tree/master/MinaGlosor.Web/App_Start"
    click D1 "https://github.com/dlidstrom/minaglosor/tree/master/MinaGlosor.Web/Models"
    click D2 "https://github.com/dlidstrom/minaglosor/tree/master/MinaGlosor.Web/Infrastructure/IoC"
    click D3 "https://github.com/dlidstrom/minaglosor/tree/master/MinaGlosor.Web/Infrastructure/BackgroundTasks"
    click D4 "https://github.com/dlidstrom/minaglosor/blob/master/MinaGlosor.Web/NLog.config"
    click P1 "https://github.com/dlidstrom/minaglosor/tree/master/MinaGlosor.Web/Models/Indexes"
    click P2 "https://github.com/dlidstrom/minaglosor/blob/master/MinaGlosor.Web/Raven.Studio.Html5.zip"
    click T1 "https://github.com/dlidstrom/minaglosor/blob/master/MinaGlosor.Tool"
    click TS1 "https://github.com/dlidstrom/minaglosor/blob/master/MinaGlosor.Test"

    %% Styles
    classDef frontend fill:#f9f,stroke:#333,stroke-width:2px;
    classDef backend fill:#ccf,stroke:#333,stroke-width:2px;
    classDef domain fill:#cfc,stroke:#333,stroke-width:2px;
    classDef infra fill:#fc9,stroke:#333,stroke-width:2px;
    classDef persistence fill:#cff,stroke:#333,stroke-width:2px;
    classDef tooling fill:#f99,stroke:#333,stroke-width:2px;
    classDef testing fill:#9f9,stroke:#333,stroke-width:2px;
```
