How ducdaiii/wwwrootmanage works
1. This repository is a single ASP.NET Core Razor Pages application, not a split frontend/backend system. The PageModels under Pages/ are the main application boundary: they handle HTTP requests, orchestrate service calls, and render server-side HTML.
2. The core business domain is FortiManager/Fortinet site management. The main user-facing areas are Sites, Locations, MacObjects, Report, and Dashboard, with a separate Account area for sign-in, password reset, trusted devices, and device verification.
3. Persistence is centered on Entity Framework Core with SQL Server. Data/ApplicationDbContext.cs, entity configurations, and Migrations/ define the schema and relationships. The model set includes users, roles, permissions, site/location permissions, trusted login devices, password reset tokens, login verification challenges, CLI credentials, audit/API logs, and Fortinet-related site data.
4. Authentication and authorization are custom-built on top of the app’s own user/role/permission tables rather than relying only on defaults. ClaimsTransformer suggests claims are enriched after login, and the presence of TrustedLoginDevice, LoginVerificationChallenge, and PasswordResetToken shows support for multi-step login and account recovery flows.
5. Admin capabilities are a distinct subsystem. The Pages/Admin/* area manages users, permissions, trusted devices, and CLI credentials. This is where operational settings and security state are maintained rather than exposed in the main workflow pages.
6. Fortinet integration is handled by dedicated services, especially FortinetApiService and FortinetTokenService. These services encapsulate external device/API communication so the UI and persistence layers do not speak to Fortinet directly.
7. Backup/automation is another important subsystem. FortigateBackupService, FortigateBackupScheduler, and the fortigate_backup.py script indicate a scheduled or scripted backup workflow around FortiGate devices. This is separate from the interactive site-management flow and likely runs as background/ops work.
8. The app also has a clear notification channel. IEmailSender and SmtpEmailSender handle outbound email, with HTML templates stored under wwwroot/email-templates/. This supports password reset and verification-related user journeys.
9. Logging and auditability are first-class concerns. ApiLog, AuditLog, and Services/Logging/AuditDbLoggerProvider.cs show that operational actions and external calls are persisted for traceability, which is important for an admin/security-oriented tool.
10. The data model also covers network-adjacent management concerns beyond sites: DHCP* models, FortiSiteIP, and permission join tables (UserSitePermission, UserLocationPermission, RolePermission, UserRole) suggest the app manages both inventory and access boundaries, not just simple CRUD records.
11. In terms of data flow, the typical pattern is: a PageModel receives a user action, calls a domain service or DbContext operation, and the result is stored in SQL Server. External reads/writes to Fortinet devices are funneled through the Fortinet services, then translated into persisted entities.
12. Operationally, the app is self-contained: static assets live in wwwroot/, the UI uses Bootstrap/jQuery assets bundled locally, and deployment automation is defined in .github/workflows/deploy.yml. This looks like a traditional monolith deployed as one unit, with SQL Server and Fortinet/SMTP as the main external dependencies.
Main entry points: ApplicationDbContext.cs DbContext · Program.cs Program · Index.cshtml.cs Sites · FortinetApiService.cs Fortinet API
Components 34
Razor Pages
Server-rendered application entrypoints and user workflows
- Dashboard · Entry dashboard for site and operational status
wwwrootmanage/Pages/Dashboard.cshtml.cs - Sites · Primary site inventory and detail workflow
wwwrootmanage/Pages/Sites/Index.cshtml.cs - Locations · Location management and assignment workflow
wwwrootmanage/Pages/Locations/Index.cshtml.cs - MacObjects · MAC object management workflow
wwwrootmanage/Pages/MacObjects/Index.cshtml.cs - Report · Reporting and operational views
wwwrootmanage/Pages/Report/Index.cshtml.cs
Account
Sign-in and recovery flows
- Login · Authentication and device verification entry
wwwrootmanage/Pages/Account/Login.cshtml.cs - Recovery · Password reset and trusted device flows
wwwrootmanage/Pages/Account/ForgotPassword.cshtml.cs - Verify Device · Multi-step login verification challenge
wwwrootmanage/Pages/Account/VerifyDevice.cshtml.cs
Admin
Operational management surfaces
- Users · User administration and access management
wwwrootmanage/Pages/Admin/Users/Index.cshtml.cs - Permissions · Permission and role administration
wwwrootmanage/Pages/Admin/Permissions/Index.cshtml.cs - Trusted Devices · Trusted login device administration
wwwrootmanage/Pages/Admin/TrustedDevices/Index.cshtml.cs - CLI Credentials · Managed credentials for device access
wwwrootmanage/Pages/Admin/CliCredentials.cshtml.cs
Core Services
Business logic, integration, and background operations
- Program · Wires services, auth, pages, and middleware
wwwrootmanage/Program.cs - Claims Transformer · Enriches user claims after sign-in
wwwrootmanage/Services/ClaimsTransformer.cs - Fortinet API · External FortiManager/FortiGate API access
wwwrootmanage/Services/FortinetApiService.cs - Token Service · Manages Fortinet authentication tokens
wwwrootmanage/Services/FortinetTokenService.cs - Backup Service · FortiGate backup execution and orchestration
wwwrootmanage/Services/FortigateBackupService.cs - Backup Scheduler · Schedules automated backup runs
wwwrootmanage/Services/FortigateBackupScheduler.cs - Email Sender · Outbound email abstraction for account flows
wwwrootmanage/Services/IEmailSender.cs - SMTP Sender · SMTP implementation for outbound mail
wwwrootmanage/Services/SmtpEmailSender.cs - Audit Logger · Persists audit and operational logs
wwwrootmanage/Services/Logging/AuditDbLoggerProvider.cs
Persistence
EF Core context, schema, and domain entities
- DbContext · Central SQL Server persistence boundary
wwwrootmanage/Data/ApplicationDbContext.cs - User · Application user and security state
wwwrootmanage/Models/User.cs - FortiSite · Managed Fortinet site record
wwwrootmanage/Models/FortiSite.cs - Location · Physical or logical location record
wwwrootmanage/Models/Location.cs - Permission · Named permission capability
wwwrootmanage/Models/Permission.cs - Trusted Device · Trusted login device record
wwwrootmanage/Models/TrustedLoginDevice.cs - Reset Token · Password reset token record
wwwrootmanage/Models/PasswordResetToken.cs - Login Challenge · Device verification challenge record
wwwrootmanage/Models/LoginVerificationChallenge.cs - Audit Log · Security and operational audit trail
wwwrootmanage/Models/AuditLog.cs - API Log · External API call log
wwwrootmanage/Models/ApiLog.cs - CLI Credentials · Stored credentials for administrative device access
wwwrootmanage/Models/CliCredentials.cs - DHCP Models · Reserved lease and monitor data for network operations
wwwrootmanage/Models/DhcpMonitorLeaseDetail.cs - Site IP · IP association for a managed site
wwwrootmanage/Models/FortiSiteIP.cs
Connections 38
- Program → DbContext: registers · Configures EF Core and app services
- Program → Claims Transformer: adds · Registers claims enrichment after authentication
- Program → Fortinet API: adds · Registers Fortinet integration services
- Program → Backup Service: adds · Registers backup orchestration
- Program → Email Sender: adds · Registers notification abstraction
- Program → Audit Logger: adds · Registers audit logging provider
- Dashboard → DbContext: reads · Loads dashboard state from persisted data
- Sites → DbContext: reads/writes · Manages sites and related records
- Sites → Fortinet API: syncs · Uses Fortinet API for device-backed site data
- Sites → FortiSite: persists · Creates and updates site entities
- Sites → Site IP: persists · Maintains site IP associations
- Locations → DbContext: reads/writes · Manages location entities and permissions
- Locations → Location: persists · Creates and updates location entities
- MacObjects → DbContext: reads/writes · Manages MAC-related operational records
- Report → DbContext: reads · Builds reports from persisted domain data
- Login → Claims Transformer: uses · Consumes enriched claims after sign-in
- Login → DbContext: authenticates · Validates users and login state
- Recovery → Email Sender: sends · Delivers reset and verification mail
- Recovery → DbContext: stores · Persists reset tokens and trusted device state
- Verify Device → DbContext: checks · Validates login verification challenges
- Users → DbContext: reads/writes · Administers user accounts and assignments
- Permissions → DbContext: reads/writes · Administers roles and permissions
- Trusted Devices → DbContext: reads/writes · Administers trusted device records
- CLI Credentials → DbContext: reads/writes · Manages CLI credential records
- Fortinet API → Token Service: uses · Acquires and refreshes API tokens
- Backup Service → Fortinet API: calls · Uses Fortinet connectivity for backup operations
- Backup Scheduler → Backup Service: triggers · Schedules automated backup runs
- SMTP Sender → Email Sender: implements · SMTP backs the mail abstraction
- Audit Logger → DbContext: writes · Persists audit and operational events
- DbContext → User: maps · Holds user table and security tables
- DbContext → Permission: maps · Holds permission tables and joins
- DbContext → Trusted Device: maps · Holds trusted login devices
- DbContext → Reset Token: maps · Holds password reset tokens
- DbContext → Login Challenge: maps · Holds device verification challenges
- DbContext → Audit Log: maps · Holds audit trail entries
- DbContext → API Log: maps · Holds external API logs
- DbContext → CLI Credentials: maps · Holds CLI credential records
- DbContext → DHCP Models: maps · Holds DHCP-related operational data