# anexsoft/asp.net-mvc-5-arquitectura-base architecture

> Architecture diagram of the GitHub repository anexsoft/asp.net-mvc-5-arquitectura-base, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anexsoft/asp.net-mvc-5-arquitectura-base
- Repository: https://github.com/anexsoft/asp.net-mvc-5-arquitectura-base

## Overview

##### Main Components
- FrontEnd (Project "01-FrontEnd"): This is the ASP.NET MVC 5 UI layer, which includes controllers, views, view models, route configurations, and front-end assets (managed via Bower for libraries like Bootstrap, jQuery, and Font Awesome). It also integrates ASP.NET Identity for authentication.
- Service Layer (Project "02-Service"): This layer contains business logic. There are at least two service projects here – one focused on authentication (“Auth.Service”) and another for general services (e.g., CourseService, StudentService, UserService). This layer bridges the presentation and data access layers.
- Persistence Layer (Project "03-Persistence"): This includes the database context, mappings, migrations, repository patterns, and also a separate project for managing DbContext scopes. This layer abstracts data access and enforces the Repository Pattern.
- Common Utilities (Project "04-Common"): This project holds shared code – helper classes (such as CurrentUserHelper, ResponseHelper), custom filters (like SoftDeleted), extensions (for DateTime, String, etc.), and dependency injection configurations (using LightInject), which are available across the solution.
- Unit Testing (Project "05-UnitTest"): Contains tests that validate the functionality across these layers.

##### Component Relationships and Data Flows
- The FrontEnd interacts with the Service Layer by making calls (either via internal service classes or Web APIs) from controllers.
- The Service Layer encapsulates the business logic and, in turn, calls the Persistence Layer’s repositories to read/write data.
- The Persistence Layer manages database connections and data operations using EF (Entity Framework) and supports mapping (defined in separate mapping files) and migrations.
- Both the FrontEnd and Service layers may also utilize elements from the Common Utilities for tasks like dependency injection, logging (NLog), user auditing, and parameter configuration.
- The Unit Test project touches different components by testing common utilities, business logic (service classes), and even parts of the data access layer.

##### Important Architectural Patterns and Technologies
- MVC Pattern in the FrontEnd (with Controllers, Views, and ViewModels).
- Layered Architecture/Separation of Concerns: Presentation (FrontEnd), Business Logic (Service), Data Access (Persistence), and Shared (Common).
- Repository Pattern in the Persistence Layer.
- Dependency Injection (using LightInject) across the solution to ensure loose coupling.
- ASP.NET Identity for authentication and authorization.
- Front-end dependency management via Bower.
- Logging using NLog.
- Automated unit testing for quality assurance.
- Automatic Parameters and SoftDeleted functionality integrated into common filters or helper functions.

##### Final Advice for the Principal Software Engineer
- Be detailed: capture the specifics such as the role of ASP.NET Identity, repository patterns, and external library management through Bower.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        FE["ASP.NET MVC UI (Controllers, Views, ViewModels, ASP.NET Identity)"]:::frontend
        Bower["Bower Dependencies (Bootstrap, jQuery, Font Awesome)"]:::external
    end

    %% Service Layer
    subgraph "Service Layer"
        AS["Auth Service (Authentication)"]:::service
        GS["General Services (Course, Student, User, etc.)"]:::service
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        PC1["Database Context & Mappings (EF)"]:::persistence
        PC2["DbContext Scoping"]:::persistence
        PC3["Repository/Data Access"]:::persistence
    end

    %% Common Utilities
    subgraph "Common Utilities"
        CM["Common Helpers & DI (LightInject, NLog, Extensions)"]:::common
    end

    %% Unit Testing
    subgraph "Unit Testing"
        UT["Unit Test Suite"]:::testing
    end

    %% Relationships between layers
    Bower -->|"provides_assets"| FE
    FE -->|"calls"| AS
    FE -->|"calls"| GS

    AS -->|"accesses"| PC3
    GS -->|"accesses"| PC3

    PC3 -->|"uses"| PC1
    PC3 -->|"uses"| PC2

    FE -->|"utilizes"| CM
    AS -->|"utilizes"| CM
    GS -->|"utilizes"| CM
    PC1 -->|"utilizes"| CM
    PC2 -->|"utilizes"| CM
    PC3 -->|"utilizes"| CM

    UT -->|"tests"| FE
    UT -->|"tests"| AS
    UT -->|"tests"| GS
    UT -->|"tests"| PC3
    UT -->|"tests"| CM

    %% Click Events
    click FE "https://github.com/anexsoft/asp.net-mvc-5-arquitectura-base/tree/master/01-FrontEnd"
    click AS "https://github.com/anexsoft/asp.net-mvc-5-arquitectura-base/blob/master/02-Service/Auth.Service"
    click GS "https://github.com/anexsoft/asp.net-mvc-5-arquitectura-base/tree/master/02-Service/Service"
    click PC1 "https://github.com/anexsoft/asp.net-mvc-5-arquitectura-base/blob/master/03-Persistence/Persistence.DatabaseContext"
    click PC2 "https://github.com/anexsoft/asp.net-mvc-5-arquitectura-base/blob/master/03-Persistence/Persistence.DbContextScope"
    click PC3 "https://github.com/anexsoft/asp.net-mvc-5-arquitectura-base/blob/master/03-Persistence/Persistence.Repository"
    click CM "https://github.com/anexsoft/asp.net-mvc-5-arquitectura-base/tree/master/04-Common"
    click UT "https://github.com/anexsoft/asp.net-mvc-5-arquitectura-base/tree/master/05-UnitTest"

    %% Styles
    classDef frontend fill:#a3c1ad,stroke:#333,stroke-width:1px;
    classDef service fill:#f9d9d7,stroke:#333,stroke-width:1px;
    classDef persistence fill:#c6e2ff,stroke:#333,stroke-width:1px;
    classDef common fill:#ffe6a7,stroke:#333,stroke-width:1px;
    classDef testing fill:#d1c4e9,stroke:#333,stroke-width:1px;
    classDef external fill:#ffccb3,stroke:#333,stroke-width:1px;
```
