# maacpiash/konschool architecture

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

- Interactive diagram: https://gitdiagram.com/maacpiash/konschool
- Repository: https://github.com/maacpiash/konschool

## Overview

##### Main components

- Frontend/UI Layer:
- Represented by the Razor Pages (located in src/Pages) and static assets under wwwroot.
- Shows pages like “Index,” “About,” “Contact,” “Analysis,” “Inputs,” and “Outputs” that build the user interface.

- REST API Layer:
- API endpoints (under src/ApiControllers) for Fuzzy AHP (‘/api/fahp’) and school data (‘/api/schools’).
- These endpoints offer programmatic access and should be drawn as separate components interacting with the frontend.

- Business Logic / Service Layer:
- Service components (for example, SchoolService in src/Services), along with models (in src/Models) that encapsulate the Fuzzy AHP algorithm, scoring calculations, and data queries.

- Data Layer / External Data Source:
- Although the core application code does not directly implement a complete data access layer, the “data” folder and the README’s reference to an external SQLite DB imply that school datasets are read (possibly via external configuration references).

- Infrastructure/Deployment Components:
- Hosting environment(s) (e.g., Azure, Heroku, Docker) since the README details multiple deployment options.

##### Relationships and interactions

- From the User Interface (Razor Pages) to the API:

- Between API Controllers and the Service Layer:
- That the API endpoints delegate the fuzzy AHP calculations and school queries to the corresponding Services in the business logic layer.

- Business Logic to Data Layer:
- Method calls or data flows where the Service Layer accesses the dataset (whether it’s a file, database, or external API) to fetch and process school data.

- Infrastructure:

##### Architectural patterns and design principles

- MVC (or Page Model) pattern:
- The Razor Pages and Controllers suggest a separation of concerns between UI handling and business logic.
- Clearly distinguish the views (in src/Pages) from the controllers and services.

- RESTful API design:
- That some components expose resources using standard API endpoints with JSON responses.

- Separation of concerns:
- The clear directory organization (src for application code, tests for unit and integration tests, docs for documentation, data for datasets) shows that the project enforces modular design.

##### Relevant technologies and frameworks

- .NET Core 3.1 LTS – the application’s core runtime and framework for backend logic.
- Razor Pages – for server-side rendered UI.
- Docker – for containerization and deployment.
- Testing frameworks – as seen in the tests directory for API, model, and page model testing.
- CI/CD tools (AppVeyor, Travis, Codecov) – which indicate an automated build and testing pipeline.
- External libraries – for instance, Bootstrap, Chart.js, and Materialize under wwwroot/lib indicate front-end styling and visualization support.
- Fuzzy AHP computation logic – which is integral to the recommendation system.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    subgraph "User Interaction"
        User["User Browser"]:::client
    end

    %% Frontend/UI Layer
    subgraph "Frontend/UI Layer"
        UI["Razor Pages UI"]:::frontend
        Assets["Static Assets"]:::frontend
    end

    %% REST API Layer
    subgraph "REST API Layer"
        FAHP_API["Fuzzy AHP API Controller"]:::api
        Schools_API["Schools API Controller"]:::api
    end

    %% Business Logic / Service Layer
    subgraph "Business Logic / Service Layer"
        Service["School Service"]:::service
        Models["Fuzzy AHP Models & Business Logic"]:::service
    end

    %% Data Layer / External Data Source
    subgraph "Data Layer / External Data Source"
        DataStore["External School Data Store"]:::database
    end

    %% Infrastructure/Deployment
    subgraph "Infrastructure/Deployment"
        Docker["Docker Support"]:::infrastructure
        CI_CD["CI/CD Pipelines"]:::infrastructure
        Cloud["Cloud Deployment"]:::infrastructure
    end

    %% Relationships
    User -->|"Uses"| UI
    User -->|"Loads"| Assets
    UI -->|"APIRequest"| FAHP_API
    UI -->|"APIRequest"| Schools_API
    FAHP_API -->|"Delegates"| Service
    Schools_API -->|"Delegates"| Service
    Service -->|"ComputesWith"| Models
    Service -->|"FetchesData"| DataStore
    Models -->|"UsesDataFrom"| DataStore
    Cloud -->|"Hosts"| UI
    Cloud -->|"Hosts"| FAHP_API
    Cloud -->|"Hosts"| Service
    Docker -->|"Containerizes"| Cloud
    CI_CD -->|"Automates"| Cloud

    %% Click Events
    click UI "https://github.com/maacpiash/konschool/tree/master/src/Pages"
    click Assets "https://github.com/maacpiash/konschool/tree/master/src/wwwroot"
    click FAHP_API "https://github.com/maacpiash/konschool/blob/master/src/ApiControllers/FAHPController.cs"
    click Schools_API "https://github.com/maacpiash/konschool/blob/master/src/ApiControllers/SchoolsController.cs"
    click Service "https://github.com/maacpiash/konschool/blob/master/src/Services/SchoolService.cs"
    click Models "https://github.com/maacpiash/konschool/tree/master/src/Models"
    click DataStore "https://github.com/maacpiash/konschool/tree/master/data"
    click Docker "https://github.com/maacpiash/konschool/tree/master/src/Dockerfile"
    click CI_CD "https://github.com/maacpiash/konschool/tree/master/.github/workflows"

    %% Styles
    classDef frontend fill:#C1E1C1,stroke:#333,stroke-width:2px;
    classDef api fill:#FDFD96,stroke:#333,stroke-width:2px;
    classDef service fill:#FFDEAD,stroke:#333,stroke-width:2px;
    classDef database fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef infrastructure fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef client fill:#FFB6C1,stroke:#333,stroke-width:2px;
```
