# azure-samples/app-templates-dotnet-azuresql-appservice architecture

> Architecture diagram of the GitHub repository azure-samples/app-templates-dotnet-azuresql-appservice, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/azure-samples/app-templates-dotnet-azuresql-appservice
- Repository: https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice

## Overview

Contoso University is a Razor Pages frontend backed by a separate ASP.NET Core API and Entity Framework Core data layer. Users manage students, courses, departments, and instructors: the web pages issue HTTP requests to the API, whose controllers query or update the SQL-backed context and return DTO-shaped results. API startup also initializes sample data. The README documents Azure hosting, Azure SQL, and Application Insights; the available source excerpts do not show frontend client configuration or telemetry wiring, so those connections are not asserted here.

Main entry points: [`src/ContosoUniversity.API/Program.cs`](https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/blob/main/src/ContosoUniversity.API/Program.cs) (API host), [`src/ContosoUniversity.API/Data/ContosoUniversityAPIContext.cs`](https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/blob/main/src/ContosoUniversity.API/Data/ContosoUniversityAPIContext.cs) (EF Core context), [`src/ContosoUniversity.API/Controllers/CoursesController.cs`](https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/blob/main/src/ContosoUniversity.API/Controllers/CoursesController.cs) (Courses API), [`src/ContosoUniversity.API/Controllers/DepartmentsController.cs`](https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/blob/main/src/ContosoUniversity.API/Controllers/DepartmentsController.cs) (Departments API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web frontend"]
  node_webapp["Razor Pages app<br/>[Program.cs]"]
  node_course_pages["Course pages<br/>[Courses]"]
  node_department_pages["Department pages<br/>[Departments]"]
  node_instructor_pages["Instructor pages<br/>[Instructors]"]
  node_student_pages["Student pages<br/>[Students]"]
  node_web_api_models["API view models<br/>[APIViewModels]"]
  node_pagination["Pagination helper<br/>[PaginatedList.cs]"]
end

subgraph group_api["University API"]
  node_api_host["API host<br/>[Program.cs]"]
  node_courses_api["Courses API"]
  node_departments_api["Departments API"]
  node_instructors_api["Instructors API"]
  node_students_api["Students API"]
  node_api_dtos["API result DTOs<br/>[DTO]"]
  node_app_insights["Application Insights"]
end

subgraph group_data["Persistence and domain"]
  node_ef_context["EF Core context"]
  node_initializer["Sample data initializer<br/>[DbInitializer.cs]"]
  node_domain_models["University entities<br/>[Models]"]
  node_sql[("Azure SQL database")]
  node_key_vault["Azure Key Vault"]
end

node_user(("University user"))

node_user -->|"uses"| node_webapp
node_course_pages -.->|"HTTP requests"| node_courses_api
node_department_pages -.->|"HTTP requests"| node_departments_api
node_instructor_pages -.->|"HTTP requests"| node_instructors_api
node_student_pages -.->|"HTTP requests"| node_students_api
node_course_pages -->|"deserializes to"| node_web_api_models
node_webapp -.->|"hosts"| node_course_pages
node_api_host -.->|"routes"| node_courses_api
node_api_host -.->|"routes"| node_departments_api
node_api_host -.->|"routes"| node_instructors_api
node_api_host -.->|"routes"| node_students_api
node_courses_api -->|"queries and updates"| node_ef_context
node_departments_api -->|"queries and updates"| node_ef_context
node_instructors_api -->|"queries and updates"| node_ef_context
node_students_api -->|"queries and updates"| node_ef_context
node_courses_api -->|"maps results"| node_api_dtos
node_departments_api -->|"maps results"| node_api_dtos
node_students_api -->|"maps results"| node_api_dtos
node_ef_context -->|"maps entities"| node_domain_models
node_api_host -->|"registers and resolves"| node_ef_context
node_api_host -->|"runs at startup"| node_initializer
node_initializer -->|"seeds"| node_ef_context
node_ef_context -.->|"persists via EF Core"| node_sql
node_api_host -->|"loads secrets from"| node_key_vault
node_api_host -->|"configures telemetry"| node_app_insights

click node_webapp "https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/blob/main/src/ContosoUniversity.WebApplication/Program.cs"
click node_course_pages "https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/tree/main/src/ContosoUniversity.WebApplication/Pages/Courses"
click node_department_pages "https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/tree/main/src/ContosoUniversity.WebApplication/Pages/Departments"
click node_instructor_pages "https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/tree/main/src/ContosoUniversity.WebApplication/Pages/Instructors"
click node_student_pages "https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/tree/main/src/ContosoUniversity.WebApplication/Pages/Students"
click node_web_api_models "https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/tree/main/src/ContosoUniversity.WebApplication/Models/APIViewModels"
click node_pagination "https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/blob/main/src/ContosoUniversity.WebApplication/PaginatedList.cs"
click node_api_host "https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/blob/main/src/ContosoUniversity.API/Program.cs"
click node_courses_api "https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/blob/main/src/ContosoUniversity.API/Controllers/CoursesController.cs"
click node_departments_api "https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/blob/main/src/ContosoUniversity.API/Controllers/DepartmentsController.cs"
click node_instructors_api "https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/blob/main/src/ContosoUniversity.API/Controllers/InstructorsController.cs"
click node_students_api "https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/blob/main/src/ContosoUniversity.API/Controllers/StudentsController.cs"
click node_api_dtos "https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/tree/main/src/ContosoUniversity.API/DTO"
click node_ef_context "https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/blob/main/src/ContosoUniversity.API/Data/ContosoUniversityAPIContext.cs"
click node_initializer "https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/blob/main/src/ContosoUniversity.API/Data/DbInitializer.cs"
click node_domain_models "https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/tree/main/src/ContosoUniversity.API/Models"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_webapp,node_course_pages,node_department_pages,node_instructor_pages,node_student_pages,node_web_api_models,node_pagination,node_user toneBlue
class node_api_host,node_courses_api,node_departments_api,node_instructors_api,node_students_api,node_api_dtos,node_app_insights toneAmber
class node_ef_context,node_initializer,node_domain_models,node_sql,node_key_vault toneMint
```

## Components

### Web frontend

- [Razor Pages app](https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/blob/main/src/ContosoUniversity.WebApplication/Program.cs): `src/ContosoUniversity.WebApplication/Program.cs`
- [Course pages](https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/tree/main/src/ContosoUniversity.WebApplication/Pages/Courses): `src/ContosoUniversity.WebApplication/Pages/Courses`
- [Department pages](https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/tree/main/src/ContosoUniversity.WebApplication/Pages/Departments): `src/ContosoUniversity.WebApplication/Pages/Departments`
- [Instructor pages](https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/tree/main/src/ContosoUniversity.WebApplication/Pages/Instructors): `src/ContosoUniversity.WebApplication/Pages/Instructors`
- [Student pages](https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/tree/main/src/ContosoUniversity.WebApplication/Pages/Students): `src/ContosoUniversity.WebApplication/Pages/Students`
- [API view models](https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/tree/main/src/ContosoUniversity.WebApplication/Models/APIViewModels): `src/ContosoUniversity.WebApplication/Models/APIViewModels`
- [Pagination helper](https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/blob/main/src/ContosoUniversity.WebApplication/PaginatedList.cs): `src/ContosoUniversity.WebApplication/PaginatedList.cs`

### University API

- [API host](https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/blob/main/src/ContosoUniversity.API/Program.cs): `src/ContosoUniversity.API/Program.cs`
- [Courses API](https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/blob/main/src/ContosoUniversity.API/Controllers/CoursesController.cs): `src/ContosoUniversity.API/Controllers/CoursesController.cs`
- [Departments API](https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/blob/main/src/ContosoUniversity.API/Controllers/DepartmentsController.cs): `src/ContosoUniversity.API/Controllers/DepartmentsController.cs`
- [Instructors API](https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/blob/main/src/ContosoUniversity.API/Controllers/InstructorsController.cs): `src/ContosoUniversity.API/Controllers/InstructorsController.cs`
- [Students API](https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/blob/main/src/ContosoUniversity.API/Controllers/StudentsController.cs): `src/ContosoUniversity.API/Controllers/StudentsController.cs`
- [API result DTOs](https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/tree/main/src/ContosoUniversity.API/DTO): `src/ContosoUniversity.API/DTO`
- **Application Insights**

### Persistence and domain

- [EF Core context](https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/blob/main/src/ContosoUniversity.API/Data/ContosoUniversityAPIContext.cs): `src/ContosoUniversity.API/Data/ContosoUniversityAPIContext.cs`
- [Sample data initializer](https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/blob/main/src/ContosoUniversity.API/Data/DbInitializer.cs): `src/ContosoUniversity.API/Data/DbInitializer.cs`
- [University entities](https://github.com/azure-samples/app-templates-dotnet-azuresql-appservice/tree/main/src/ContosoUniversity.API/Models): `src/ContosoUniversity.API/Models`
- **Azure SQL database**
- **Azure Key Vault**

### Other components

- **University user**

## Connections

- University user → Razor Pages app: uses (evidence: `README.md`)
- Course pages → Courses API: HTTP requests
- Department pages → Departments API: HTTP requests
- Instructor pages → Instructors API: HTTP requests
- Student pages → Students API: HTTP requests
- Course pages → API view models: deserializes to (evidence: `src/ContosoUniversity.WebApplication/Pages/Courses/Edit.cshtml.cs`)
- Razor Pages app → Course pages: hosts
- API host → Courses API: routes
- API host → Departments API: routes
- API host → Instructors API: routes
- API host → Students API: routes
- Courses API → EF Core context: queries and updates (evidence: `src/ContosoUniversity.API/Controllers/CoursesController.cs`)
- Departments API → EF Core context: queries and updates (evidence: `src/ContosoUniversity.API/Controllers/DepartmentsController.cs`)
- Instructors API → EF Core context: queries and updates (evidence: `src/ContosoUniversity.API/Controllers/InstructorsController.cs`)
- Students API → EF Core context: queries and updates (evidence: `src/ContosoUniversity.API/Controllers/StudentsController.cs`)
- Courses API → API result DTOs: maps results (evidence: `src/ContosoUniversity.API/Controllers/CoursesController.cs`)
- Departments API → API result DTOs: maps results (evidence: `src/ContosoUniversity.API/Controllers/DepartmentsController.cs`)
- Students API → API result DTOs: maps results (evidence: `src/ContosoUniversity.API/Controllers/StudentsController.cs`)
- EF Core context → University entities: maps entities (evidence: `src/ContosoUniversity.API/Data/ContosoUniversityAPIContext.cs`)
- API host → EF Core context: registers and resolves (evidence: `src/ContosoUniversity.API/Program.cs`)
- API host → Sample data initializer: runs at startup (evidence: `src/ContosoUniversity.API/Program.cs`)
- Sample data initializer → EF Core context: seeds (evidence: `src/ContosoUniversity.API/Data/DbInitializer.cs`)
- EF Core context → Azure SQL database: persists via EF Core
- API host → Azure Key Vault: loads secrets from (evidence: `src/ContosoUniversity.API/Program.cs`)
- API host → Application Insights: configures telemetry (evidence: `src/ContosoUniversity.API/Program.cs`)
