# zuyd-hogeschool/narrowcasting architecture

> Architecture diagram of the GitHub repository zuyd-hogeschool/narrowcasting, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zuyd-hogeschool/narrowcasting
- Repository: https://github.com/zuyd-hogeschool/narrowcasting

## Overview

1. **Overall shape**
   - This is an ASP.NET Core application called **Narrowcasting** with a classic layered structure: **UI layer** (Razor Pages + controllers), **service layer**, **data/model layer** (EF Core), and **Identity/authentication**.
   - The solution also includes a separate **test project** and a **Dockerfile** for containerized deployment.

2. **Primary domain**
   - The app appears to manage a narrowcasting/digital-signage system: **screens**, **playlists**, **playlist items**, **media files**, **announcements**, **departments**, **users**, and **audit logs**.
   - The domain models in `Models/` are the core objects that flow through the app and are persisted by EF Core.

3. **UI boundaries**
   - The application has two main UI surfaces:
     - **Admin area** under `Pages/Admin`, used for managing users, screens, playlists, media files, departments, announcements, and audit logs.
     - **Public pages** under `Pages/Public`, including **Display** and **Cast**, which are likely the playback/runtime-facing views for screens.
   - There is also a conventional `Pages/Shared` layout structure and a separate `Areas/Identity` implementation for authentication pages.

4. **Controllers vs Razor Pages**
   - The repo mixes **MVC controllers** in `Controllers/` with **Razor Pages** in `Pages/`.
   - The controllers likely expose CRUD or API-style endpoints for core resources such as announcements, playlists, screens, departments, users, and audit logs.
   - The Razor Pages area is used for the admin dashboard and public-facing pages, keeping interactive site flows distinct from controller endpoints.

5. **Service layer**
   - Business logic is concentrated in `Services/` and abstracted behind interfaces in `Interfaces/`.
   - Each major business concept has a service contract and implementation: `IAnnouncementService`, `IPlaylistService`, `IScreenService`, `IMediaFileService`, `IDepartmentService`, `IAuditService`, and `IPlaylistItemService`.
   - `ServiceExtensions.cs` suggests a dependency-injection composition boundary where services are registered into the ASP.NET Core container.

6. **Persistence and schema**
   - `Data/ApplicationDbContext.cs` is the EF Core database context and the main persistence boundary.
   - The `Migrations/` folder contains both **Identity schema migrations** and **application model migrations**, showing that Identity and domain data share the same database context or at least the same EF Core migration pipeline.
   - The model snapshot indicates code-first schema management is the source of truth.

7. **Authentication and user management**
   - Authentication is built on **ASP.NET Core Identity**, with a full generated identity UI under `Areas/Identity`.
   - The app supports login, registration, password reset, 2FA, external login, account management, and email confirmation.
   - `Models/ApplicationUser.cs` indicates the identity user has been extended to fit the application’s domain needs.

8. **Authorization and roles**
   - The presence of `Pages/Admin`, `AdminPageModel.cs`, and dedicated `UserController` strongly suggests role-based access control around the admin functions.
   - The separation between admin and public pages implies authorization is a key boundary: public playback pages are accessible broadly, while management pages are restricted.

9. **Audit and operational visibility**
   - `AuditLog` and `AuditLogsController` / `Pages/Admin/AuditLog` indicate the system records administrative or data-change activity.
   - This is a cross-cutting subsystem rather than a business object, likely used to trace changes to playlists, screens, media, and users.

10. **Media and file handling**
   - `MediaFile` plus `MediaFileService` and the top-level `UploadedFiles/` directory indicate the application stores uploaded content on disk rather than purely in the database.
   - That creates a clear boundary between **metadata in the database** and **binary assets on the filesystem**.
   - The `Display`/`Cast` pages likely consume those stored assets to render content on a target screen.

11. **Playback/content composition flow**
   - A plausible main data flow is: admin uploads media → media is stored in `UploadedFiles` and indexed in the DB → playlists are assembled from playlist items → screens are assigned or scheduled content → public display pages render the resulting content.
   - `Schedule.cs` in the models suggests time-based or rule-based playback is part of the content delivery model.

12. **Testing and deployment**
   - `NarrowcastingTest` contains tests for at least login and screen behavior, indicating the app has some automated verification around authentication and screen-related logic.
   - `Dockerfile`, `.dockerignore`, and `serviceDependencies*.json` show the project is prepared for containerized and possibly cloud deployment.
   - `appsettings*.json` holds environment-specific configuration, likely including connection strings and identity/runtime settings.

Main entry points: [`Narrowcasting/Interfaces/IAnnouncementService.cs`](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Interfaces/IAnnouncementService.cs) (Service contracts), [`Narrowcasting/Data/ApplicationDbContext.cs`](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Data/ApplicationDbContext.cs) (DbContext), [`Narrowcasting/Pages/Admin/Index.cshtml`](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Pages/Admin/Index.cshtml) (Admin UI), [`Narrowcasting/Controllers/AnnouncementsController.cs`](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Controllers/AnnouncementsController.cs) (Controllers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_ui["UI"]
  node_n_admin_pages["Admin UI<br/>razor pages<br/>[Index.cshtml]"]
  node_n_public_pages["Public UI<br/>razor pages<br/>[Index.cshtml]"]
  node_n_mvc_controllers["Controllers<br/>mvc endpoints"]
end

subgraph group_grp_domain["Domain"]
  node_n_dbcontext[("DbContext<br/>ef core context")]
  node_n_models_user["User<br/>identity model<br/>[ApplicationUser.cs]"]
  node_n_models_domain["Domain models<br/>entities<br/>[Announcement.cs]"]
  node_n_ann_service["Announcements"]
  node_n_audit_service["Audit<br/>[AuditService.cs]"]
  node_n_department_service["Departments"]
  node_n_media_service["Media files"]
  node_n_playlistitem_service["Playlist items"]
  node_n_playlist_service["Playlists<br/>[PlaylistService.cs]"]
  node_n_screen_service["Screens<br/>[ScreenService.cs]"]
end

subgraph group_grp_identity["Identity"]
  node_n_identity_ui["Identity UI<br/>razor area<br/>[Login.cshtml]"]
end

subgraph group_grp_support["Support"]
  node_n_program["Program<br/>host setup<br/>[Program.cs]"]
  node_n_services_ext["DI setup<br/>composition"]
  node_n_interfaces["Service contracts<br/>abstractions"]
  node_n_userctx_service["User context"]
  node_n_tests["Tests<br/>test project"]
  node_n_docker["Dockerfile<br/>deployment"]
  node_n_uploaded["Uploaded files<br/>filesystem assets"]
end

node_n_program -->|"uses"| node_n_services_ext
node_n_program -->|"configures"| node_n_dbcontext
node_n_program -->|"hosts"| node_n_admin_pages
node_n_program -->|"hosts"| node_n_public_pages
node_n_program -->|"maps"| node_n_mvc_controllers
node_n_program -->|"enables"| node_n_identity_ui
node_n_services_ext -->|"registers"| node_n_interfaces
node_n_interfaces -->|"implemented by"| node_n_ann_service
node_n_interfaces -->|"implemented by"| node_n_audit_service
node_n_interfaces -->|"implemented by"| node_n_department_service
node_n_interfaces -->|"implemented by"| node_n_media_service
node_n_interfaces -->|"implemented by"| node_n_playlistitem_service
node_n_interfaces -->|"implemented by"| node_n_playlist_service
node_n_interfaces -->|"implemented by"| node_n_screen_service
node_n_interfaces -->|"implemented by"| node_n_userctx_service
node_n_ann_service -->|"persists"| node_n_dbcontext
node_n_audit_service -->|"persists"| node_n_dbcontext
node_n_department_service -->|"persists"| node_n_dbcontext
node_n_media_service -->|"persists"| node_n_dbcontext
node_n_media_service -->|"stores files"| node_n_uploaded
node_n_playlistitem_service -->|"persists"| node_n_dbcontext
node_n_playlist_service -->|"persists"| node_n_dbcontext
node_n_screen_service -->|"persists"| node_n_dbcontext
node_n_userctx_service -->|"reads"| node_n_models_user
node_n_admin_pages -->|"uses"| node_n_ann_service
node_n_admin_pages -->|"uses"| node_n_audit_service
node_n_admin_pages -->|"uses"| node_n_department_service
node_n_admin_pages -->|"uses"| node_n_media_service
node_n_admin_pages -->|"uses"| node_n_playlist_service
node_n_admin_pages -->|"uses"| node_n_screen_service
node_n_admin_pages -->|"uses"| node_n_userctx_service
node_n_public_pages -->|"reads"| node_n_playlist_service
node_n_public_pages -->|"reads"| node_n_screen_service
node_n_public_pages -->|"reads"| node_n_media_service
node_n_mvc_controllers -->|"uses"| node_n_ann_service
node_n_mvc_controllers -->|"uses"| node_n_audit_service
node_n_mvc_controllers -->|"uses"| node_n_department_service
node_n_mvc_controllers -->|"uses"| node_n_playlist_service
node_n_mvc_controllers -->|"uses"| node_n_screen_service
node_n_mvc_controllers -->|"uses"| node_n_userctx_service
node_n_identity_ui -->|"authenticates"| node_n_models_user
node_n_dbcontext -->|"maps"| node_n_models_domain
node_n_dbcontext -->|"maps"| node_n_models_user
node_n_tests -.->|"verifies"| node_n_identity_ui
node_n_tests -.->|"verifies"| node_n_screen_service
node_n_docker -->|"packages"| node_n_program

click node_n_program "https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Program.cs"
click node_n_services_ext "https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Services/ServiceExtensions.cs"
click node_n_dbcontext "https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Data/ApplicationDbContext.cs"
click node_n_models_user "https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Models/ApplicationUser.cs"
click node_n_models_domain "https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Models/Announcement.cs"
click node_n_interfaces "https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Interfaces/IAnnouncementService.cs"
click node_n_ann_service "https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Services/AnnouncementService.cs"
click node_n_audit_service "https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Services/AuditService.cs"
click node_n_department_service "https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Services/DepartmentService.cs"
click node_n_media_service "https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Services/MediaFileService.cs"
click node_n_playlistitem_service "https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Services/PlaylistItemService.cs"
click node_n_playlist_service "https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Services/PlaylistService.cs"
click node_n_screen_service "https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Services/ScreenService.cs"
click node_n_userctx_service "https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Services/UserContextService.cs"
click node_n_admin_pages "https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Pages/Admin/Index.cshtml"
click node_n_public_pages "https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Pages/Public/Index.cshtml"
click node_n_mvc_controllers "https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Controllers/AnnouncementsController.cs"
click node_n_identity_ui "https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Areas/Identity/Pages/Account/Login.cshtml"
click node_n_tests "https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/NarrowcastingTest/NarrowcastingTest.csproj"
click node_n_docker "https://github.com/zuyd-hogeschool/narrowcasting/tree/develop/Narrowcasting/Dockerfile"
click node_n_uploaded "https://github.com/zuyd-hogeschool/narrowcasting/tree/develop/UploadedFiles"

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_n_admin_pages,node_n_public_pages,node_n_mvc_controllers toneBlue
class node_n_dbcontext,node_n_models_user,node_n_models_domain,node_n_ann_service,node_n_audit_service,node_n_department_service,node_n_media_service,node_n_playlistitem_service,node_n_playlist_service,node_n_screen_service toneAmber
class node_n_identity_ui toneMint
class node_n_program,node_n_services_ext,node_n_interfaces,node_n_userctx_service,node_n_tests,node_n_docker,node_n_uploaded toneRose
```

## Components

### UI

Razor Pages and MVC endpoints for admin and public-facing flows

- [Admin UI](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Pages/Admin/Index.cshtml): razor pages · Management dashboard and CRUD surfaces · `Narrowcasting/Pages/Admin/Index.cshtml`
- [Public UI](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Pages/Public/Index.cshtml): razor pages · Public playback and informational pages · `Narrowcasting/Pages/Public/Index.cshtml`
- [Controllers](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Controllers/AnnouncementsController.cs): mvc endpoints · Controller-based access to core resources · `Narrowcasting/Controllers/AnnouncementsController.cs`

### Domain

Core application models and persistence

- [DbContext](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Data/ApplicationDbContext.cs): ef core context · Main persistence boundary for Identity and domain data · `Narrowcasting/Data/ApplicationDbContext.cs`
- [User](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Models/ApplicationUser.cs): identity model · Application-specific Identity user · `Narrowcasting/Models/ApplicationUser.cs`
- [Domain models](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Models/Announcement.cs): entities · Screens, playlists, media, announcements, departments, schedules, and logs · `Narrowcasting/Models/Announcement.cs`
- [Announcements](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Services/AnnouncementService.cs): service · Announcement business operations · `Narrowcasting/Services/AnnouncementService.cs`
- [Audit](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Services/AuditService.cs): service · Audit trail and activity recording · `Narrowcasting/Services/AuditService.cs`
- [Departments](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Services/DepartmentService.cs): service · Department management logic · `Narrowcasting/Services/DepartmentService.cs`
- [Media files](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Services/MediaFileService.cs): service · Uploaded file handling and media metadata · `Narrowcasting/Services/MediaFileService.cs`
- [Playlist items](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Services/PlaylistItemService.cs): service · Playlist composition logic · `Narrowcasting/Services/PlaylistItemService.cs`
- [Playlists](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Services/PlaylistService.cs): service · Playlist lifecycle and playback organization · `Narrowcasting/Services/PlaylistService.cs`
- [Screens](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Services/ScreenService.cs): service · Screen management and assignment logic · `Narrowcasting/Services/ScreenService.cs`

### Identity

ASP.NET Core Identity UI and user account flows

- [Identity UI](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Areas/Identity/Pages/Account/Login.cshtml): razor area · Generated authentication and account management pages · `Narrowcasting/Areas/Identity/Pages/Account/Login.cshtml`

### Support

Composition, deployment, tests, and runtime assets

- [Program](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Program.cs): host setup · ASP.NET Core app bootstrap and middleware pipeline · `Narrowcasting/Program.cs`
- [DI setup](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Services/ServiceExtensions.cs): composition · Registers application services into the container · `Narrowcasting/Services/ServiceExtensions.cs`
- [Service contracts](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Interfaces/IAnnouncementService.cs): abstractions · Interfaces for business services and user context · `Narrowcasting/Interfaces/IAnnouncementService.cs`
- [User context](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/Narrowcasting/Services/UserContextService.cs): service · Current user and authorization context · `Narrowcasting/Services/UserContextService.cs`
- [Tests](https://github.com/zuyd-hogeschool/narrowcasting/blob/develop/NarrowcastingTest/NarrowcastingTest.csproj): test project · Automated checks for login and screen behavior · `NarrowcastingTest/NarrowcastingTest.csproj`
- [Dockerfile](https://github.com/zuyd-hogeschool/narrowcasting/tree/develop/Narrowcasting/Dockerfile): deployment · Container build and runtime definition · `Narrowcasting/Dockerfile`
- [Uploaded files](https://github.com/zuyd-hogeschool/narrowcasting/tree/develop/UploadedFiles): filesystem assets · On-disk storage for media uploads · `UploadedFiles`

## Connections

- Program → DI setup: uses · Bootstraps registered application services
- Program → DbContext: configures · Wires EF Core persistence into the app
- Program → Admin UI: hosts · Serves the admin Razor Pages surface
- Program → Public UI: hosts · Serves the public playback surface
- Program → Controllers: maps · Exposes controller endpoints
- Program → Identity UI: enables · Integrates ASP.NET Core Identity pages
- DI setup → Service contracts: registers · Binds contracts to concrete services
- Service contracts → Announcements: implemented by · Announcement service contract
- Service contracts → Audit: implemented by · Audit service contract
- Service contracts → Departments: implemented by · Department service contract
- Service contracts → Media files: implemented by · Media service contract
- Service contracts → Playlist items: implemented by · Playlist item service contract
- Service contracts → Playlists: implemented by · Playlist service contract
- Service contracts → Screens: implemented by · Screen service contract
- Service contracts → User context: implemented by · User context contract
- Announcements → DbContext: persists · Reads and writes announcements
- Audit → DbContext: persists · Stores audit events
- Departments → DbContext: persists · Stores departments
- Media files → DbContext: persists · Stores media metadata
- Media files → Uploaded files: stores files · Writes uploaded binary assets to disk
- Playlist items → DbContext: persists · Stores playlist item composition
- Playlists → DbContext: persists · Stores playlists
- Screens → DbContext: persists · Stores screen data
- User context → User: reads · Resolves current application user
- Admin UI → Announcements: uses · Admin management of announcements
- Admin UI → Audit: uses · Admin audit log viewing
- Admin UI → Departments: uses · Admin department management
- Admin UI → Media files: uses · Admin media upload management
- Admin UI → Playlists: uses · Admin playlist management
- Admin UI → Screens: uses · Admin screen management
- Admin UI → User context: uses · Admin authorization and user context
- Public UI → Playlists: reads · Displays playlist-driven content
- Public UI → Screens: reads · Looks up screen-specific playback state
- Public UI → Media files: reads · Resolves media assets for playback
- Controllers → Announcements: uses · Controller access to announcement operations
- Controllers → Audit: uses · Controller access to audit records
- Controllers → Departments: uses · Controller access to department operations
- Controllers → Playlists: uses · Controller access to playlist operations
- Controllers → Screens: uses · Controller access to screen operations
- Controllers → User context: uses · Controller access to user context
- Identity UI → User: authenticates · Built around the application user type
- DbContext → Domain models: maps · EF Core maps core domain entities
- DbContext → User: maps · EF Core maps the identity user model
- Tests → Identity UI: verifies · Covers login-related behavior
- Tests → Screens: verifies · Covers screen behavior
- Dockerfile → Program: packages · Builds and runs the ASP.NET Core app
