# gururajkl/whitelagoon architecture

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

- Interactive diagram: https://gitdiagram.com/gururajkl/whitelagoon
- Repository: https://github.com/gururajkl/whitelagoon

## Overview

##### Main Components
- Domain Layer (WhiteLagoon.Domain): Contains the core business entities such as Amenity, Booking, Villa, VillaNumber, ApplicationUser, etc. This is the heart of the application’s business logic.
- Application Layer (WhiteLagoon.Application): Houses business logic, Data Transfer Objects (DTOs) like LineChartDTO, PieChartDTO, RadialBarChartDTO, service interfaces (e.g., IDashboardService), and concrete service implementations (e.g., DashboardService). This layer defines contracts (interfaces) for repositories and units of work.
- Infrastructure Layer (WhiteLagoon.Infrastructure): Implements data persistence logic including the ApplicationDbContext, repositories (e.g., AmenityRepository, VillaRepository), UnitOfWork, and database migrations for evolving the database schema (migrating Identity, adding properties, seeding data, etc.).
- Web Layer (WhiteLagoon.Web): Delivers the presentation/UI part of the MVC-based application with Controllers, Views, ViewModels, and static assets (CSS, JavaScript files including charting scripts, and libraries like Bootstrap and jQuery). It also contains Identity controllers (AccountController) and view configurations for login, registration, and error handling.

##### Relationships and Interactions
- The Web layer (UI/Controllers) interacts with the Application layer services and indirectly triggers business logic.
- The Application layer defines repository interfaces that are concretely implemented in the Infrastructure layer. This ensures a clear separation of concerns and encourages dependency inversion.
- The Infrastructure layer deals with data access including database context management and seeding, and it is decoupled from the UI by its use of interfaces from the Application layer.
- The Domain layer sits at the center, with all business entities and rules, ensuring that both Application and Infrastructure layers depend on the Domain rather than the other way around.
- ASP.NET Identity is integrated across layers (primarily via the Web and Infrastructure projects) to secure access, with corresponding entities and migrations as seen in the file tree.

##### Architectural Patterns and Design Principles
- Clean Architecture: The structure enforces separation of concerns with distinct layers for Domain, Application, Infrastructure, and Presentation (Web).
- Repository and Unit of Work Patterns: These are evident in the Infrastructure layer where repository interfaces and concrete implementations (including UnitOfWork) are used to manage data persistence.
- MVC Pattern: The presentation layer (Web) follows a Model-View-Controller design, as shown in the Controllers, Views, and ViewModels directories.
- Use of Data Transfer Objects (DTOs): The Application layer leverages DTOs to transfer data between layers, particularly for dashboard/chart functionalities, indicating a design geared toward decoupled communication among layers.

##### Relevant Technologies and Frameworks
- ASP.NET (most likely Core based on the file structure and project files)
- ASP.NET Identity for authentication and security.
- Entity Framework (evident from migrations and DbContext in the Infrastructure layer).
- JavaScript libraries for advanced charting (evident from ApexCharts files and custom dashboard JS scripts).
- Front-end libraries such as Bootstrap and jQuery for responsive design and enhanced UI functionality.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Domain Layer
    subgraph "Domain Layer"
        DomainEntities["Domain Entities"]:::domain
    end

    %% Application Layer
    subgraph "Application Layer"
        DTOs["DTOs (LineChart, PieChart, RadialBarChart)"]:::application
        IDashboardService["IDashboardService"]:::application
        DashboardService["DashboardService"]:::application
        RepoInterfaces["Repository Interfaces"]:::application
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        AppDbContext["ApplicationDbContext"]:::infrastructure
        DbMigrations["Database Migrations"]:::infrastructure
        RepositoriesUW["Repositories & UnitOfWork"]:::infrastructure
        DbInitializer["DbInitializer"]:::infrastructure
    end

    %% Web Layer
    subgraph "Web Layer"
        Controllers["Controllers"]:::web
        MVCViews["MVC Views"]:::web
        ViewModels["ViewModels"]:::web
        FrontendAssets["Frontend Assets"]:::web
        ApexCharts["ApexCharts & JS"]:::external
    end

    %% Security (ASP.NET Identity)
    subgraph "Security"
        ASPIdentity["ASP.NET Identity"]:::security
    end

    %% Connections between layers
    Controllers -->|"calls"| IDashboardService
    IDashboardService ---|"implementedBy"| DashboardService
    DashboardService -->|"returnsDTO"| DTOs
    DashboardService -->|"uses"| RepoInterfaces
    RepoInterfaces -->|"implementedBy"| RepositoriesUW
    RepositoriesUW -->|"usesDb"| AppDbContext
    DbInitializer -->|"initializes"| AppDbContext
    AppDbContext -->|"migratedBy"| DbMigrations
    DashboardService -->|"usesDomain"| DomainEntities
    RepoInterfaces -->|"usesDomain"| DomainEntities

    Controllers -->|"renders"| MVCViews
    MVCViews -->|"binds"| ViewModels
    Controllers -->|"binds"| ViewModels
    FrontendAssets -->|"provides"| ApexCharts

    %% ASP.NET Identity cross-cutting
    Controllers -->|"authenticatesWith"| ASPIdentity
    DbMigrations -->|"configures"| ASPIdentity

    %% Click Events
    click DomainEntities "https://github.com/gururajkl/whitelagoon/tree/master/WhiteLagoon.Domain/Entities"
    click DTOs "https://github.com/gururajkl/whitelagoon/tree/master/WhiteLagoon.Application/Common/DataTransferObject"
    click IDashboardService "https://github.com/gururajkl/whitelagoon/tree/master/WhiteLagoon.Application/Services/Interface"
    click DashboardService "https://github.com/gururajkl/whitelagoon/tree/master/WhiteLagoon.Application/Services/Implementation"
    click RepoInterfaces "https://github.com/gururajkl/whitelagoon/tree/master/WhiteLagoon.Application/Common/Interfaces"
    click AppDbContext "https://github.com/gururajkl/whitelagoon/blob/master/WhiteLagoon.Infrastructure/Data/ApplicationDbContext.cs"
    click DbMigrations "https://github.com/gururajkl/whitelagoon/tree/master/WhiteLagoon.Infrastructure/Migrations"
    click RepositoriesUW "https://github.com/gururajkl/whitelagoon/tree/master/WhiteLagoon.Infrastructure/Repository"
    click DbInitializer "https://github.com/gururajkl/whitelagoon/blob/master/WhiteLagoon.Infrastructure/Data/DbInitializer.cs"
    click Controllers "https://github.com/gururajkl/whitelagoon/tree/master/WhiteLagoon.Web/Controllers"
    click MVCViews "https://github.com/gururajkl/whitelagoon/tree/master/WhiteLagoon.Web/Views"
    click ViewModels "https://github.com/gururajkl/whitelagoon/tree/master/WhiteLagoon.Web/ViewModels"
    click FrontendAssets "https://github.com/gururajkl/whitelagoon/tree/master/WhiteLagoon.Web/wwwroot"

    %% Styles
    classDef domain fill:#FAD7A0,stroke:#D68910,color:black;
    classDef application fill:#AED6F1,stroke:#5DADE2,color:black;
    classDef infrastructure fill:#A9DFBF,stroke:#27AE60,color:black;
    classDef web fill:#F5B7B1,stroke:#E74C3C,color:black;
    classDef security fill:#D7BDE2,stroke:#8E44AD,color:black;
    classDef external fill:#D6EAF8,stroke:#3498DB,color:black;
```
