# itprovn86/fptuniversity-training architecture

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

- Interactive diagram: https://gitdiagram.com/itprovn86/fptuniversity-training
- Repository: https://github.com/itprovn86/fptuniversity-training

## Overview

##### Project Type and Purpose
- This is a full-stack .NET application handling both a web MVC front end and an OData API. The solution is structured into clearly separated layers – a business layer (UniversityBusiness), a data access layer (UniversityDataAccess), an MVC presentation layer (UniversityMVC), and an API layer (UniversityOData).
- The project handles university-related data (students, specializations, etc.) and even includes bot components, hinting at interactive functionality.

##### Analyzing the File Structure
- UniversityBusiness: This project includes Entity Framework migrations (files under Migrations) and model classes (Student, Specialization) along with the DbContext. It represents your domain/business logic and database connectivity.
- UniversityDataAccess: Contains DAOs and repository interfaces/implementations (such as SpecializationDAO.cs, StudentDAO.cs, and repository pattern classes), encapsulating data operations and abstracting database interactions.
- UniversityMVC: As the web presentation layer, it contains Controllers, Views, Models, static assets (CSS, JS, libraries like Bootstrap and jQuery), and even Bot adapters. This is where the user interface and interactions with the system happen.
- UniversityOData: Provides API controllers (OData endpoints for Students and Specializations, plus a WeatherForecast sample) with its own Program.cs and configuration files, serving external API requests.
- Overall, the solution file (.sln) shows integration of these projects to form a cohesive application.

a. Main Components to Include:
- Presentation Layer: Represent the UniversityMVC project as a container that handles user interactions through MVC controllers, Interactive views, and Bot integration (see Bots folder).
- API Layer: Represent the UniversityOData project as a service endpoint exposing data via OData controllers.
- Business Logic Layer: Represent the UniversityBusiness project that defines your domain entities, business rules, and facilitates the database schema through Entity Framework migrations and DbContext.
- Data Access Layer: Represent the UniversityDataAccess project where the repository pattern is employed (with DAO and repository classes) to abstract database operations.
- (Optionally) Database: Though not directly visible as a file, include a database component (e.g., SQL Server) that the Entity Framework DbContext connects to.

b. Relationships and Interactions:
- The MVC controllers (in UniversityMVC) will invoke methods in the business layer (UniversityBusiness) and often indirectly call into the DataAccess layer for CRUD operations.
- The OData controllers (in UniversityOData) similarly retrieve data from the business and data access layers and expose it as API endpoints to external consumers.
- The Business layer (UniversityBusiness) uses the Entity Framework (via UniversityDbContext) to manage migrations and data models.
- The DataAccess layer (UniversityDataAccess) abstracts data interactions via DAOs and repository methods, which are used by both MVC and API controllers.
- Configuration files (appsettings.json in several projects, launchSettings.json, etc.) suggest that each project may have its own environment-specific settings that determine how they connect to external services or databases.

c. Architectural Patterns and Design Principles:
- Model-View-Controller (MVC) Pattern: Clearly evident in UniversityMVC.
- Repository and DAO Patterns: Present in UniversityDataAccess, promoting separation of concerns between data handling and application logic.
- Layered Architecture: The division between presentation (MVC), business, data access, and API layers ensures loose coupling and high maintainability.
- Dependency Injection: Although not explicitly described, the common .NET practices suggest that DI is used for connecting controllers to business logic and data repositories.

d. Technologies, Frameworks, and Libraries:
- ASP.NET MVC for the Web Application.
- Entity Framework for ORM and migrations (as seen in UniversityBusiness).
- OData technology for the API endpoints (in UniversityOData).
- Bootstrap, jQuery, and related client-side libraries present in UniversityMVC for responsive design.
- C# as the primary language, with Visual Studio solution management (FPTUniversity.sln).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Entities
    User["User"]:::external
    ExternalAPI["ExternalAPICaller"]:::external

    %% Presentation Layer: UniversityMVC
    subgraph "Presentation Layer (UniversityMVC)"
        MVCControllers["MVC Controllers, Views & Assets"]:::presentation
        Bots["Bot Components"]:::presentation
    end

    %% API Layer: UniversityOData
    subgraph "API Layer (UniversityOData)"
        ODataControllers["OData API Controllers"]:::api
        APIConfig["Configuration & Startup"]:::api
    end

    %% Business Logic Layer: UniversityBusiness
    subgraph "Business Logic Layer (UniversityBusiness)"
        DomainModels["Domain Models (Student, Specialization)"]:::business
        Migrations["EF Migrations"]:::business
        DbContext["UniversityDbContext"]:::business
    end

    %% Data Access Layer: UniversityDataAccess
    subgraph "Data Access Layer (UniversityDataAccess)"
        DAOs["Data Access Objects (DAOs)"]:::dataAccess
        Repositories["Repositories & Interfaces"]:::dataAccess
    end

    %% Database Component
    Database["Database (SQL Server)"]:::database

    %% Connections / Data Flow
    User -->|"triggers"| MVCControllers
    ExternalAPI -->|"calls"| ODataControllers
    MVCControllers -->|"invokes"| DomainModels
    ODataControllers -->|"invokes"| DomainModels
    Bots -->|"integrates_with"| MVCControllers

    DomainModels -->|"configured_by"| DbContext
    DomainModels -->|"uses"| DAOs
    DomainModels -->|"uses"| Repositories

    Migrations -->|"updates_schema"| Database
    DbContext -->|"manages"| Database
    DAOs -->|"queries"| Database
    Repositories -->|"queries"| Database

    %% Click Events for Component Mapping
    click MVCControllers "https://github.com/itprovn86/fptuniversity-training/tree/master/UniversityMVC"
    click Bots "https://github.com/itprovn86/fptuniversity-training/tree/master/UniversityMVC/Bots"
    click ODataControllers "https://github.com/itprovn86/fptuniversity-training/tree/master/UniversityOData/Controllers"
    click APIConfig "https://github.com/itprovn86/fptuniversity-training/blob/master/UniversityOData/Program.cs"
    click DomainModels "https://github.com/itprovn86/fptuniversity-training/tree/master/UniversityBusiness"
    click Migrations "https://github.com/itprovn86/fptuniversity-training/tree/master/UniversityBusiness/Migrations"
    click DbContext "https://github.com/itprovn86/fptuniversity-training/blob/master/UniversityBusiness/UniversityDbContext.cs"
    click DAOs "https://github.com/itprovn86/fptuniversity-training/tree/master/UniversityDataAccess/DAO"
    click Repositories "https://github.com/itprovn86/fptuniversity-training/tree/master/UniversityDataAccess/Repositories"

    %% Styling Classes
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef presentation fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef api fill:#FA8072,stroke:#000,stroke-width:2px;
    classDef business fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef dataAccess fill:#FFFACD,stroke:#000,stroke-width:2px;
    classDef database fill:#F4A460,stroke:#000,stroke-width:2px;
```
