# vanshika6605/ai-hospital-management-app architecture

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

- Interactive diagram: https://gitdiagram.com/vanshika6605/ai-hospital-management-app
- Repository: https://github.com/vanshika6605/ai-hospital-management-app

## Overview

1. This is an ASP.NET Core MVC hospital management system built around a layered monolith: UI controllers and Razor views, a service layer, a repository layer, and Entity Framework Core persistence.

2. The application is split into role-based MVC Areas: Admin, Doctor, Patient, Receptionist, and Identity. Each area has its own controllers and views, which is the main presentation boundary in the repo.

3. The shared, non-area entry point is minimal: `HomeController` and shared views/layouts under `Views/Shared`. The root layout and login partial indicate a single server-rendered web app with authenticated and unauthenticated entry paths.

4. Identity is handled separately under `Areas/Identity/Pages/Account` using Razor Pages for login and registration. That boundary suggests ASP.NET Core Identity is the auth subsystem, independent from the role-specific MVC pages.

5. The domain model lives in `Models/Domain` and centers on hospital entities such as `Patient`, `Doctor`, `Appointment`, `Department`, `Bill`, `Prescription`, `MedicalRecord`, `DoctorSchedule`, `Notification`, and `ApplicationUser`. `AppointmentStatus` is the main workflow enum.

6. EF Core persistence is wired through `Data/ApplicationDbContext.cs`, with migrations tracked in `Data/Migrations`. `SeedData.cs` suggests startup data population for initial users, roles, or reference records.

7. The repository layer is thin and currently focused on appointments: a generic repository abstraction plus an appointment-specific repository. This implies most data access is meant to be centralized behind repositories, with room for entity-specific extensions where needed.

8. The service layer contains the business workflows: appointments, billing, departments, doctors, patients, prescriptions, and notifications. These services likely coordinate validation, status changes, cross-entity updates, and persistence through repositories.

9. Controllers in each area depend on those services rather than on the DbContext directly. That keeps UI actions separate from business rules: for example, Admin controllers manage CRUD screens, Doctor controllers handle dashboards/prescriptions, Receptionist handles billing, and Patient/Doctor dashboards surface role-specific data.

10. View models in `ViewModels` act as the UI contract between controllers and Razor views. They separate presentation shape from domain entities, especially for forms like appointments, bills, departments, doctors, patients, and prescriptions.

11. The notification subsystem has both a domain entity and a SignalR hub (`Hubs/NotificationHub.cs`) plus a notification service. That indicates a real-time push channel for events such as booking, billing, or status updates, alongside standard request/response MVC flows.

12. Static assets and client libraries are bundled under `wwwroot`, with Bootstrap, jQuery, validation, and site-specific CSS/JS. This is a server-rendered app with lightweight client-side enhancement rather than a SPA.

13. `Program.cs` is the composition root where MVC, Identity, EF Core, services, repositories, and SignalR are wired together. The app’s runtime boundary is therefore a conventional ASP.NET Core web host backed by a relational database via EF Core.

14. For an architecture diagram, the key data flow is: browser request → role/area controller or Identity page → service → repository → `ApplicationDbContext`/database, with notifications optionally flowing through SignalR back to connected clients.

Main entry points: [`Program.cs`](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Program.cs) (Program), [`Data/ApplicationDbContext.cs`](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Data/ApplicationDbContext.cs) (Db Context), [`Areas/Admin/Controllers/DashboardController.cs`](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Areas/Admin/Controllers/DashboardController.cs) (Admin Area), [`Repositories/Implementations/GenericRepository.cs`](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Repositories/Implementations/GenericRepository.cs) (Generic Repo)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_home_controller["Home<br/>mvc controller<br/>[HomeController.cs]"]
  node_shared_views["Shared Views<br/>razor views<br/>[_Layout.cshtml]"]
  node_admin_area["Admin Area<br/>mvc area"]
  node_doctor_area["Doctor Area<br/>mvc area"]
  node_patient_area["Patient Area<br/>mvc area"]
  node_receptionist_area["Receptionist Area<br/>mvc area"]
end

subgraph group_identity["Identity"]
  node_identity_pages["Identity Pages<br/>razor pages<br/>[Login.cshtml]"]
end

subgraph group_application["Application"]
  node_appointment_service["Appointments"]
  node_billing_service["Billing<br/>[BillingService.cs]"]
  node_doctor_service["Doctors<br/>[DoctorService.cs]"]
  node_patient_service["Patients<br/>[PatientService.cs]"]
  node_department_service["Departments"]
  node_prescription_service["Prescriptions"]
  node_appointment_repo["Appt Repo"]
  node_generic_repo["Generic Repo"]
end

subgraph group_persistence["Persistence"]
  node_db_context[("Db Context<br/>ef core context")]
  node_seed_data["Seed Data<br/>database seeding<br/>[SeedData.cs]"]
  node_migrations["Migrations<br/>schema history"]
end

subgraph group_realtime["Realtime"]
  node_notification_service["Notifications"]
  node_notification_hub(("SignalR Hub<br/>realtime hub<br/>[NotificationHub.cs]"))
end

subgraph group_domain["Domain"]
  node_domain_models["Domain Models<br/>entities<br/>[Appointment.cs]"]
  node_appointment_status{{"Status Enum<br/>workflow enum"}}
  node_view_models["View Models<br/>ui contracts"]
end

subgraph group_composition["Host"]
  node_program["Program<br/>startup host<br/>[Program.cs]"]
end

node_program -->|"maps"| node_admin_area
node_program -->|"maps"| node_doctor_area
node_program -->|"maps"| node_patient_area
node_program -->|"maps"| node_receptionist_area
node_program -->|"enables"| node_identity_pages
node_program -->|"injects"| node_appointment_service
node_program -->|"injects"| node_billing_service
node_program -->|"injects"| node_doctor_service
node_program -->|"injects"| node_patient_service
node_program -->|"injects"| node_department_service
node_program -->|"injects"| node_prescription_service
node_program -->|"injects"| node_notification_service
node_program -->|"configures"| node_db_context
node_program -->|"hosts"| node_notification_hub
node_home_controller -->|"renders"| node_shared_views
node_admin_area -->|"uses"| node_view_models
node_doctor_area -->|"uses"| node_view_models
node_patient_area -->|"uses"| node_view_models
node_receptionist_area -->|"uses"| node_view_models
node_identity_pages -->|"shares"| node_shared_views
node_admin_area -->|"calls"| node_appointment_service
node_admin_area -->|"calls"| node_doctor_service
node_admin_area -->|"calls"| node_patient_service
node_admin_area -->|"calls"| node_department_service
node_doctor_area -->|"calls"| node_prescription_service
node_patient_area -->|"calls"| node_appointment_service
node_receptionist_area -->|"calls"| node_billing_service
node_appointment_service -->|"uses"| node_appointment_repo
node_appointment_service -->|"publishes"| node_notification_service
node_billing_service -->|"uses"| node_generic_repo
node_doctor_service -->|"uses"| node_generic_repo
node_patient_service -->|"uses"| node_generic_repo
node_department_service -->|"uses"| node_generic_repo
node_prescription_service -->|"uses"| node_generic_repo
node_notification_service -->|"pushes"| node_notification_hub
node_appointment_repo -->|"queries"| node_db_context
node_generic_repo -->|"queries"| node_db_context
node_db_context -->|"maps"| node_domain_models
node_db_context -->|"uses"| node_appointment_status
node_db_context -->|"evolves"| node_migrations
node_seed_data -->|"seeds"| node_db_context
node_view_models -->|"adapts"| node_domain_models

click node_program "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Program.cs"
click node_home_controller "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Controllers/HomeController.cs"
click node_shared_views "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Views/Shared/_Layout.cshtml"
click node_admin_area "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Areas/Admin/Controllers/DashboardController.cs"
click node_doctor_area "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Areas/Doctor/Controllers/DashboardController.cs"
click node_patient_area "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Areas/Patient/Controllers/DashboardController.cs"
click node_receptionist_area "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Areas/Receptionist/Controllers/BillingController.cs"
click node_identity_pages "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Areas/Identity/Pages/Account/Login.cshtml"
click node_appointment_service "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Services/Implementations/AppointmentService.cs"
click node_billing_service "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Services/Implementations/BillingService.cs"
click node_doctor_service "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Services/Implementations/DoctorService.cs"
click node_patient_service "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Services/Implementations/PatientService.cs"
click node_department_service "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Services/Implementations/DepartmentService.cs"
click node_prescription_service "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Services/Implementations/PrescriptionService.cs"
click node_notification_service "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Services/Implementations/NotificationService.cs"
click node_appointment_repo "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Repositories/Implementations/AppointmentRepository.cs"
click node_generic_repo "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Repositories/Implementations/GenericRepository.cs"
click node_db_context "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Data/ApplicationDbContext.cs"
click node_seed_data "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Data/SeedData.cs"
click node_migrations "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Data/Migrations/ApplicationDbContextModelSnapshot.cs"
click node_domain_models "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Models/Domain/Appointment.cs"
click node_appointment_status "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Models/Enums/AppointmentStatus.cs"
click node_view_models "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/ViewModels/AppointmentViewModel.cs"
click node_notification_hub "https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Hubs/NotificationHub.cs"

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_home_controller,node_shared_views,node_admin_area,node_doctor_area,node_patient_area,node_receptionist_area,node_program toneBlue
class node_identity_pages toneAmber
class node_appointment_service,node_billing_service,node_doctor_service,node_patient_service,node_department_service,node_prescription_service,node_appointment_repo,node_generic_repo toneMint
class node_db_context,node_seed_data,node_migrations toneRose
class node_notification_service,node_notification_hub toneIndigo
class node_domain_models,node_appointment_status,node_view_models toneTeal
```

## Components

### Presentation

Role-based MVC areas plus shared server-rendered pages and assets.

- [Home](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Controllers/HomeController.cs): mvc controller · Shared entry controller for the non-area home pages. · `Controllers/HomeController.cs`
- [Shared Views](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Views/Shared/_Layout.cshtml): razor views · Root layout, login partial, error page, and shared MVC templates. · `Views/Shared/_Layout.cshtml`
- [Admin Area](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Areas/Admin/Controllers/DashboardController.cs): mvc area · Administrative controllers and views for appointments, departments, doctors, and patients. · `Areas/Admin/Controllers/DashboardController.cs`
- [Doctor Area](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Areas/Doctor/Controllers/DashboardController.cs): mvc area · Doctor dashboards and prescription workflows. · `Areas/Doctor/Controllers/DashboardController.cs`
- [Patient Area](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Areas/Patient/Controllers/DashboardController.cs): mvc area · Patient dashboard and role-specific pages. · `Areas/Patient/Controllers/DashboardController.cs`
- [Receptionist Area](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Areas/Receptionist/Controllers/BillingController.cs): mvc area · Billing screens for front-desk workflows. · `Areas/Receptionist/Controllers/BillingController.cs`

### Identity

Authentication and account pages built with Razor Pages.

- [Identity Pages](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Areas/Identity/Pages/Account/Login.cshtml): razor pages · Login and registration pages under the Identity area. · `Areas/Identity/Pages/Account/Login.cshtml`

### Application

Business workflows implemented through services and repositories.

- [Appointments](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Services/Implementations/AppointmentService.cs): service · Coordinates booking, status changes, and appointment workflows. · `Services/Implementations/AppointmentService.cs`
- [Billing](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Services/Implementations/BillingService.cs): service · Handles billing and invoice-related business rules. · `Services/Implementations/BillingService.cs`
- [Doctors](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Services/Implementations/DoctorService.cs): service · Business logic for doctor management and schedules. · `Services/Implementations/DoctorService.cs`
- [Patients](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Services/Implementations/PatientService.cs): service · Patient management and related workflow logic. · `Services/Implementations/PatientService.cs`
- [Departments](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Services/Implementations/DepartmentService.cs): service · Department management and lookup logic. · `Services/Implementations/DepartmentService.cs`
- [Prescriptions](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Services/Implementations/PrescriptionService.cs): service · Creates and manages prescriptions and medication details. · `Services/Implementations/PrescriptionService.cs`
- [Appt Repo](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Repositories/Implementations/AppointmentRepository.cs): repository · Appointment-specific data access built on the generic repository. · `Repositories/Implementations/AppointmentRepository.cs`
- [Generic Repo](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Repositories/Implementations/GenericRepository.cs): repository · Shared repository abstraction for common EF Core operations. · `Repositories/Implementations/GenericRepository.cs`

### Persistence

Entity Framework Core database access, schema, and seed data.

- [Db Context](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Data/ApplicationDbContext.cs): ef core context · ApplicationDbContext and DbSet mappings for the hospital domain. · `Data/ApplicationDbContext.cs`
- [Seed Data](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Data/SeedData.cs): database seeding · Initial data population for users, roles, and reference records. · `Data/SeedData.cs`
- [Migrations](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Data/Migrations/ApplicationDbContextModelSnapshot.cs): schema history · EF Core migrations and model snapshot tracking schema evolution. · `Data/Migrations/ApplicationDbContextModelSnapshot.cs`

### Realtime

SignalR notification channel and related push workflow.

- [Notifications](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Services/Implementations/NotificationService.cs): service · Creates notifications and pushes updates to clients. · `Services/Implementations/NotificationService.cs`
- [SignalR Hub](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Hubs/NotificationHub.cs): realtime hub · Push channel for live notification delivery to connected clients. · `Hubs/NotificationHub.cs`

### Domain

Hospital entities, enums, and view models used across layers.

- [Domain Models](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Models/Domain/Appointment.cs): entities · Hospital entities such as Patient, Doctor, Appointment, Bill, Prescription, and Notification. · `Models/Domain/Appointment.cs`
- [Status Enum](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Models/Enums/AppointmentStatus.cs): workflow enum · Appointment lifecycle states used across booking and doctor workflows. · `Models/Enums/AppointmentStatus.cs`
- [View Models](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/ViewModels/AppointmentViewModel.cs): ui contracts · Presentation shapes for appointment, billing, department, doctor, patient, and prescription screens. · `ViewModels/AppointmentViewModel.cs`

### Host

Application startup and dependency wiring.

- [Program](https://github.com/vanshika6605/ai-hospital-management-app/blob/main/Program.cs): startup host · Composition root wiring MVC, Identity, EF Core, services, repositories, and SignalR. · `Program.cs`

## Connections

- Program → Admin Area: maps · Registers the admin MVC area in the web host.
- Program → Doctor Area: maps · Registers the doctor MVC area in the web host.
- Program → Patient Area: maps · Registers the patient MVC area in the web host.
- Program → Receptionist Area: maps · Registers the receptionist MVC area in the web host.
- Program → Identity Pages: enables · Configures Identity Razor Pages for authentication.
- Program → Appointments: injects · Wires the appointment workflow service into DI.
- Program → Billing: injects · Wires the billing workflow service into DI.
- Program → Doctors: injects · Wires the doctor workflow service into DI.
- Program → Patients: injects · Wires the patient workflow service into DI.
- Program → Departments: injects · Wires the department workflow service into DI.
- Program → Prescriptions: injects · Wires the prescription workflow service into DI.
- Program → Notifications: injects · Wires the notification service into DI.
- Program → Db Context: configures · Registers EF Core persistence for the application database.
- Program → SignalR Hub: hosts · Maps the real-time notification hub.
- Home → Shared Views: renders · Uses shared MVC layout and templates.
- Admin Area → View Models: uses · Shapes CRUD and booking screens with view models.
- Doctor Area → View Models: uses · Shapes dashboard and prescription screens with view models.
- Patient Area → View Models: uses · Shapes patient dashboard data for views.
- Receptionist Area → View Models: uses · Shapes billing and invoice views.
- Identity Pages → Shared Views: shares · Uses the common layout and partials where applicable.
- Admin Area → Appointments: calls · Admin appointment screens delegate to the appointment service.
- Admin Area → Doctors: calls · Admin doctor screens delegate to doctor management logic.
- Admin Area → Patients: calls · Admin patient screens delegate to patient management logic.
- Admin Area → Departments: calls · Admin department screens delegate to department management logic.
- Doctor Area → Prescriptions: calls · Doctor prescription screens delegate to prescription logic.
- Patient Area → Appointments: calls · Patient dashboard and booking paths use appointment workflows.
- Receptionist Area → Billing: calls · Billing screens delegate to billing workflow logic.
- Appointments → Appt Repo: uses · Appointment workflow persists through the appointment repository.
- Appointments → Notifications: publishes · Appointment changes can trigger notifications.
- Billing → Generic Repo: uses · Billing workflows persist through shared repository operations.
- Doctors → Generic Repo: uses · Doctor workflows rely on shared repository operations.
- Patients → Generic Repo: uses · Patient workflows rely on shared repository operations.
- Departments → Generic Repo: uses · Department workflows rely on shared repository operations.
- Prescriptions → Generic Repo: uses · Prescription workflows rely on shared repository operations.
- Notifications → SignalR Hub: pushes · Notification service broadcasts real-time updates through the hub.
- Appt Repo → Db Context: queries · Appointment repository talks to EF Core context.
- Generic Repo → Db Context: queries · Shared repository talks to EF Core context.
- Db Context → Domain Models: maps · DbContext maps the hospital entities to the database schema.
- Db Context → Status Enum: uses · Appointment entity state transitions rely on the workflow enum.
- Db Context → Migrations: evolves · Schema changes are tracked through EF Core migrations.
- Seed Data → Db Context: seeds · Initial records are inserted through the application context.
- View Models → Domain Models: adapts · View models translate domain entities into UI-specific shapes.
