# kostavlev/wilson architecture

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

- Interactive diagram: https://gitdiagram.com/kostavlev/wilson
- Repository: https://github.com/kostavlev/wilson

## Overview

a. Domain Modules – There are separate domain-specific modules:
- Accounting Module – Contains the Wilson.Accounting.Core and Data projects. It defines domain entities (like Invoice, Bill, Employee, etc.), value objects, enumerations, and related configurations using Entity Framework.
- Companies Module – Holds the Wilson.Companies.Core and its Data layer. It includes domain entities for companies, employees, roles, and contracts.
- Projects Module – Contains basic project entities and its associated data access.
- Scheduler Module – Manages scheduling, pay rates, and work hours along with similar domain/entity definitions.
b. Data Access and Infrastructure Layers – Each module includes its own DbContext, migrations, repositories, and configuration classes. They encapsulate persistence logic and are designed following DDD principles.
c. Web / Presentation Layer – The Web project (Wilson.Web) organizes its UI into separate areas (Accounting, Companies, Scheduler, Admin) with controllers, view models, view components, AutoMapper configurations, and common services. It handles user authentication (Account controllers, Manage controllers) and integrates the different modules.
d. Common Services & Events – The Web project contains shared infrastructure such as event handling (domain events like CompanyCreated and EmployeeCreated) and utility services for email and SMS.

##### Out the interactions and relationships
- Each domain module (Accounting, Companies, Projects, Scheduler) maintains its own core business logic and data access layer. They can be diagrammed as separate “bounded contexts.”
- The Web project is the integration front-end which calls into these modules’ services and repositories (or domain services) to present a unified ERP system.
- An API or service layer abstraction (e.g., the “Services” provided within each area) mediates between the presentation layer and the domain/data layers.
- Shared components like AutoMapper configurations and event handlers (in the Events folder) show cross‑module integration for tasks such as synchronization or broadcasting domain events.

##### Important architectural patterns/design principles
- Layered Architecture / N‑Tier: Domain (Core), Data (Infrastructure), and Presentation layers are clearly separated.
- Domain-Driven Design (DDD): Noted by the separation into “Core” projects for business logic/entities, rich domain models with value objects, and repository patterns in the Data projects.
- Modular/Boun‑ded Contexts: Each module is self-contained and can be represented as a bounded context interacting through set interfaces in the web layer.
- Repository Pattern: Data access repositories are used for decoupling business logic from persistence specifics.
- MVC Pattern: Employed in the Web project (separation of controllers, views, and models).

- Configuration/data seeding components (found under Web/Seed) which indicate how the system initializes or populates data.
- Supporting files (e.g., launchSettings.json, migrations) only if they add clarity on deployment or configuration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Web / Presentation Layer
    subgraph "Web / Presentation Layer"
        web["Web Presentation Layer"]:::presentation
    end

    %% Accounting Module
    subgraph "Accounting Module"
        accDomain["Accounting Domain (Core)"]:::domain
        accData["Accounting Data Access"]:::data
    end

    %% Companies Module
    subgraph "Companies Module"
        compDomain["Companies Domain (Core)"]:::domain
        compData["Companies Data Access"]:::data
    end

    %% Projects Module
    subgraph "Projects Module"
        projDomain["Projects Domain (Core)"]:::domain
        projData["Projects Data Access"]:::data
    end

    %% Scheduler Module
    subgraph "Scheduler Module"
        schedDomain["Scheduler Domain (Core)"]:::domain
        schedData["Scheduler Data Access"]:::data
    end

    %% Shared Components & Configurations
    subgraph "Shared Components"
        config["AutoMapper & Configurations"]:::shared
        events["Event Handlers"]:::shared
        seed["Seed Data"]:::shared
    end

    %% Connections: Web Presentation Layer calls domain modules
    web -->|"calls"| accDomain
    web -->|"calls"| compDomain
    web -->|"calls"| projDomain
    web -->|"calls"| schedDomain

    %% Domain to Data Access for each module
    accDomain -->|"repository"| accData
    compDomain -->|"repository"| compData
    projDomain -->|"repository"| projData
    schedDomain -->|"repository"| schedData

    %% Presentation uses shared components
    web -->|"configures"| config
    web -->|"dispatches"| events
    web -->|"seeds"| seed

    %% Domain Modules dispatch events to shared Event Handlers
    accDomain -->|"events"| events
    compDomain -->|"events"| events
    projDomain -->|"events"| events
    schedDomain -->|"events"| events

    %% Click Events for Component Mapping
    click accDomain "https://github.com/kostavlev/wilson/blob/master/Accounting/Wilson.Accounting.Core"
    click accData "https://github.com/kostavlev/wilson/blob/master/Accounting/Wilson.Accounting.Data"
    click compDomain "https://github.com/kostavlev/wilson/blob/master/Companies/Wilson.Companies.Core"
    click compData "https://github.com/kostavlev/wilson/blob/master/Companies/Wilson.Companies.Data"
    click projDomain "https://github.com/kostavlev/wilson/blob/master/Projects/Wilson.Projects.Core"
    click projData "https://github.com/kostavlev/wilson/blob/master/Projects/Wilson.Projects.Data"
    click schedDomain "https://github.com/kostavlev/wilson/blob/master/Scheduler/Wilson.Scheduler.Core"
    click schedData "https://github.com/kostavlev/wilson/blob/master/Scheduler/Wilson.Scheduler.Data"
    click web "https://github.com/kostavlev/wilson/blob/master/Web/Wilson.Web"
    click config "https://github.com/kostavlev/wilson/tree/master/Web/Wilson.Web/Configurations"
    click events "https://github.com/kostavlev/wilson/tree/master/Web/Wilson.Web/Events"
    click seed "https://github.com/kostavlev/wilson/tree/master/Web/Wilson.Web/Seed"

    %% Styles
    classDef domain fill:#a2d9ce,stroke:#333,stroke-width:2px;
    classDef data fill:#aed6f1,stroke:#333,stroke-width:2px;
    classDef presentation fill:#f9e79f,stroke:#333,stroke-width:2px;
    classDef shared fill:#f5cba7,stroke:#333,stroke-width:2px;
```
