# deleriumbg/studentmanagement architecture

> Architecture diagram of the GitHub repository deleriumbg/studentmanagement, 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/deleriumbg/studentmanagement
- Repository: https://github.com/deleriumbg/studentmanagement

## Overview

##### Project Type and Purpose
- The project is a web-based ASP.NET MVC application.
- Its purpose is to display and manage student records and associated cases from Dynamics CRM.
- The README specifies three main pages: Students (home) page, Student Details page (with view/edit modes), and a Cases page for managing student-related cases. There’s also a dedicated emphasis on ensuring all retrieved records are “active” and the use of a singleton class for the CRM connection.

##### And Separate Main Components
a. Presentation Layer (Frontend):
- Views folder: Contains Razor (.cshtml) files for Home, Details, Cases pages as well as shared views like error handling.
- Controllers folder: Implements MVC controllers (HomeController, DetailsController, CasesController, ErrorController) that process user actions, coordinate for data, and select views.
- Scripts and Content directories: Manage client-side assets (jQuery, Bootstrap, custom JavaScript) and styling respectively.
b. Business/Data Access Layer:
- DAL directory: Contains CaseDataAccess.cs and StudentDataAccess.cs which encapsulate the logic for fetching and updating data.
- Models folder: Holds view models (e.g., StudentViewModel, CaseViewModel) and enum definitions (StudentStatus) to support strongly-typed views.
- Connection classes: CRMConnection.cs (and related files like Xrm.cs and IConnection) implement the singleton pattern to establish and maintain a connection to Dynamics CRM.
c. Configuration and Infrastructure:
- App_Start directory: Contains configuration files for route definitions (RouteConfig.cs), bundling and minification (BundleConfig.cs), and global filters (FilterConfig.cs).
- Global.asax: Sets up the application on start-up.
- Other configuration files: log4net.config, ApplicationInsights.config, Web.config files, and deployment configs (Web.Debug.config, Web.Release.config).

##### Representing Relationships and Data Flow
- User/Browser: Represents the client-side initiating requests.
- Frontend – Presentation Layer: Group Controllers and Views (with a note that client-side resources are managed by Scripts & Content).
- Business/Data Access Layer: Include the DAL and Models to indicate data transformation and retrieval.
- From User → Frontend: Represent user actions leading to requests.
- From Controllers → DAL: Indicate that controllers delegate data operations to the data access layer.
- From DAL → External CRM: Indicate the external call/communication to Dynamics CRM.

##### Architectural Patterns and Technologies to Highlight
- MVC Pattern: Clearly show the separation between Models, Views, and Controllers.
- Singleton Pattern for CRM Connection: Note that the CRM connection is managed as a singleton, ensuring a single instance throughout the application.
- Early Bound Entity Pattern: Mention that early bound entity classes are used for interacting with CRM data.
- Dependencies: Indicate use of frameworks and libraries like ASP.NET MVC, jQuery, Bootstrap, and logging with log4net. Other configuration files (like ApplicationInsights.config) hint at application insights and monitoring.

##### Putting It All Together
- Demonstrate how the controllers call the DAL to validate, retrieve, or update data, and how this data is encapsulated in view models before being rendered.
- Singleton CRM connection placed between the DAL and the external Dynamics CRM service, emphasizing the connection reuse and efficiency.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    User["User/Browser"]:::external

    %% Presentation Layer
    subgraph "Presentation Layer"
        %% Controllers Subgraph
        subgraph "Controllers"
            HomeController["HomeController"]:::presentation
            DetailsController["DetailsController"]:::presentation
            CasesController["CasesController"]:::presentation
            ErrorController["ErrorController"]:::presentation
        end
        %% Views Subgraph
        subgraph "Views"
            Views["Razor Views (Home, Details, Cases, Shared)"]:::presentation
        end
        %% Client Assets Subgraph
        subgraph "Client Assets"
            Scripts["Scripts"]:::presentation
            Content["Content"]:::presentation
        end
    end

    %% Business & Data Access Layer
    subgraph "Business & Data Access Layer"
        DAL["Data Access (StudentDataAccess & CaseDataAccess)"]:::business
        Models["Models (Student & Case ViewModels, enums)"]:::business
    end

    %% Integration Layer
    subgraph "Integration Layer"
        CRM["CRM Connection (Singleton)"]:::integration
        ExternalCRM["Dynamics CRM"]:::external
    end

    %% Configuration and Infrastructure
    subgraph "Configuration & Infrastructure"
        AppStart["App_Start (Route, Bundle, Filter Configs)"]:::config
        Global["Global.asax"]:::config
        Configs["Configuration Files (Web.config, log4net.config, ApplicationInsights.config)"]:::config
    end

    %% Data Flow Connections
    User -->|"navigates"| HomeController
    User -->|"navigates"| DetailsController
    User -->|"navigates"| CasesController

    HomeController -->|"calls"| DAL
    DetailsController -->|"calls"| DAL
    CasesController -->|"calls"| DAL

    DAL -->|"populates"| Models

    DAL -->|"uses"| CRM
    CRM -->|"retrieves"| ExternalCRM

    HomeController -->|"renders"| Views
    DetailsController -->|"renders"| Views
    CasesController -->|"renders"| Views

    Views -->|"loads"| Scripts
    Views -->|"loads"| Content

    %% Application Initialization Flow
    Global -->|"configures"| AppStart
    AppStart -->|"routes"| HomeController
    AppStart -->|"routes"| DetailsController
    AppStart -->|"routes"| CasesController
    AppStart -->|"routes"| ErrorController
    Global -->|"loads"| Configs

    %% Click Events
    click Views "https://github.com/deleriumbg/studentmanagement/tree/master/StudentManagement/Views"
    click HomeController "https://github.com/deleriumbg/studentmanagement/blob/master/StudentManagement/Controllers/HomeController.cs"
    click DetailsController "https://github.com/deleriumbg/studentmanagement/blob/master/StudentManagement/Controllers/DetailsController.cs"
    click CasesController "https://github.com/deleriumbg/studentmanagement/blob/master/StudentManagement/Controllers/CasesController.cs"
    click ErrorController "https://github.com/deleriumbg/studentmanagement/blob/master/StudentManagement/Controllers/ErrorController.cs"
    click Scripts "https://github.com/deleriumbg/studentmanagement/tree/master/StudentManagement/Scripts"
    click Content "https://github.com/deleriumbg/studentmanagement/tree/master/StudentManagement/Content"
    click DAL "https://github.com/deleriumbg/studentmanagement/tree/master/StudentManagement/DAL"
    click Models "https://github.com/deleriumbg/studentmanagement/tree/master/StudentManagement/Models"
    click CRM "https://github.com/deleriumbg/studentmanagement/blob/master/StudentManagement/CRMConnection.cs"
    click AppStart "https://github.com/deleriumbg/studentmanagement/tree/master/StudentManagement/App_Start"
    click Global "https://github.com/deleriumbg/studentmanagement/blob/master/StudentManagement/Global.asax"
    click Configs "https://github.com/deleriumbg/studentmanagement/blob/master/StudentManagement/Web.config"

    %% Styles
    classDef presentation fill:#f9e79f,stroke:#333,stroke-width:2px;
    classDef business fill:#aed6f1,stroke:#333,stroke-width:2px;
    classDef integration fill:#a3e4d7,stroke:#333,stroke-width:2px;
    classDef config fill:#f5b7b1,stroke:#333,stroke-width:2px;
    classDef external fill:#d7bde2,stroke:#333,stroke-width:2px;
```
